From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Maksim Davydov <davydov-max@yandex-team.ru>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Daniel Sneddon <daniel.sneddon@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Alexandre Chartre <alexandre.chartre@oracle.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Peter Zijlstra <peterz@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sean Christopherson <seanjc@google.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Nikolay Borisov <nik.borisov@suse.com>,
KP Singh <kpsingh@kernel.org>, Waiman Long <longman@redhat.com>,
Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v5 3/3] x86/bugs: Add 'spectre_bhi=vmexit' cmdline option
Date: Tue, 25 Jun 2024 22:58:28 -0700 [thread overview]
Message-ID: <20240626055828.ziui7i42wofxvfel@treble> (raw)
In-Reply-To: <22da39f0-e73f-4e11-830e-914b5bc04029@yandex-team.ru>
On Mon, May 27, 2024 at 01:45:59PM +0300, Maksim Davydov wrote:
> I think it will be useful for us to have appropriate Kconfig option. Could
> you please add it to the next version?
That should probably be a separate patch, something like the below?
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1d7122a1883e..ab1ea701bc42 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2642,17 +2642,46 @@ config MITIGATION_RFDS
stored in floating point, vector and integer registers.
See also <file:Documentation/admin-guide/hw-vuln/reg-file-data-sampling.rst>
-config MITIGATION_SPECTRE_BHI
- bool "Mitigate Spectre-BHB (Branch History Injection)"
+choice
+ prompt "Mitigate Spectre-BHB (Branch History Injection)"
depends on CPU_SUP_INTEL
- default y
+ default MITIGATION_SPECTRE_BHI_ON
help
Enable BHI mitigations. BHI attacks are a form of Spectre V2 attacks
where the branch history buffer is poisoned to speculatively steer
indirect branches.
+
+ The compile-time default can be set to on, vmexit, or off,
+ corresponding to the "spectre_bhi=" cmdline defaults described in
+ Documentation/admin-guide/kernel-parameters.rst. The cmdline
+ options can be used to override this compile-time default.
+
See <file:Documentation/admin-guide/hw-vuln/spectre.rst>
-endif
+config MITIGATION_SPECTRE_BHI_ON
+ bool "on"
+ help
+ Enable the HW or SW mitigation as needed. This protects the kernel
+ from both syscalls and VMs. Equivalent to the spectre_bhi=on cmdline
+ option.
+
+config MITIGATION_SPECTRE_BHI_VMEXIT
+ bool "vmexit"
+ help
+ On systems which don't have the HW mitigation available, enable the
+ SW mitigation on vmexit ONLY. On such systems, the host kernel is
+ protected from VM-originated BHI attacks, but may still be vulnerable
+ to syscall attacks. Equivalent to the spectre_bhi=vmexit cmdline
+ option.
+
+config MITIGATION_SPECTRE_BHI_OFF
+ bool "off"
+ help
+ Disable the mitigation. Equivalent to the spectre_bhi=off cmdline
+ option.
+endchoice
+
+endif # CPU_MITIGATIONS
config ARCH_HAS_ADD_PAGES
def_bool y
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 94bcf29df465..d415f24b7169 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1628,8 +1628,13 @@ enum bhi_mitigations {
BHI_MITIGATION_VMEXIT_ONLY,
};
-static enum bhi_mitigations bhi_mitigation __ro_after_init =
- IS_ENABLED(CONFIG_MITIGATION_SPECTRE_BHI) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF;
+#ifdef CONFIG_MITIGATION_SPECTRE_BHI_ON
+static enum bhi_mitigations bhi_mitigation __ro_after_init = BHI_MITIGATION_ON;
+#elif CONFIG_MITIGATION_SPECTRE_BHI_VMEXIT
+static enum bhi_mitigations bhi_mitigation __ro_after_init = BHI_MITIGATION_VMEXIT;
+#else
+static enum bhi_mitigations bhi_mitigation __ro_after_init = BHI_MITIGATION_OFF;
+#endif
static int __init spectre_bhi_parse_cmdline(char *str)
{
next prev parent reply other threads:[~2024-06-26 5:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 5:30 [PATCH v5 0/3] x86/bugs: more BHI Josh Poimboeuf
2024-05-07 5:30 ` [PATCH v5 1/3] x86/syscall: Mark exit[_group] syscall handlers __noreturn Josh Poimboeuf
2024-05-07 14:38 ` Paul E. McKenney
2024-06-26 2:21 ` Paul E. McKenney
2024-06-26 5:28 ` Josh Poimboeuf
2024-06-26 6:35 ` Paul E. McKenney
2024-06-27 6:36 ` Alexandre Chartre
2024-05-27 11:15 ` Nikolay Borisov
2024-06-26 5:21 ` Josh Poimboeuf
2024-05-07 5:30 ` [PATCH v5 2/3] x86/bugs: Remove duplicate Spectre cmdline option descriptions Josh Poimboeuf
2024-05-07 15:04 ` Daniel Sneddon
2024-05-08 5:55 ` Josh Poimboeuf
2024-05-08 14:28 ` Daniel Sneddon
2024-05-07 5:30 ` [PATCH v5 3/3] x86/bugs: Add 'spectre_bhi=vmexit' cmdline option Josh Poimboeuf
2024-05-07 14:58 ` Daniel Sneddon
2024-05-08 5:19 ` Josh Poimboeuf
2024-05-27 10:45 ` Maksim Davydov
2024-06-26 5:58 ` Josh Poimboeuf [this message]
2024-05-08 15:10 ` Nikolay Borisov
2024-05-09 5:24 ` Josh Poimboeuf
2024-05-09 8:21 ` Nikolay Borisov
2024-05-20 13:12 ` Maksim Davydov
2024-05-23 1:04 ` Josh Poimboeuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626055828.ziui7i42wofxvfel@treble \
--to=jpoimboe@kernel.org \
--cc=alexandre.chartre@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=bp@alien8.de \
--cc=daniel.sneddon@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=davydov-max@yandex-team.ru \
--cc=gregkh@linuxfoundation.org \
--cc=konrad.wilk@oracle.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@kernel.org \
--cc=nik.borisov@suse.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®