From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 419DFC7EE30 for ; Thu, 26 Jun 2025 13:49:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C47916B009E; Thu, 26 Jun 2025 09:49:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF7F56B009F; Thu, 26 Jun 2025 09:49:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE7C36B00A0; Thu, 26 Jun 2025 09:49:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 983FF6B009E for ; Thu, 26 Jun 2025 09:49:42 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 217C2160219 for ; Thu, 26 Jun 2025 13:49:42 +0000 (UTC) X-FDA: 83597684604.17.9D732FE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 33D3E18000A for ; Thu, 26 Jun 2025 13:49:39 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mwSmQ5JJ ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750945780; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DDjOhg3TDA3lAk/n8wJigYThpB4BiPBNqT914UwqWr4=; b=W/PC6RQevaAUswRN2xAqZErgDCGvwt8sdh6eEE02e2yKHRXlyzlR/zK0XACpklJ3BX+GeM QpBHvdw8qCpTkBa7CX207dpX2t+qLLXuNTr23qO3ePKJ4dh1auywGC69hFS1gRNlfoxK+E Fn6CV4J9JT9+ONdIs+1b9R1tvDSq8gA= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mwSmQ5JJ; spf=none (imf24.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750945780; a=rsa-sha256; cv=none; b=wIWfBN7gHSAdG0/E2YClHtG5GVtEdg2jKwPMhFzFtEyH77LK6aj1dFiq1OgXDiDi6IduoR sz9zTZEmbqfNoE84bMokN4zRa0t8APyyfHGER131yUolr2XvYNmK7vxAbkoq5u4kBxpbo0 jzauKd+T0KmQ0+TrQjHO8eDWUkwKqEI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DDjOhg3TDA3lAk/n8wJigYThpB4BiPBNqT914UwqWr4=; b=mwSmQ5JJj9GCM6h53p6V6Ly1Ur bR/FprIAMYt9ES7WjIwtXs4Fg2epbCSYV5xdWtLV2wmXsyyQGDS4gFn+lqX+bEw+lrzmuLBmv8hPv Phtec8rRMc2b31BMwiypEcQtCXFaB5SmQbpKIaZ7alD2OxxZXneU6FZOPY3ZVqc91pXRdtRm9NxZ3 O2EDB3QNDHO7/8V/JTj2tgMuE7qLsLMd7+kdbu8ZFmRdXOM+WEYSm+0obArX6wiTtkcJr3CgXil9p oyLDhT3tYFfNOghkv3+1UD3dWyLAwUPBK4CNWgO9yggHIIjKofh6og8+FMbA0dd+SscVt8hGtWM1C kufkI7kQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUmyf-0000000BkWF-368u; Thu, 26 Jun 2025 13:49:21 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 4678430BDA9; Thu, 26 Jun 2025 15:49:21 +0200 (CEST) Date: Thu, 26 Jun 2025 15:49:21 +0200 From: Peter Zijlstra To: "Kirill A. Shutemov" Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ard Biesheuvel , "Paul E. McKenney" , Josh Poimboeuf , Xiongwei Song , Xin Li , "Mike Rapoport (IBM)" , Brijesh Singh , Michael Roth , Tony Luck , Alexey Kardashevskiy , Alexander Shishkin , Jonathan Corbet , Sohil Mehta , Ingo Molnar , Pawan Gupta , Daniel Sneddon , Kai Huang , Sandipan Das , Breno Leitao , Rick Edgecombe , Alexei Starovoitov , Hou Tao , Juergen Gross , Vegard Nossum , Kees Cook , Eric Biggers , Jason Gunthorpe , "Masami Hiramatsu (Google)" , Andrew Morton , Luis Chamberlain , Yuntao Wang , Rasmus Villemoes , Christophe Leroy , Tejun Heo , Changbin Du , Huang Shijie , Geert Uytterhoeven , Namhyung Kim , Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv7 03/16] x86/alternatives: Disable LASS when patching kernel alternatives Message-ID: <20250626134921.GK1613200@noisy.programming.kicks-ass.net> References: <20250625125112.3943745-1-kirill.shutemov@linux.intel.com> <20250625125112.3943745-5-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250625125112.3943745-5-kirill.shutemov@linux.intel.com> X-Rspamd-Server: rspam03 X-Rspam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EeqOpg9nmh668t YHjchM3A 39u9+HkWBELnlkz9wa+Epit7ig+S3JrO57+BCBKGuzUIpjTX+jVr6sy97gp3j5K7tu1GPIp4wQz29YyHbRy0UvKovqy8SXG+j7QmaLUBRoGLkU+FIl8DZggurpTDgUl1AskuM6xHNA5BxjWfXxsIdbBBDc61qpUcVZs15YdfIt8aaM7nduuVymXijJpK3O2OHOP9jlK5C5b5G+3Y1IMbBmXHVs3uDeOFtcWJA5PdG4a+HPYf0SOcZ79gXYjyK8+mWy0UK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Jun 25, 2025 at 03:50:56PM +0300, Kirill A. Shutemov wrote: > +/* > + * The CLAC/STAC instructions toggle the enforcement of X86_FEATURE_SMAP and > + * X86_FEATURE_LASS. > + * > + * SMAP enforcement is based on the _PAGE_BIT_USER bit in the page tables: the > + * kernel is not allowed to touch pages with the bit set unless the AC bit is > + * set. > + * > + * LASS enforcement is based on bit 63 of the virtual address. The kernel is > + * not allowed to touch memory in the lower half of the virtual address space > + * unless the AC bit is set. > + * > + * Note: a barrier is implicit in alternative(). > + */ > + > static __always_inline void clac(void) > { > - /* Note: a barrier is implicit in alternative() */ > alternative("", "clac", X86_FEATURE_SMAP); > } > > static __always_inline void stac(void) > { > - /* Note: a barrier is implicit in alternative() */ > alternative("", "stac", X86_FEATURE_SMAP); > } > > +static __always_inline void lass_enable_enforcement(void) > +{ > + alternative("", "clac", X86_FEATURE_LASS); > +} > + > +static __always_inline void lass_disable_enforcement(void) > +{ > + alternative("", "stac", X86_FEATURE_LASS); > +} Much hate for this naming. WTH was wrong with lass_{clac,stac}()? We're not calling those other functions smap_{en,dis}able_enforcement() either (and please don't take that as a suggestion, its terrible naming).