]> Git Repo - qemu.git/commitdiff
i386: hvf: Move Guest LMA reset to macvm_set_cr0()
authorRoman Bolshakov <[email protected]>
Tue, 30 Jun 2020 10:28:21 +0000 (13:28 +0300)
committerPaolo Bonzini <[email protected]>
Fri, 10 Jul 2020 22:02:19 +0000 (18:02 -0400)
The only useful purpose of hvf_reset_vcpu() is to clear "IA-32e mode
guest" (LMA) VM-Entry control. But it can be moved to macvm_set_cr0()
which is indirectly used by post-init and post-reset to flush emulator
state. That enables clean removal of hvf_reset_vcpu().

LMA is set only if IA32_EFER.LME = 1, according to Intel SDM "9.8.5
Initializing IA-32e Mode" and "9.8.5.4 Switching Out of IA-32e Mode
Operation", otherwise the entry control can be safely cleared.

Cc: Cameron Esfahani <[email protected]>
Signed-off-by: Roman Bolshakov <[email protected]>
Message-Id: <20200630102824[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
target/i386/hvf/hvf.c
target/i386/hvf/vmx.h

index efe9802962e92d6bc1906970fa5a9dbde4fd5e7d..31980f907618ed7cc1cbe1b50f808670061d0b12 100644 (file)
@@ -459,7 +459,6 @@ void hvf_reset_vcpu(CPUState *cpu) {
     /* TODO: this shouldn't be needed; there is already a call to
      * cpu_synchronize_all_post_reset in vl.c
      */
-    wvmcs(cpu->hvf_fd, VMCS_ENTRY_CTLS, 0);
     wvmcs(cpu->hvf_fd, VMCS_GUEST_IA32_EFER, 0);
 
     /* Initialize PDPTE */
index 437238f11d5611d728392c1b042bda5b7d89815b..75ba1e2a5f4d33a4b84197d9437baedc73682bfd 100644 (file)
@@ -123,6 +123,7 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
     uint64_t old_cr0 = rvmcs(vcpu, VMCS_GUEST_CR0);
     uint64_t changed_cr0 = old_cr0 ^ cr0;
     uint64_t mask = CR0_PG | CR0_CD | CR0_NW | CR0_NE | CR0_ET;
+    uint64_t entry_ctls;
 
     if ((cr0 & CR0_PG) && (rvmcs(vcpu, VMCS_GUEST_CR4) & CR4_PAE) &&
         !(efer & MSR_EFER_LME)) {
@@ -146,6 +147,9 @@ static inline void macvm_set_cr0(hv_vcpuid_t vcpu, uint64_t cr0)
                 exit_long_mode(vcpu, cr0, efer);
             }
         }
+    } else {
+        entry_ctls = rvmcs(vcpu, VMCS_ENTRY_CTLS);
+        wvmcs(vcpu, VMCS_ENTRY_CTLS, entry_ctls & ~VM_ENTRY_GUEST_LMA);
     }
 
     /* Filter new CR0 after we are finished examining it above. */
This page took 0.029378 seconds and 4 git commands to generate.