FAILED: patch "[PATCH] KVM: x86: cleanup CR3 reserved bits checks" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c1c35cf78bfab31b8cb455259524395c9e4c7cd6 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Fri, 13 Nov 2020 08:30:38 -0500
Subject: [PATCH] KVM: x86: cleanup CR3 reserved bits checks
If not in long mode, the low bits of CR3 are reserved but not enforced to be zero, so remove those checks. If in long mode, however, the MBZ bits extend down to the highest physical address bit of the guest, excluding the encryption bit.
Make the checks consistent with the above, and match them between nested_vmcb_checks and KVM_SET_SREGS.
arch/x86/kvm/svm/nested.c +3 -10
@@ -231,6 +231,7 @@ static bool nested_vmcb_check_controls(struct vmcb_control_area *control)static bool nested_vmcb_checks (struct vcpu_svm *svm,struct vmcb *vmcb12) { +struct kvm_vcpu *vcpu = &svm->vcpu;bool vmcb12_lma;if ((vmcb12->save.efer &EFER_SVME ) ==0 )
@@ -244,18 +245,10 @@ static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12) vmcb12_lma = (vmcb12->save.efer &EFER_LME ) && (vmcb12->save.cr0 &X86_CR0_PG ); -if (!vmcb12_lma) { -if (vmcb12->save.cr4 &X86_CR4_PAE ) { -if (vmcb12->save.cr3 &MSR_CR3_LEGACY_PAE_RESERVED_MASK ) -return false; - }else { -if (vmcb12->save.cr3 &MSR_CR3_LEGACY_RESERVED_MASK ) -return false; - } - }else { +if (vmcb12_lma) {if (!(vmcb12->save.cr4 &X86_CR4_PAE ) || !(vmcb12->save.cr0 &X86_CR0_PE ) || - (vmcb12->save.cr3 &MSR_CR3_LONG_MBZ_MASK )) + (vmcb12->save.cr3 & vcpu->arch.cr3_lm_rsvd_bits))return false; }if (!kvm_is_valid_cr4 (&svm->vcpu, vmcb12->save.cr4))
arch/x86/kvm/svm/svm.h +0 -3
@@ -403,9 +403,6 @@ static inline bool gif_set(struct vcpu_svm *svm) }/* svm.c */ -#define MSR_CR3_LEGACY_RESERVED_MASK 0xfe7U -#define MSR_CR3_LEGACY_PAE_RESERVED_MASK 0x7U -#define MSR_CR3_LONG_MBZ_MASK 0xfff0000000000000U#define MSR_INVALID 0xffffffffUextern int sev;
arch/x86/kvm/x86.c +2 -0
@@ -9624,6 +9624,8 @@ static bool kvm_is_valid_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)*/ if (!(sregs->cr4 &X86_CR4_PAE ) || !(sregs->efer &EFER_LMA ))return false; +if (sregs->cr3 & vcpu->arch.cr3_lm_rsvd_bits) +return false; }else {/* * Not in 64-bit mode: EFER.LMA is clear and the code