From 234c4dde2fd4f1182fe1a6bea6bced83fe363007 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 23 May 2013 13:08:32 +0200 Subject: [PATCH 1/2] x86: fix boot time APIC mode detection current_cpu_data becomes valid only relatively late in the boot process, so looking there for a particular feature early in the game would generally give the appearance of the feature being unavailable. Getting this wrong means that at kexec time the system would get returned to xAPIC mode, causing disconnect_bsp_APIC() to try to access the APIC page, which on systems with x2APIC pre-enabled will never get set up. Signed-off-by: Jan Beulich Acked-by: Keir Fraser Reviewed-by: Andrew Cooper --- xen/arch/x86/apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index b28f5ed431..a52a0e881d 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -1474,7 +1474,7 @@ enum apic_mode current_local_apic_mode(void) /* Reading EXTD bit from the MSR is only valid if CPUID * says so, else reserved */ - if ( cpu_has(¤t_cpu_data, X86_FEATURE_X2APIC) + if ( boot_cpu_has(X86_FEATURE_X2APIC) && (msr_contents & MSR_IA32_APICBASE_EXTD) ) return APIC_MODE_X2APIC; From 47f71a8ccb0c881cf3d9e0b917ef5f0dc084b062 Mon Sep 17 00:00:00 2001 From: Eric Shelton Date: Thu, 23 May 2013 13:08:51 +0200 Subject: [PATCH 2/2] x86/EFI: fix boot for pre-UEFI systems efi/boot.c makes a call to QueryVariableInfo on all systems. However, as it is only promised for UEFI 2.0+ systems, pre-UEFI systems can hang or crash on this call. The below patch adds a version check, a technique used in other parts of the Xen EFI codebase. Signed-off-by: Eric Shelton Check runtime services version instead of EFI version (while generally they would be in sync, nothing requires them to be). Signed-off-by: Jan Beulich --- xen/arch/x86/efi/boot.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 117a5cbe43..9718bd7df9 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -1241,12 +1241,14 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) setup_efi_pci(); /* Get snapshot of variable store parameters. */ - status = efi_rs->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE | + status = (efi_rs->Hdr.Revision >> 16) >= 2 ? + efi_rs->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, &efi_boot_max_var_store_size, &efi_boot_remain_var_store_size, - &efi_boot_max_var_size); + &efi_boot_max_var_size) : + EFI_INCOMPATIBLE_VERSION; if ( EFI_ERROR(status) ) { efi_boot_max_var_store_size = 0;