Skip to content

Commit 74a0e79

Browse files
committed
KVM: SVM: Disallow guest from changing userspace's MSR_AMD64_DE_CFG value
Inject a #GP if the guest attempts to change MSR_AMD64_DE_CFG from its *current* value, not if the guest attempts to write a value other than KVM's set of supported bits. As per the comment and the changelog of the original code, the intent is to effectively make MSR_AMD64_DE_CFG read- only for the guest. Opportunistically use a more conventional equality check instead of an exclusive-OR check to detect attempts to change bits. Fixes: d1d93fa ("KVM: SVM: Add MSR-based feature support for serializing LFENCE") Cc: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20240802181935.292540-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent e0183a4 commit 74a0e79

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,8 +3189,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
31893189
if (data & ~msr_entry.data)
31903190
return 1;
31913191

3192-
/* Don't allow the guest to change a bit, #GP */
3193-
if (!msr->host_initiated && (data ^ msr_entry.data))
3192+
/*
3193+
* Don't let the guest change the host-programmed value. The
3194+
* MSR is very model specific, i.e. contains multiple bits that
3195+
* are completely unknown to KVM, and the one bit known to KVM
3196+
* is simply a reflection of hardware capabilities.
3197+
*/
3198+
if (!msr->host_initiated && data != svm->msr_decfg)
31943199
return 1;
31953200

31963201
svm->msr_decfg = data;

0 commit comments

Comments
 (0)