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 584EAC021B8 for ; Sat, 1 Mar 2025 07:24:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFC676B0083; Sat, 1 Mar 2025 02:24:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DAC63280001; Sat, 1 Mar 2025 02:24:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C26826B0089; Sat, 1 Mar 2025 02:24:34 -0500 (EST) 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 A72386B0083 for ; Sat, 1 Mar 2025 02:24:34 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1CF6F161AD1 for ; Sat, 1 Mar 2025 07:24:34 +0000 (UTC) X-FDA: 83172144468.04.D090A1B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 650ED140007 for ; Sat, 1 Mar 2025 07:24:32 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gtscTzal; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740813872; 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=T6rxFlo/hPCWLtCLwR3UaE+JW7XJ8IVSfcU3QpwR0Wo=; b=KaF5QxCBt2Gmi4lbmd30/xshP7nQzGr1o8vHa+kTW1yGzJpXeXrg+mf21atMAtpbVm6ZK/ C2rTqU20LmUSswge370E9RLE6+866+QhrPSM0v9yQVKJkjw/3xAA4B6+KWe8Q+Za6NNrb2 VZtMY9Czkt+t6a9D3bRssSV88Q1pjAA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gtscTzal; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740813872; a=rsa-sha256; cv=none; b=fJQVc9aVGeBzKW6MfvuhuuPJKQ1w27BQ2cLNnqm+MXtOI49LkhVCTUkqe2X5bV2RC2zSWH 2amfEHB69AcH9IXH+nMwiTdLkJD89gpDOjkBlIW/TEsY/LUPNB02aBmkX59RqtBMSTOXKb 35DMXnzlU0lAjxLoLN+IENaeJpPpULc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0912B5C0F7B; Sat, 1 Mar 2025 07:22:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 800D1C4CEDD; Sat, 1 Mar 2025 07:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740813870; bh=zNyC5lhRK0Jp4F93R1ijsSaURdoFR2R28yW7mia17cM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gtscTzalpXI+EBlbvhmEfLi9LdExvWsiMbsCojuFb6z7D6TJ+eIyI5Zu0dNVt1+Rt R7KC6887+sVZtgnQ19+IkfSlJqXOab6/YNi9aZBAtp/VgQU/JqRJpIH8eBc4GGjByG /iEET/+yluuuSKQHZY8L55Rx9HismpEadrVB6zyppH+G3FGWR/3bh3ot8dW5rcHNI7 NKKycvvnkEsnUXv1eFIzBBP8cwd+jkC4/L6TStK9cq+p4BvnEfW2RzlrWF5UZglu5h /IAlH97YxPUeMyrnxQe6BmmTiig5TOwLHznM4yMtuGGFo8JCLj5r1JCg4T+JRGSA6x kS+2S3GSKmFcQ== Date: Sat, 1 Mar 2025 09:23:51 +0200 From: Mike Rapoport To: Brendan Jackman Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Richard Henderson , Matt Turner , Vineet Gupta , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Brian Cain , Huacai Chen , WANG Xuerui , Geert Uytterhoeven , Michal Simek , Thomas Bogendoerfer , Dinh Nguyen , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Richard Weinberger , Anton Ivanov , Johannes Berg , Chris Zankel , Max Filippov , Arnd Bergmann , Andrew Morton , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Uladzislau Rezki , Christoph Hellwig , Masami Hiramatsu , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Dennis Zhou , Tejun Heo , Christoph Lameter , Sean Christopherson , Paolo Bonzini , Ard Biesheuvel , Josh Poimboeuf , Pawan Gupta , x86@kernel.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, Junaid Shahid Subject: Re: [PATCH RFC v2 02/29] x86: Create CONFIG_MITIGATION_ADDRESS_SPACE_ISOLATION Message-ID: References: <20250110-asi-rfc-v2-v2-0-8419288bc805@google.com> <20250110-asi-rfc-v2-v2-2-8419288bc805@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250110-asi-rfc-v2-v2-2-8419288bc805@google.com> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 650ED140007 X-Rspam-User: X-Stat-Signature: dfqubko6a6r5mqi696iajb8mg7qf114i X-HE-Tag: 1740813872-189186 X-HE-Meta: U2FsdGVkX1+1Or7zsCfCSnRWrDr3U1bIG7acyYtO3boemHZPgZBEMxab94bHtqJnn3bc2asSizyrju5Zsuv75YcxKXXeBJj9w/cTsN9mb/QDeHwv19LPVgSlP2O/gXaGZY6D5DbckAxR8hPGRXjQUyGEOi3m2PPMSWtT6ubMqTcTNim8ZCjuicnYYbB+vG8XkoMrnECxsJL3BEXRlyNtN6D0JNqyqgkhRYMaCS4uR85CpitZrUG9tyVVK0/UOm97nShELy/ZJKT6W8mq+6c6CsFH29JXfmp+mPk51FX+K9XyKxSD7aju01CZKn+QzdBcocyX5oBwLF/47z1AvEqtCKQ4YI+Onq9Hbl857/qP/3z1AJXtLWfXGZxGTPxUadDJZDG9RY+4Yi0/ihf+kl6jcnTzkPwxrlAumH5Mkg7Z2jSIo8NCGe4UwzgA4J7wDkKjOhs4qLkJdATHoZRZFRvMQ1EL4RoGuYwMU+QN0xDriB30sk4zDikzepsoT9Xhx6/mxFJn+xQxWqZukwnU9zPVrxf0Znfdcn1U2zxvUi/uIxpfxRHtpMDigO9vQ9RBweGjaYmQczpWBIAYLWUICBEz+ifEp4jEt75fBPcb2660YcsX/BSxQghV2dnHJucZVYdfx+GMTy//iET3QRXtLzIoF7Okhul+oS9VXSE4EmJbAdHpFPFVpSVg/C+6Kw8f3E1OwYjWj3sI5JXpsR6dIpaG48jU8yNiJT4oyWgFwW7FEdHhR1cLvZABnsbeGxnurAF1bbVG8aBhKe6ZDF+WfFpCcbjvWSCYSCqcLK5sXRfovXB4HrrEylqmK1DE9M7GBxHVdVaf+yq0cIL5Y7EgWPKnlhZ+UAGStcBeeKsnZYFeEW/bty1RSyQE2jwQyarPGSMRc2WMgvNmekDY5yv5j2YEI19ofKn+p4s1WiWAUk4DhYSoM7XgMjQYwp7jbm2uEubVE4hBMIb/tGoNIc6xjOh mNQj7QEB ycR9SkJ5JERibcnTccYoXvqQ+SoR+9KwKEiXZkZ2GK8omWSYuJAyhFude95TxBPciF3M48M8CaJ8HVAyU4xDDRpWmfANOWPvZ7ELFwRMWcYpSI4iDMurjba1LWDyvHxrg5dAFebGR79PTuVUrMO36IGgYpvF62BGxxqkEqf9Snk6tSdzJpEID8459v0LNEWoD4lAPGeMKw65dnHT/0Ct8U31pVuBcIhIxHBft2lVUXE4pnIFeupDiRM5O4isczdJdBPDEdkPtqpTJn0eADhw5HcQBBl3eI8hZmJrWF4d+OdLNbInHT41GMOvxrsOn0q1BL1OEp7S3uOZibow= 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: Hi Brendan, On Fri, Jan 10, 2025 at 06:40:28PM +0000, Brendan Jackman wrote: > Currently a nop config. Keeping as a separate commit for easy review of > the boring bits. Later commits will use and enable this new config. > > This config is only added for non-UML x86_64 as other architectures do > not yet have pending implementations. It also has somewhat artificial > dependencies on !PARAVIRT and !KASAN which are explained in the Kconfig > file. > > Co-developed-by: Junaid Shahid > Signed-off-by: Junaid Shahid > Signed-off-by: Brendan Jackman > --- > arch/alpha/include/asm/Kbuild | 1 + > arch/arc/include/asm/Kbuild | 1 + > arch/arm/include/asm/Kbuild | 1 + > arch/arm64/include/asm/Kbuild | 1 + > arch/csky/include/asm/Kbuild | 1 + > arch/hexagon/include/asm/Kbuild | 1 + > arch/loongarch/include/asm/Kbuild | 3 +++ > arch/m68k/include/asm/Kbuild | 1 + > arch/microblaze/include/asm/Kbuild | 1 + > arch/mips/include/asm/Kbuild | 1 + > arch/nios2/include/asm/Kbuild | 1 + > arch/openrisc/include/asm/Kbuild | 1 + > arch/parisc/include/asm/Kbuild | 1 + > arch/powerpc/include/asm/Kbuild | 1 + > arch/riscv/include/asm/Kbuild | 1 + > arch/s390/include/asm/Kbuild | 1 + > arch/sh/include/asm/Kbuild | 1 + > arch/sparc/include/asm/Kbuild | 1 + > arch/um/include/asm/Kbuild | 2 +- > arch/x86/Kconfig | 14 ++++++++++++++ > arch/xtensa/include/asm/Kbuild | 1 + > include/asm-generic/asi.h | 5 +++++ > 22 files changed, 41 insertions(+), 1 deletion(-) I don't think this all is needed. You can put asi.h with stubs used outside of arch/x86 in include/linux and save you the hassle of updating every architecture. > diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild > index 43b0ae4c2c2112d4d4d3cb3c60e787b175172dea..cb9062c9be17fe276cc92d2ac99d8b165f6297bf 100644 > --- a/arch/sparc/include/asm/Kbuild > +++ b/arch/sparc/include/asm/Kbuild > @@ -4,3 +4,4 @@ generated-y += syscall_table_64.h > generic-y += agp.h > generic-y += kvm_para.h > generic-y += mcs_spinlock.h > +generic-y += asi.h sparc already has include/asm/asi.h, this will break the build > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 7b9a7e8f39acc8e9aeb7d4213e87d71047865f5c..5a50582eb210e9d1309856a737d32b76fa1bfc85 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -2519,6 +2519,20 @@ config MITIGATION_PAGE_TABLE_ISOLATION > > See Documentation/arch/x86/pti.rst for more details. > > +config MITIGATION_ADDRESS_SPACE_ISOLATION > + bool "Allow code to run with a reduced kernel address space" > + default n > + depends on X86_64 && !PARAVIRT && !UML > + help > + This feature provides the ability to run some kernel code > + with a reduced kernel address space. This can be used to > + mitigate some speculative execution attacks. > + > + The !PARAVIRT dependency is only because of lack of testing; in theory > + the code is written to work under paravirtualization. In practice > + there are likely to be unhandled cases, in particular concerning TLB > + flushes. > + If you expect other architectures might implement ASI the config would better fit into init/Kconfig or mm/Kconfig and in arch/x86/Kconfig will define ARCH_HAS_MITIGATION_ADDRESS_SPACE_ISOLATION. > config MITIGATION_RETPOLINE > bool "Avoid speculative indirect branches in kernel" > select OBJTOOL if HAVE_OBJTOOL > diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild > index fa07c686cbcc2153776a478ac4093846f01eddab..07cea6902f98053be244d026ed594fe7246755a6 100644 > --- a/arch/xtensa/include/asm/Kbuild > +++ b/arch/xtensa/include/asm/Kbuild > @@ -8,3 +8,4 @@ generic-y += parport.h > generic-y += qrwlock.h > generic-y += qspinlock.h > generic-y += user.h > +generic-y += asi.h > diff --git a/include/asm-generic/asi.h b/include/asm-generic/asi.h > new file mode 100644 > index 0000000000000000000000000000000000000000..c4d9a5ff860a96428422a15000c622aeecc2d664 > --- /dev/null > +++ b/include/asm-generic/asi.h > @@ -0,0 +1,5 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __ASM_GENERIC_ASI_H > +#define __ASM_GENERIC_ASI_H > + > +#endif IMHO it should be include/linux/asi.h, with something like #infdef __LINUX_ASI_H #define __LINUX_ASI_H #ifdef CONFIG_MITIGATION_ADDRESS_SPACE_ISOLATION #include #else /* CONFIG_MITIGATION_ADDRESS_SPACE_ISOLATION */ /* stubs for functions used outside arch/ */ #endif /* CONFIG_MITIGATION_ADDRESS_SPACE_ISOLATION */ #endif /* __LINUX_ASI_H */ -- Sincerely yours, Mike.