[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/19] hvf: Fetch cr4 before evaluating CPUID(1)
From: |
Paolo Bonzini |
Subject: |
[PULL 19/19] hvf: Fetch cr4 before evaluating CPUID(1) |
Date: |
Mon, 15 Feb 2021 14:16:26 +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>
[RB: resolved conflict with another CPUID change]
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
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 10a06c3c79..15f14ac69e 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -828,6 +828,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);
+ }
hvf_cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx);
wreg(cpu->hvf_fd, HV_X86_RAX, rax);
--
2.29.2
- [PULL 09/19] libqos/qgraph: add qos_node_create_driver_named(), (continued)
- [PULL 09/19] libqos/qgraph: add qos_node_create_driver_named(), Paolo Bonzini, 2021/02/15
- [PULL 11/19] tests/qtest/qos-test: dump qos graph if verbose, Paolo Bonzini, 2021/02/15
- [PULL 13/19] tests/qtest/qos-test: dump QEMU command if verbose, Paolo Bonzini, 2021/02/15
- [PULL 12/19] tests/qtest/qos-test: dump environment variables if verbose, Paolo Bonzini, 2021/02/15
- [PULL 14/19] util/cutils: Skip "." when looking for next directory component, Paolo Bonzini, 2021/02/15
- [PULL 17/19] hvf: x86: Remove unused definitions, Paolo Bonzini, 2021/02/15
- [PULL 15/19] hvf: Guard xgetbv call, Paolo Bonzini, 2021/02/15
- [PULL 16/19] target/i386/hvf: add vmware-cpuid-freq cpu feature, Paolo Bonzini, 2021/02/15
- [PULL 18/19] target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT, Paolo Bonzini, 2021/02/15
- [PULL 19/19] hvf: Fetch cr4 before evaluating CPUID(1),
Paolo Bonzini <=
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, Thomas Huth, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, Philippe Mathieu-Daudé, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, no-reply, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, Eric Blake, 2021/02/15