Skip to contentSkip to conversation

support CPUID hypervisor feature bit

PATCH New Jan Beulich 1 participant 1 message Nov 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support CPUID hypervisor feature bit

See http://lkml.org/lkml/2008/10/1/246 for more context.

xen/arch/x86/domain.c +5 -2
Index: 2008-10-27/xen/arch/x86/domain.c
===================================================================
@@ -1888,6 +1888,8 @@ void domain_cpuid(
     cpuid_input_t *cpuid;
     int i;
 
+    *eax = *ebx = *ecx = *edx = 0;
+
     for ( i = 0; i < MAX_CPUID_INPUT; i++ )
     {
         cpuid = &d->arch.cpuids[i];
@@ -1900,11 +1902,12 @@ void domain_cpuid(
             *ebx = cpuid->ebx;
             *ecx = cpuid->ecx;
             *edx = cpuid->edx;
-            return;
+            break;
         }
     }
 
-    *eax = *ebx = *ecx = *edx = 0;
+    if ( input == 1 )
+        *ecx |= 1U << (X86_FEATURE_HYPERVISOR % 32);
 }
 
 void vcpu_kick(struct vcpu *v)
xen/arch/x86/traps.c +1 -0
Index: 2008-10-27/xen/arch/x86/traps.c
===================================================================
@@ -754,6 +754,7 @@ static void pv_cpuid(struct cpu_user_reg
         __clear_bit(X86_FEATURE_XTPR % 32, &c);
         __clear_bit(X86_FEATURE_PDCM % 32, &c);
         __clear_bit(X86_FEATURE_DCA % 32, &c);
+        __set_bit(X86_FEATURE_HYPERVISOR % 32, &c);
         break;
     case 0x80000001:
         /* Modify Feature Information. */
xen/include/asm-x86/cpufeature.h +1 -0
Index: 2008-10-27/xen/include/asm-x86/cpufeature.h
===================================================================
@@ -94,6 +94,7 @@
 #define X86_FEATURE_SSE4_2	(4*32+20) /* Streaming SIMD Extensions 4.2 */
 #define X86_FEATURE_X2APIC	(4*32+21) /* Extended xAPIC */
 #define X86_FEATURE_POPCNT	(4*32+23) /* POPCNT instruction */
+#define X86_FEATURE_HYPERVISOR	(4*32+31) /* running under some hypervisor */
 
 /* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
 #define X86_FEATURE_XSTORE	(5*32+ 2) /* on-CPU RNG present (xstore insn) */