* [PATCH v2] KVM: nSVM: Gate CET state copy in svm_copy_vmrun_state() on guest SHSTK
@ 2026-11-14 0:07 Jim Mattson
0 siblings, 0 replies; only message in thread
From: Jim Mattson @ 2026-11-14 0:07 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: Yosry Ahmed, kvm, linux-kernel, Jim Mattson
svm_copy_vmrun_state() should gate copying s_cet, isst_addr, and ssp on
guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK) (i.e. the feature is advertised
to the guest), without which the shadow stack MSRs cannot be set. Instead,
copying is gated on kvm_cpu_cap_has(X86_FEATURE_SHSTK) (i.e. the host
supports shadow stacks).
Check guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK) instead of
kvm_cpu_cap_has(X86_FEATURE_SHSTK) in svm_copy_vmrun_state().
Fixes: c5ba49458513 ("KVM: nSVM: Save/load CET Shadow Stack state to/from vmcb12/vmcb02")
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Signed-off-by: Jim Mattson <jmattson@google.com>
---
v1 -> v2:
- Drop confusing nested_vmcb02_prepare_save() and
nested_svm_vmexit_update_vmcb12() examples and note that the shadow stack
MSRs cannot be set without guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK) [Yosry]
v1: https://lore.kernel.org/all/20261112212628.265262-1-jmattson@google.com/
arch/x86/kvm/svm/nested.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 1299fdadeb73..b73bc9c3ebdb 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -1248,7 +1248,7 @@ void svm_copy_vmrun_state(struct kvm_vcpu *vcpu, struct vmcb_save_area *to_save,
to_save->rip = from_save->rip;
to_save->cpl = 0;
- if (kvm_cpu_cap_has(X86_FEATURE_SHSTK)) {
+ if (guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK)) {
to_save->s_cet = from_save->s_cet;
to_save->isst_addr = from_save->isst_addr;
to_save->ssp = from_save->ssp;
base-commit: dea4f6380f4ec96e8f3b0aaf2343764bd0d25ef4
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-14 0:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14 0:07 [PATCH v2] KVM: nSVM: Gate CET state copy in svm_copy_vmrun_state() on guest SHSTK Jim Mattson
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®