[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/53] i386: hvf: Move Guest LMA reset to macvm_set_cr0()
From: |
Paolo Bonzini |
Subject: |
[PULL 16/53] i386: hvf: Move Guest LMA reset to macvm_set_cr0() |
Date: |
Mon, 6 Jul 2020 12:41:18 -0400 |
From: Roman Bolshakov <r.bolshakov@yadro.com>
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 <dirty@apple.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Message-Id: <20200630102824.77604-7-r.bolshakov@yadro.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/hvf/hvf.c | 1 -
target/i386/hvf/vmx.h | 4 ++++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index efe9802962..31980f9076 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -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 */
diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h
index 437238f11d..75ba1e2a5f 100644
--- a/target/i386/hvf/vmx.h
+++ b/target/i386/hvf/vmx.h
@@ -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. */
--
2.26.2
- [PULL 08/53] target/i386: set SSE FTZ in correct floating-point state, (continued)
- [PULL 08/53] target/i386: set SSE FTZ in correct floating-point state, Paolo Bonzini, 2020/07/06
- [PULL 12/53] i386: hvf: Set env->eip in macvm_set_rip(), Paolo Bonzini, 2020/07/06
- [PULL 14/53] i386: hvf: Add hvf_cpu_synchronize_pre_loadvm(), Paolo Bonzini, 2020/07/06
- [PULL 09/53] target/i386: fix IEEE SSE floating-point exception raising, Paolo Bonzini, 2020/07/06
- [PULL 17/53] i386: hvf: Don't duplicate register reset, Paolo Bonzini, 2020/07/06
- [PULL 18/53] i386: hvf: Clean up synchronize functions, Paolo Bonzini, 2020/07/06
- [PULL 21/53] MAINTAINERS: Add an 'overall' entry for accelerators, Paolo Bonzini, 2020/07/06
- [PULL 22/53] MAINTAINERS: Cover the HAX accelerator stub, Paolo Bonzini, 2020/07/06
- [PULL 23/53] Makefile: Remove dangerous EOL trailing backslash, Paolo Bonzini, 2020/07/06
- [PULL 24/53] Makefile: Write MINIKCONF variables as one entry per line, Paolo Bonzini, 2020/07/06
- [PULL 16/53] i386: hvf: Move Guest LMA reset to macvm_set_cr0(),
Paolo Bonzini <=
- [PULL 25/53] accel/Kconfig: Extract accel selectors into their own config, Paolo Bonzini, 2020/07/06
- [PULL 01/53] tcg/svm: use host cr4 during NPT page table walk, Paolo Bonzini, 2020/07/06
- [PULL 19/53] MAINTAINERS: Add Cameron as HVF co-maintainer, Paolo Bonzini, 2020/07/06
- [PULL 11/53] coverity: provide Coverity-friendly MIN_CONST and MAX_CONST, Paolo Bonzini, 2020/07/06
- [PULL 31/53] KVM: x86: believe what KVM says about WAITPKG, Paolo Bonzini, 2020/07/06
- [PULL 13/53] i386: hvf: Move synchronize functions to sysemu, Paolo Bonzini, 2020/07/06
- [PULL 15/53] i386: hvf: Make long mode enter and exit clearer, Paolo Bonzini, 2020/07/06
- [PULL 30/53] target/i386: implement undocumented "smsw r32" behavior, Paolo Bonzini, 2020/07/06