From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 704DA1FA176 for ; Fri, 3 Jan 2025 12:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735908294; cv=none; b=s8mjt7Io8EeNJgX6y0yGeJsimkJuKbCVVvniuntZZyAsqdHpG0KuZwfrvTaWtkdwezZm9T8DZfgTTBWX8IJBI5V/3SbBSrnWf4aAVEORXzNVMAOn6oWEbpWw95SNfiPHM1dp1PzegEEPcRQO6VO1Bn7Pvnnf80HJ/TP1eL6akfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735908294; c=relaxed/simple; bh=/DLvT3BRETvzu0vhZhTC9gJC4cu48A2fkRE62ikpVrI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IU3EN3atsrvqU68VIPcSRl8xr6IizTJ5J8cTbsIPIs/9NRH8e8ZAYxNEyse7xQR1IOpOTfCSERhCvHotwQleTmllWdh6r7/jayEpBxp9wsgGHWKMN9+NwXFqEqx5NGgbTPZJdpPPFZ7CjtYhQBA/fnH4ZqVpa5xC0vrv4FGn0MQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=aom6v8Qf; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="aom6v8Qf" Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id E09A440E021D; Fri, 3 Jan 2025 12:44:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6OBLd1zaFhcp; Fri, 3 Jan 2025 12:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1735908286; bh=SyDSwOqrq8wgbwDjK4ANOL+V725/oMvEKzRyHtC7kFA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aom6v8QfkSz9TZrljJk0b1vUp7eK6D5rVgzehXAJZ+SF0e3NEehKt3L4IDAVxoJz3 /7UkM68bjZCE+djuLOa+TwvTcrBPhGKW0X6Rt4kfhua/+R8JQWwqzTUDkT3T+DsH3a /75BYAPlyvwEhUBxSK9P7QOD66LO0dcCFaLVMBZBtF7nxn2CBQIuI/J5QzGCiHu1cq zNxaLp5hWHB6hObbs/1dQlyNAj/9XdVh95M3T636L9iayc6FsMKO/WDhxLHa/MGUMD yGPRV8TSkLykN1qwmKJxvvPw2NRBonk5O9bx16nVKdBl7r0TqpgTp312UpRs0YmCIC 0hFC+vvMRFJ+xcDdru7lEM3iZOYkxTl6IzRGmpzj+sqL5coE3do9jHnxolaxrHK0BE 0+s5I6EjrwOPSa3hsMEvGuvhI1tyIgOq71GABConNU4A1RGVw2TdyjD7Dzfj9b6W7C Z+HlU/5Aipqi4VjXTqcv31k7+EYNdyHBdG3WjSI66SaK6alyGRWptbe/VtmD8mAT6K 23T/n6i/3Wt2G4ieuksni+PMglZPHrI+/b2OQ2kqEVVFlT0WelVyuZ1NoAhcBqXdLS NlPuODyplB3aXxVZ5dUlC8JT4PKsiFDme6zK/rwDi20gOzgCLiwMCC0IlVDYF91Xc9 A6tb2fA6VkB6N3FjYPo2Nuwo= Received: from zn.tnic (p200300Ea971F93bA329c23Fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:971f:93ba:329c:23ff:fea6:a903]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4865040E01F9; Fri, 3 Jan 2025 12:44:32 +0000 (UTC) Date: Fri, 3 Jan 2025 13:44:31 +0100 From: Borislav Petkov To: Rik van Riel Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, akpm@linux-foundation.org, nadav.amit@gmail.com, zhengqi.arch@bytedance.com, linux-mm@kvack.org Subject: Re: [PATCH 05/12] x86/mm: add INVLPGB support code Message-ID: <20250103124431.GBZ3fbr-eRbl83G_Fm@fat_crate.local> References: <20241230175550.4046587-1-riel@surriel.com> <20241230175550.4046587-6-riel@surriel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20241230175550.4046587-6-riel@surriel.com> On Mon, Dec 30, 2024 at 12:53:06PM -0500, Rik van Riel wrote: > +static inline void __invlpgb(unsigned long asid, unsigned long pcid, unsigned long addr, > + int extra_count, bool pmd_stride, unsigned long flags) That pmd_stride thing - the callers should supply a bool: true/false instead of 0/1 for more clarity at the call sites. > +{ > + u64 rax = addr | flags; > + u32 ecx = (pmd_stride << 31) | extra_count; You need to handle the case where extra_count becomes negative because callers supply nr=0 and you do "nr - 1" below and then you'll end up flushing 0b1111_1111_1111_1111 TLB entries. "ECX[15:0] contains a count of the number of sequential pages to invalidate in addition to the original virtual address, starting from the virtual address specified in rAX." > + u32 edx = (pcid << 16) | asid; > + > + asm volatile("invlpgb" : : "a" (rax), "c" (ecx), "d" (edx)); > +} -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette