]> xenbits.xensource.com Git - xen.git/commitdiff
x86: correct remaining extended CPUID level checks
authorJan Beulich <jbeulich@suse.com>
Wed, 11 May 2016 07:47:21 +0000 (09:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 11 May 2016 07:47:21 +0000 (09:47 +0200)
We should consistently check the upper 16 bits to be equal 0x8000 and
only then the full value to be >= the desired level.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/boot/head.S
xen/arch/x86/cpu/common.c
xen/arch/x86/efi/efi-boot.h
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/mtrr.c

index f3501fdf47a439f3a263443ef9d3618025ef12bd..0999997fd2efc28cf363058f8e507dc58ea6729b 100644 (file)
@@ -133,7 +133,10 @@ __start:
         /* Interrogate CPU extended features via CPUID. */
         mov     $0x80000000,%eax
         cpuid
+        shld    $16,%eax,%ecx
         xor     %edx,%edx
+        cmp     $0x8000,%cx         # any function @ 0x8000xxxx?
+        jne     1f
         cmp     $0x80000000,%eax    # any function > 0x80000000?
         jbe     1f
         mov     $0x80000001,%eax
index 4b560619aef99d6dd3cfe9f415809cffa27b2312..760543bc1ddbcb0a724970905c6060278b2b7d64 100644 (file)
@@ -297,9 +297,12 @@ static void generic_identify(struct cpuinfo_x86 *c)
 
        /* AMD-defined flags: level 0x80000001 */
        c->extended_cpuid_level = cpuid_eax(0x80000000);
-       cpuid(0x80000001, &tmp, &tmp,
-             &c->x86_capability[cpufeat_word(X86_FEATURE_LAHF_LM)],
-             &c->x86_capability[cpufeat_word(X86_FEATURE_SYSCALL)]);
+       if ((c->extended_cpuid_level >> 16) != 0x8000)
+               c->extended_cpuid_level = 0;
+       if (c->extended_cpuid_level > 0x80000000)
+               cpuid(0x80000001, &tmp, &tmp,
+                     &c->x86_capability[cpufeat_word(X86_FEATURE_LAHF_LM)],
+                     &c->x86_capability[cpufeat_word(X86_FEATURE_SYSCALL)]);
        if (c == &boot_cpu_data)
                bootsym(cpuid_ext_features) =
                        c->x86_capability[cpufeat_word(X86_FEATURE_NX)];
index 6dbb14def58d4cf874d1c5ece5353df9a96c8500..1fa9e474266ca79fb41fc4b17c7630503659ccca 100644 (file)
@@ -605,7 +605,9 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name,
 
 static void __init efi_arch_cpu(void)
 {
-    if ( cpuid_eax(0x80000000) > 0x80000000 )
+    uint32_t eax = cpuid_eax(0x80000000);
+
+    if ( (eax >> 16) == 0x8000 && eax > 0x80000000 )
     {
         cpuid_ext_features = cpuid_edx(0x80000001);
         boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_SYSCALL)]
index 917db564bbddd8be4750be9bd7794e034cb5510f..7492030a131a4212d9ca8e700621b2c8836867a9 100644 (file)
@@ -884,7 +884,7 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
 
         ASSERT(v->domain == current->domain);
         hvm_cpuid(0x80000000, &level, NULL, NULL, NULL);
-        if ( level >= 0x80000001 )
+        if ( (level >> 16) == 0x8000 && level > 0x80000000 )
         {
             unsigned int dummy;
 
index 7ab7f6325c2882a039652d5793adee32c0f60ac5..f7831ff8e133387232787c3bc5c1969b318e3a84 100644 (file)
@@ -455,7 +455,7 @@ bool_t mtrr_var_range_msr_set(
     {
         phys_addr = 36;
         hvm_cpuid(0x80000000, &eax, NULL, NULL, NULL);
-        if ( eax >= 0x80000008 )
+        if ( (eax >> 16) == 0x8000 && eax >= 0x80000008 )
         {
             hvm_cpuid(0x80000008, &eax, NULL, NULL, NULL);
             phys_addr = (uint8_t)eax;