提交 1094e24a 编写于 作者: S Sean Christopherson 提交者: Zheng Zengkai

KVM: VMX: Drop explicit 'nested' check from vmx_set_cr4()

stable inclusion
from stable-v5.10.137
commit da7f731f2ed5b4a082567967ce74be274aab2daf
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60PLB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=da7f731f2ed5b4a082567967ce74be274aab2daf

--------------------------------

[ Upstream commit a447e38a ]

Drop vmx_set_cr4()'s explicit check on the 'nested' module param now
that common x86 handles the check by incorporating VMXE into the CR4
reserved bits, via kvm_cpu_caps.  X86_FEATURE_VMX is set in kvm_cpu_caps
(by vmx_set_cpu_caps()), if and only if 'nested' is true.

No functional change intended.
Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20201007014417.29276-3-sean.j.christopherson@intel.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 f10bb38e
......@@ -3259,18 +3259,13 @@ int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
}
}
if (cr4 & X86_CR4_VMXE) {
/*
* To use VMXON (and later other VMX instructions), a guest
* must first be able to turn on cr4.VMXE (see handle_vmon()).
* So basically the check on whether to allow nested VMX
* is here. We operate under the default treatment of SMM,
* so VMX cannot be enabled under SMM. Note, guest CPUID is
* intentionally ignored, it's handled by cr4_guest_rsvd_bits.
* We operate under the default treatment of SMM, so VMX cannot be
* enabled under SMM. Note, whether or not VMXE is allowed at all is
* handled by kvm_valid_cr4().
*/
if (!nested || is_smm(vcpu))
if ((cr4 & X86_CR4_VMXE) && is_smm(vcpu))
return 1;
}
if (vmx->nested.vmxon && !nested_cr4_valid(vcpu, cr4))
return 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册