On 2011-05-23 23:46, john cooper wrote:
> Add kvm emulated x2apic flag to config defined cpu models
> and general support for such hypervisor emulated flags.
> 
> In addition to checking user request flags against the host
> we also selectively check against kvm for emulated flags.

As you are already digging through this jungle, could you also check how
much of this diff from qemu-kvm is obsolete now?

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index e479a4d..091d812 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -1175,6 +1175,31 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t
index, uint32_t count,
                 *ecx |= 1 << 1;    /* CmpLegacy bit */
             }
         }
+        if (kvm_enabled()) {
+            uint32_t h_eax, h_edx;
+
+            host_cpuid(index, 0, &h_eax, NULL, NULL, &h_edx);
+
+            /* disable CPU features that the host does not support */
+
+            /* long mode */
+            if ((h_edx & 0x20000000) == 0 /* || !lm_capable_kernel */)
+                *edx &= ~0x20000000;
+            /* syscall */
+            if ((h_edx & 0x00000800) == 0)
+                *edx &= ~0x00000800;
+            /* nx */
+            if ((h_edx & 0x00100000) == 0)
+                *edx &= ~0x00100000;
+
+            /* disable CPU features that KVM cannot support */
+
+            /* svm */
+            if (!kvm_nested)
+                *ecx &= ~CPUID_EXT3_SVM;
+            /* 3dnow */
+            *edx &= ~0xc0000000;
+        }
         break;
     case 0x80000002:
     case 0x80000003:

If something is still missing in upstream, it should be ported - except
for kvm_nested which should be controllable via '-cpu ...,+/-svm'. TIA!

Jörg, how to deal with -enable-nesting in qemu-kvm to align behavior
with upstream?

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to