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 <[email protected]> --- CC: Jan Beulich <[email protected]> CC: Wei Liu <[email protected]> CC: Roger Pau Monné <[email protected]> CC: Sergey Dyasli <[email protected]> CC: Juergen Gross <[email protected]> --- xen/arch/x86/apic.c | 2 +- xen/arch/x86/boot/head.S | 4 ++++ xen/arch/x86/efi/efi-boot.h | 6 ++++-- xen/arch/x86/guest/xen.c | 6 +----- xen/arch/x86/mm.c | 3 +-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index a5f7b05d5a..a8ee18636f 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -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); diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 77309e3c82..8d0ffbd1b0 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -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 diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index cde193a771..232972eedf 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -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; diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c index 7b7a5badab..a329e7c886 100644 --- a/xen/arch/x86/guest/xen.c +++ b/xen/arch/x86/guest/xen.c @@ -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(); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 57f22775ac..bd8182f40f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -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; } -- 2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
