From: Borislav Petkov <bp@kernel.org>
To: Sean Christopherson <seanjc@google.com>, X86 ML <x86@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
KVM <kvm@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
"Borislav Petkov (AMD)" <bp@alien8.de>
Subject: [PATCH v2 1/4] x86/bugs: Add SRSO_USER_KERNEL_NO support
Date: Mon, 2 Dec 2024 13:04:13 +0100 [thread overview]
Message-ID: <20241202120416.6054-2-bp@kernel.org> (raw)
In-Reply-To: <20241202120416.6054-1-bp@kernel.org>
From: "Borislav Petkov (AMD)" <bp@alien8.de>
If the machine has:
CPUID Fn8000_0021_EAX[30] (SRSO_USER_KERNEL_NO) -- If this bit is 1,
it indicates the CPU is not subject to the SRSO vulnerability across
user/kernel boundaries.
have it fall back to IBPB on VMEXIT only, in the case it is going to run
VMs:
Speculative Return Stack Overflow: CPU user/kernel transitions protected, falling back to IBPB-on-VMEXIT
Speculative Return Stack Overflow: Mitigation: IBPB on VMEXIT only
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/kernel/cpu/bugs.c | 6 ++++++
arch/x86/kernel/cpu/common.c | 1 +
3 files changed, 8 insertions(+)
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 17b6590748c0..2787227a8b42 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -464,6 +464,7 @@
#define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */
#define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */
#define X86_FEATURE_SRSO_NO (20*32+29) /* CPU is not affected by SRSO */
+#define X86_FEATURE_SRSO_USER_KERNEL_NO (20*32+30) /* CPU is not affected by SRSO across user/kernel boundaries */
/*
* Extended auxiliary flags: Linux defined - for features scattered in various
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 47a01d4028f6..8854d9bce2a5 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2615,6 +2615,11 @@ static void __init srso_select_mitigation(void)
break;
case SRSO_CMD_SAFE_RET:
+ if (boot_cpu_has(X86_FEATURE_SRSO_USER_KERNEL_NO)) {
+ pr_notice("CPU user/kernel transitions protected, falling back to IBPB-on-VMEXIT\n");
+ goto ibpb_on_vmexit;
+ }
+
if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
/*
* Enable the return thunk for generated code
@@ -2658,6 +2663,7 @@ static void __init srso_select_mitigation(void)
}
break;
+ibpb_on_vmexit:
case SRSO_CMD_IBPB_ON_VMEXIT:
if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
if (!boot_cpu_has(X86_FEATURE_ENTRY_IBPB) && has_microcode) {
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a5c28975c608..954f9c727f11 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1270,6 +1270,7 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
VULNBL_AMD(0x17, RETBLEED | SMT_RSB | SRSO),
VULNBL_HYGON(0x18, RETBLEED | SMT_RSB | SRSO),
VULNBL_AMD(0x19, SRSO),
+ VULNBL_AMD(0x1a, SRSO),
{}
};
--
2.43.0
next prev parent reply other threads:[~2024-12-02 12:04 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 12:04 [PATCH v2 0/4] x86/bugs: Adjust SRSO mitigation to new features Borislav Petkov
2024-12-02 12:04 ` Borislav Petkov [this message]
2024-12-10 6:53 ` [PATCH v2 1/4] x86/bugs: Add SRSO_USER_KERNEL_NO support Josh Poimboeuf
2024-12-10 15:37 ` Borislav Petkov
2024-12-11 7:53 ` Josh Poimboeuf
2024-12-11 20:38 ` Borislav Petkov
2024-12-11 22:35 ` Sean Christopherson
2024-12-16 17:21 ` Borislav Petkov
2024-12-02 12:04 ` [PATCH v2 2/4] KVM: x86: Advertise SRSO_USER_KERNEL_NO to userspace Borislav Petkov
2024-12-02 12:04 ` [PATCH v2 3/4] x86/bugs: KVM: Add support for SRSO_MSR_FIX Borislav Petkov
2024-12-11 22:27 ` Sean Christopherson
2024-12-16 17:31 ` Borislav Petkov
2024-12-16 18:51 ` Sean Christopherson
2024-12-17 9:34 ` Borislav Petkov
2024-12-30 11:14 ` Borislav Petkov
2025-01-08 13:38 ` Sean Christopherson
2025-01-08 15:49 ` Borislav Petkov
2025-01-08 17:18 ` Sean Christopherson
2025-01-08 18:14 ` Borislav Petkov
2025-01-08 18:37 ` Jim Mattson
2025-01-08 19:14 ` Borislav Petkov
2025-01-08 19:43 ` Jim Mattson
2025-01-08 19:45 ` Borislav Petkov
2025-01-11 12:52 ` [PATCH] " Borislav Petkov
2025-01-17 18:56 ` Sean Christopherson
2025-01-18 15:26 ` Borislav Petkov
2025-01-23 16:25 ` Sean Christopherson
2025-01-23 17:01 ` Borislav Petkov
2025-01-23 18:04 ` Sean Christopherson
2025-01-24 12:58 ` Borislav Petkov
2025-02-11 19:19 ` Jim Mattson
2025-02-11 20:51 ` Borislav Petkov
2025-02-13 10:53 ` Patrick Bellasi
2025-02-13 13:44 ` Patrick Bellasi
2025-02-13 14:28 ` Borislav Petkov
2025-02-13 17:50 ` Patrick Bellasi
2025-02-14 20:10 ` Borislav Petkov
2025-02-15 0:57 ` Yosry Ahmed
2025-02-15 9:15 ` Borislav Petkov
2025-02-17 5:47 ` Yosry Ahmed
2025-02-17 15:26 ` Borislav Petkov
2025-02-15 12:53 ` Borislav Petkov
2025-02-17 5:59 ` Yosry Ahmed
2025-02-17 16:07 ` Borislav Petkov
2025-02-17 19:56 ` Yosry Ahmed
2025-02-17 20:20 ` Borislav Petkov
2025-02-17 20:32 ` Yosry Ahmed
2025-02-18 11:13 ` [PATCH final?] " Borislav Petkov
2025-02-18 14:42 ` Patrick Bellasi
2025-02-18 15:34 ` Borislav Petkov
2025-04-29 13:25 ` x86/bugs: KVM: Add support for SRSO_MSR_FIX, back for moar Borislav Petkov
2025-04-30 23:33 ` Sean Christopherson
2025-05-01 0:42 ` Michael Larabel
2025-05-01 8:19 ` Borislav Petkov
2025-05-01 16:56 ` Sean Christopherson
2025-05-05 15:25 ` Borislav Petkov
2025-05-05 15:40 ` Kaplan, David
2025-05-05 15:47 ` Borislav Petkov
2025-05-05 16:30 ` Sean Christopherson
2025-05-05 16:42 ` Kaplan, David
2025-05-05 18:03 ` Sean Christopherson
2025-05-05 18:25 ` Kaplan, David
2024-12-02 12:04 ` [PATCH v2 4/4] Documentation/kernel-parameters: Fix a typo in kvm.enable_virt_at_load text Borislav Petkov
2024-12-03 14:30 ` [PATCH v2 0/4] x86/bugs: Adjust SRSO mitigation to new features Nikolay Borisov
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=20241202120416.6054-2-bp@kernel.org \
--to=bp@kernel.org \
--cc=bp@alien8.de \
--cc=jpoimboe@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--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