Commit be100ef1 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: VMX: Clean cr3/pgd handling in vmx_load_mmu_pgd()

Rename @cr3 to @pgd in vmx_load_mmu_pgd() to reflect that it will be
loaded into vmcs.EPT_POINTER and not vmcs.GUEST_CR3 when EPT is enabled.
Similarly, load guest_cr3 with @pgd if and only if EPT is disabled.

This fixes one of the last, if not _the_ last, cases in KVM where a
variable that is not strictly a cr3 value uses "cr3" instead of "pgd".
Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200320212833.3507-38-sean.j.christopherson@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent be01e8e2
...@@ -3034,16 +3034,15 @@ u64 construct_eptp(struct kvm_vcpu *vcpu, unsigned long root_hpa) ...@@ -3034,16 +3034,15 @@ u64 construct_eptp(struct kvm_vcpu *vcpu, unsigned long root_hpa)
return eptp; return eptp;
} }
void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long cr3) void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long pgd)
{ {
struct kvm *kvm = vcpu->kvm; struct kvm *kvm = vcpu->kvm;
bool update_guest_cr3 = true; bool update_guest_cr3 = true;
unsigned long guest_cr3; unsigned long guest_cr3;
u64 eptp; u64 eptp;
guest_cr3 = cr3;
if (enable_ept) { if (enable_ept) {
eptp = construct_eptp(vcpu, cr3); eptp = construct_eptp(vcpu, pgd);
vmcs_write64(EPT_POINTER, eptp); vmcs_write64(EPT_POINTER, eptp);
if (kvm_x86_ops.tlb_remote_flush) { if (kvm_x86_ops.tlb_remote_flush) {
...@@ -3064,6 +3063,8 @@ void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long cr3) ...@@ -3064,6 +3063,8 @@ void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long cr3)
else /* vmcs01.GUEST_CR3 is already up-to-date. */ else /* vmcs01.GUEST_CR3 is already up-to-date. */
update_guest_cr3 = false; update_guest_cr3 = false;
ept_load_pdptrs(vcpu); ept_load_pdptrs(vcpu);
} else {
guest_cr3 = pgd;
} }
if (update_guest_cr3) if (update_guest_cr3)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment