Checks for hardware virtualization support
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 12 Aug 2009 01:52:14 +0000 (18:52 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 12 Aug 2009 19:53:24 +0000 (12:53 -0700)
x86_64 specific, or at least (intel) processors that support the
IA32_FEATURE_CONTROL MSR.

kern/arch/i386/cpuinfo.c
kern/arch/i386/x86.h

index 61f1f82..1aeec3f 100644 (file)
@@ -69,6 +69,16 @@ void print_cpuinfo(void)
                cprintf("x2APIC Detected\n");
        else
                cprintf("x2APIC Not Detected\n");
+       if (ecx & 0x00000060) {
+               msr_val = read_msr(IA32_FEATURE_CONTROL);
+               printd("64 Bit Feature Control: 0x%08x\n", msr_val);
+               if (msr_val & 0x5 == 0x5)
+                       printk("Hardware virtualization supported\n");
+               else
+                       printk("Hardware virtualization not supported\n");
+       } else { 
+               printk("Hardware virtualization not supported\n");
+       }
        cpuid(0x80000008, &eax, &ebx, &ecx, &edx);
        cprintf("Physical Address Bits: %d\n", eax & 0x000000FF);
        cprintf("Cores per Die: %d\n", (ecx & 0x000000FF) + 1);
index c44d770..ac192b2 100644 (file)
@@ -6,6 +6,7 @@
 
 /* Model Specific Registers */
 #define IA32_APIC_BASE                         0x1b
+#define IA32_FEATURE_CONTROL           0x3a
 #define IA32_MTRR_DEF_TYPE                     0x2ff
 #define IA32_MTRR_PHYSBASE0                    0x200
 #define IA32_MTRR_PHYSMASK0                    0x201