[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/36] hvf: Fetch cr4 before evaluating CPUID(1)
From: |
Paolo Bonzini |
Subject: |
[PULL 35/36] hvf: Fetch cr4 before evaluating CPUID(1) |
Date: |
Fri, 29 Jan 2021 12:18:13 +0100 |
From: Alexander Graf <agraf@csgraf.de>
The CPUID function 1 has a bit called OSXSAVE which tells user space the
status of the CR4.OSXSAVE bit. Our generic CPUID function injects that bit
based on the status of CR4.
With Hypervisor.framework, we do not synchronize full CPU state often enough
for this function to see the CR4 update before guest user space asks for it.
To be on the save side, let's just always synchronize it when we receive a
CPUID(1) request. That way we can set the bit with real confidence.
Reported-by: Asad Ali <asad@osaro.com>
Signed-off-by: Alexander Graf <agraf@csgraf.de>
Message-Id: <20210123004129.6364-1-agraf@csgraf.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/hvf/hvf.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index ed9356565c..79970f3d58 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -734,6 +734,10 @@ int hvf_vcpu_exec(CPUState *cpu)
uint32_t rcx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX);
uint32_t rdx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX);
+ if (rax == 1) {
+ /* CPUID1.ecx.OSXSAVE needs to know CR4 */
+ env->cr[4] = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR4);
+ }
cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx);
wreg(cpu->hvf_fd, HV_X86_RAX, rax);
--
2.29.2
- [PULL 21/36] meson: Explicit TCG backend used, (continued)
- [PULL 21/36] meson: Explicit TCG backend used, Paolo Bonzini, 2021/01/29
- [PULL 26/36] pc-bios/meson: Only install EDK2 blob firmwares with system emulation, Paolo Bonzini, 2021/01/29
- [PULL 24/36] build-sys: make libslirp a meson subproject, Paolo Bonzini, 2021/01/29
- [PULL 25/36] tests/meson: Only build softfloat objects if TCG is selected, Paolo Bonzini, 2021/01/29
- [PULL 28/36] meson: Merge trace_events_subdirs array, Paolo Bonzini, 2021/01/29
- [PULL 31/36] qapi/meson: Restrict qdev code to system-mode emulation, Paolo Bonzini, 2021/01/29
- [PULL 23/36] slirp: update to git master, Paolo Bonzini, 2021/01/29
- [PULL 27/36] meson: Restrict block subsystem processing, Paolo Bonzini, 2021/01/29
- [PULL 32/36] qapi/meson: Remove QMP from user-mode emulation, Paolo Bonzini, 2021/01/29
- [PULL 30/36] meson: Restrict emulation code, Paolo Bonzini, 2021/01/29
- [PULL 35/36] hvf: Fetch cr4 before evaluating CPUID(1),
Paolo Bonzini <=
- [PULL 36/36] accel/kvm/kvm-all: Fix wrong return code handling in dirty log code, Paolo Bonzini, 2021/01/29
- [PULL 29/36] meson: Restrict some trace event directories to user/system emulation, Paolo Bonzini, 2021/01/29
- [PULL 33/36] qapi/meson: Restrict system-mode specific modules, Paolo Bonzini, 2021/01/29
- [PULL 34/36] qapi/meson: Restrict UI module to system emulation and tools, Paolo Bonzini, 2021/01/29
- Re: [PULL 00/36] Misc patches (buildsys, i386, fuzzing) for 2021-01-29, Peter Maydell, 2021/01/29