Skip to content

Commit 334006b

Browse files
calmisisean-jc
authored andcommitted
KVM: VMX: Use kvm_read_cr4() to get cr4 value
Directly use vcpu->arch.cr4 is not recommended since it gets stale value if the cr4 is not available. Use kvm_read_cr4() instead to ensure correct value. Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> Link: https://lore.kernel.org/r/20230410125017.1305238-2-xiaoyao.li@intel.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent b9846a6 commit 334006b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3387,7 +3387,7 @@ static bool vmx_is_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
33873387

33883388
void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
33893389
{
3390-
unsigned long old_cr4 = vcpu->arch.cr4;
3390+
unsigned long old_cr4 = kvm_read_cr4(vcpu);
33913391
struct vcpu_vmx *vmx = to_vmx(vcpu);
33923392
/*
33933393
* Pass through host's Machine Check Enable value to hw_cr4, which

0 commit comments

Comments
 (0)