]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: SVM: Serialize updates to global OS-Visible Workarounds variables
authorSean Christopherson <seanjc@google.com>
Thu, 13 Nov 2025 23:14:16 +0000 (15:14 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 3 Mar 2026 20:23:26 +0000 (12:23 -0800)
commitf35043d0f973504e5f199be6287159dc5b373deb
tree8fe8d7b1df4a5fac910d15387ddd664ef9d6fa24
parent2b1a59f7ef96c3f29f0ada1a63f4699c35687e33
KVM: SVM: Serialize updates to global OS-Visible Workarounds variables

Guard writes to the global osvw_status and osvw_len variables with a
spinlock to ensure enabling virtualization on multiple CPUs in parallel
doesn't effectively drop any writes due to writing back stale data.  Don't
bother taking the lock when the boot CPU doesn't support the feature, as
that check is constant for all CPUs, i.e. racing writes will always write
the same value (zero).

Note, the bug was inadvertently "fixed" by commit 9a798b1337af ("KVM:
Register cpuhp and syscore callbacks when enabling hardware"), which
effectively serialized calls to enable virtualization due to how the cpuhp
framework "brings up" CPU.  But KVM shouldn't rely on the mechanics of
cphup to provide serialization.

Link: https://patch.msgid.link/20251113231420.1695919-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c