]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/boot: Cache cpu_has_hypervisor very early on boot
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 1 Nov 2019 20:07:31 +0000 (20:07 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 21 Nov 2019 15:49:54 +0000 (15:49 +0000)
We cache Long Mode and No Execute early on boot, so take the opportunity to
cache HYPERVISOR early as well.

Replace opencoded early access to the feature bit.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/apic.c
xen/arch/x86/boot/head.S
xen/arch/x86/efi/efi-boot.h
xen/arch/x86/guest/xen.c
xen/arch/x86/mm.c

index a5f7b05d5a07dc573ccb20b78e1fba44a3928b7c..a8ee18636f4c2eddd8829f971ec29eb2e598a46a 100644 (file)
@@ -1156,7 +1156,7 @@ static void __init check_deadline_errata(void)
     const struct x86_cpu_id *m;
     unsigned int rev;
 
-    if ( boot_cpu_has(X86_FEATURE_HYPERVISOR) )
+    if ( cpu_has_hypervisor )
         return;
 
     m = x86_match_cpu(deadline_match);
index 77309e3c8289ec2d4fffda160af87648e09d4ece..8d0ffbd1b071d04543ec5dfa1569ee8713174cfd 100644 (file)
@@ -630,6 +630,10 @@ trampoline_setup:
 
 1:
         /* Interrogate CPU extended features via CPUID. */
+        mov     $1, %eax
+        cpuid
+        mov     %ecx, sym_fs(boot_cpu_data) + CPUINFO_FEATURE_OFFSET(X86_FEATURE_HYPERVISOR)
+
         mov     $0x80000000,%eax
         cpuid
         shld    $16,%eax,%ecx
index cde193a771b058e9c4470149528cbd8d50b50532..232972eedf8e9e384b9a86d3ba5742b454f4c660 100644 (file)
@@ -637,11 +637,13 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name,
 static void __init efi_arch_cpu(void)
 {
     uint32_t eax = cpuid_eax(0x80000000);
+    uint32_t *caps = boot_cpu_data.x86_capability;
+
+    caps[cpufeat_word(X86_FEATURE_HYPERVISOR)] = cpuid_ecx(1);
 
     if ( (eax >> 16) == 0x8000 && eax > 0x80000000 )
     {
-        boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_SYSCALL)]
-            = cpuid_edx(0x80000001);
+        caps[cpufeat_word(X86_FEATURE_SYSCALL)] = cpuid_edx(0x80000001);
 
         if ( cpu_has_nx )
             trampoline_efer |= EFER_NX;
index 7b7a5badabb29d4de15dbc488a337e78b7fd15d8..a329e7c8865ce9019732fa6e41b08041e10941a9 100644 (file)
@@ -69,11 +69,7 @@ static void __init find_xen_leaves(void)
 
 void __init probe_hypervisor(void)
 {
-    if ( xen_guest )
-        return;
-
-    /* Too early to use cpu_has_hypervisor */
-    if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
+    if ( xen_guest || !cpu_has_hypervisor )
         return;
 
     find_xen_leaves();
index 57f22775acaebe8f17281e4d6f229d2395300035..bd8182f40f71adba2409003847c597e422a85b95 100644 (file)
@@ -6112,8 +6112,7 @@ const struct platform_bad_page *__init get_platform_badpages(unsigned int *array
     case 0x000506e0: /* errata SKL167 / SKW159 */
     case 0x000806e0: /* erratum KBL??? */
     case 0x000906e0: /* errata KBL??? / KBW114 / CFW103 */
-        *array_size = (cpuid_eax(0) >= 7 &&
-                       !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) &&
+        *array_size = (cpuid_eax(0) >= 7 && !cpu_has_hypervisor &&
                        (cpuid_count_ebx(7, 0) & cpufeat_mask(X86_FEATURE_HLE)));
         return &hle_bad_page;
     }