KVM: SVM: Allow guest writes to set MSR_AMD64_DE_CFG bits
Sean Christopherson
maintainerPATCH 1/1 KVM: SVM: Allow guest writes to set MSR_AMD64_DE_CFG bits
Drop KVM's arbitrary behavior of making DE_CFG.LFENCE_SERIALIZE read-only for the guest, as rejecting writes can lead to guest crashes, e.g. Windows in particular doesn't gracefully handle unexpected #GPs on the WRMSR, and nothing in the AMD manuals suggests that LFENCE_SERIALIZE is read-only _if it exists_.
KVM only allows LFENCE_SERIALIZE to be set, by the guest or host, if the underlying CPU has X86_FEATURE_LFENCE_RDTSC, i.e. if LFENCE is guaranteed to be serializing. So if the guest sets LFENCE_SERIALIZE, KVM will provide the desired/correct behavior without any additional action (the guest's value is never stuffed into hardware). And having LFENCE be serializing even when it's not _required_ to be is a-ok from a functional perspective.
--- arch/x86/kvm/svm/svm.c | 9 --------- 1 file changed, 9 deletions(-)
arch/x86/kvm/svm/svm.c +0 -9
@@ -3201,15 +3201,6 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)if (data & ~supported_de_cfg)return 1 ; -/* -* Don't let the guest change the host-programmed value. The -* MSR is very model specific, i.e. contains multiple bits that -* are completely unknown to KVM, and the one bit known to KVM -* is simply a reflection of hardware capabilities. -*/ -if (!msr->host_initiated && data != svm->msr_decfg) -return 1 ; - svm->msr_decfg = data;break ; }
base-commit: fac04efc5c793dccbd07e2d59af9f90b7fc0dca4
Signature · 1 line
2.47.0.338.g60cca15819-goog
Quoted 13 lines · Sean Christopherson
Drop KVM's arbitrary behavior of making DE_CFG.LFENCE_SERIALIZE read-only for the guest, as rejecting writes can lead to guest crashes, e.g. Windows in particular doesn't gracefully handle unexpected #GPs on the WRMSR, and nothing in the AMD manuals suggests that
LFENCE_SERIALIZEis read-only_ifitexists_.KVM only allows
LFENCE_SERIALIZEto be set, by the guest or host, if the underlying CPU hasX86_FEATURE_LFENCE_RDTSC, i.e. if LFENCE is guaranteed to be serializing. So if the guest setsLFENCE_SERIALIZE, KVM will provide the desired/correct behavior without any additional action (the guest's value is never stuffed into hardware). And having LFENCE be serializing even when it's not _required_ to be is a-ok from a functional perspective.
Quoted 7 lines
Fixes 74a0e79df68a ("KVM: SVM: Disallow guest from changing userspace's MSR_AMD64_DE_CFG value")Fixes d1d93fa90f1a ("KVM: SVM: Add MSR-based feature support for serializing LFENCE")Reported-by Simon Pilkington <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Sean Christopherson <[email protected]>
Quoted 26 lines
--- arch/x86/kvm/svm/svm.c | 9 --------- 1 file changed, 9 deletions(-)arch/x86/kvm/svm/svm.c +0
-9@@ -3201,15 +3201,6 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)if (data & ~supported_de_cfg)return 1 ; -/* -* Don't let the guest change the host-programmed value. The -* MSR is very model specific, i.e. contains multiple bits that -* are completely unknown to KVM, and the one bit known to KVM -* is simply a reflection of hardware capabilities. -*/ -if (!msr->host_initiated && data != svm->msr_decfg) -return 1 ; - svm->msr_decfg = data;break ; }base-commit:
fac04efc5c793dccbd07e2d59af9f90b7fc0dca4
Quoted 6 lines · Sean Christopherson
Drop KVM's arbitrary behavior of making DE_CFG.LFENCE_SERIALIZE read-only for the guest, as rejecting writes can lead to guest crashes, e.g. Windows in particular doesn't gracefully handle unexpected #GPs on the WRMSR, and nothing in the AMD manuals suggests that
LFENCE_SERIALIZEis read-only_ifitexists_.
Quoted 8 lines
KVM only allows
LFENCE_SERIALIZEto be set, by the guest or host, if the underlying CPU hasX86_FEATURE_LFENCE_RDTSC, i.e. if LFENCE is guaranteed to be serializing. So if the guest setsLFENCE_SERIALIZE, KVM will provide the desired/correct behavior without any additional action (the guest's value is never stuffed into hardware). And having LFENCE be serializing even when it's not _required_ to be is a-ok from a functional perspective.[...]
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: SVM: Allow guest writes to set MSR_AMD64_DE_CFG bits
https://github.com/kvm-x86/linux/commit/2778c9a4687d
Paolo Bonzini
maintainerQuoted 14 lines · Sean Christopherson
Quoted 13 lines · Sean Christopherson
Drop KVM's arbitrary behavior of making DE_CFG.LFENCE_SERIALIZE read-only for the guest, as rejecting writes can lead to guest crashes, e.g. Windows in particular doesn't gracefully handle unexpected #GPs on the WRMSR, and nothing in the AMD manuals suggests that
LFENCE_SERIALIZEis read-only_ifitexists_.KVM only allows
LFENCE_SERIALIZEto be set, by the guest or host, if the underlying CPU hasX86_FEATURE_LFENCE_RDTSC, i.e. if LFENCE is guaranteed to be serializing. So if the guest setsLFENCE_SERIALIZE, KVM will provide the desired/correct behavior without any additional action (the guest's value is never stuffed into hardware). And having LFENCE be serializing even when it's not _required_ to be is a-ok from a functional perspective.
Quoted 6 lines
Quoted 1 line
[...]
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: SVM: Allow guest writes to set
MSR_AMD64_DE_CFGbitshttps://github.com/kvm-x86/linux/commit/2778c9a4687d
Oh, I missed this! I assume you're going to send me a pull request today or tomorrow?
Paolo
Sean Christopherson
maintainerQuoted 17 lines · Paolo Bonzini
Quoted 16 lines · Sean Christopherson
Quoted 14 lines · Sean Christopherson
Drop KVM's arbitrary behavior of making DE_CFG.LFENCE_SERIALIZE read-only for the guest, as rejecting writes can lead to guest crashes, e.g. Windows in particular doesn't gracefully handle unexpected #GPs on the WRMSR, and nothing in the AMD manuals suggests that
LFENCE_SERIALIZEis read-only_ifitexists_.KVM only allows
LFENCE_SERIALIZEto be set, by the guest or host, if the underlying CPU hasX86_FEATURE_LFENCE_RDTSC, i.e. if LFENCE is guaranteed to be serializing. So if the guest setsLFENCE_SERIALIZE, KVM will provide the desired/correct behavior without any additional action (the guest's value is never stuffed into hardware). And having LFENCE be serializing even when it's not _required_ to be is a-ok from a functional perspective.[...]
Quoted 7 lines
Quoted 4 lines
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: SVM: Allow guest writes to set
MSR_AMD64_DE_CFGbitshttps://github.com/kvm-x86/linux/commit/2778c9a4687dOh, I missed this! I assume you're going to send me a pull request today or tomorrow?
Yep, I'll get it to you today.