Skip to contentSkip to conversation

Work around misreported kvm cpuid features

PATCH Superseded Avi Kivity 2 participants 3 messages May 10, 2009 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 Work around misreported kvm cpuid features

kvm misreports MCA, MCE, MTRR, and PAT as unsupported. This causes Vista to fail. Since QEMU does not support any version of kvm that does not actually support these features, it is safe to enable them unconditionally.

These features are needed by Vista x64 to boot.

---
 target-i386/kvm.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
target-i386/kvm.c +7 -0
index fe67eed..a7b7ae3 100644
@@ -88,6 +88,13 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg)
                 break;
             case R_EDX:
                 ret = cpuid->entries[i].edx;
+                if (function == 1) {
+                    /* kvm misreports the following features: */
+                    ret |= 1 << 12; /* MTRR */
+                    ret |= 1 << 16; /* PAT */
+                    ret |= 1 << 7;  /* MCE */
+                    ret |= 1 << 14; /* MCA */
+                }
                 if (function == 0x80000001) {
                     /* On Intel, kvm returns cpuid according to the Intel spec,
                      * so add missing bits according to the AMD spec:
Signature · 1 line
1.6.1.1
#1 lore raw

target-i386/kvm.c uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) · line 96

Quoted 6 lines · Avi Kivity

These features are needed by Vista x64 to boot.

target-i386/kvm.c +4 -0
+                    ret |= 1 << 12; /* MTRR */
+                    ret |= 1 << 16; /* PAT */
+                    ret |= 1 << 7;  /* MCE */
+                    ret |= 1 << 14; /* MCA */

Just curious -- is there a reason to avoid the use of CPUID_MTRR, CPUID_PAT, CPUID_MCE and CPUID_MCA here?

Cheers,

Signature · 1 line
Stuart Brady
author
#2 lore raw
Quoted 6 lines · Stuart Brady
Quoted 2 lines · Avi Kivity

These features are needed by Vista x64 to boot.

Quoted 9 lines

target-i386/kvm.c uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) · line 96

Quoted 5 lines
target-i386/kvm.c +4 -0
+                    ret |= 1 << 12; /* MTRR */
+                    ret |= 1 << 16; /* PAT */
+                    ret |= 1 << 7;  /* MCE */
+                    ret |= 1 << 14; /* MCA */

Just curious -- is there a reason to avoid the use of CPUID_MTRR, CPUID_PAT, CPUID_MCE and CPUID_MCA here?

Didn't notice those. Will send an updated patch.

Signature · 1 line
error compiling committee.c: too many arguments to function