Skip to content

Commit 6f913de

Browse files
kirylKAGA-KOKO
authored andcommitted
x86/boot/compressed/64: Do not read legacy ROM on EFI system
EFI systems do not necessarily provide a legacy ROM. If the ROM is missing the memory is not mapped at all. Trying to dereference values in the legacy ROM area leads to a crash on Macbook Pro. Only look for values in the legacy ROM area for non-EFI system. Fixes: 3548e13 ("x86/boot/compressed/64: Find a place for 32-bit trampoline") Reported-by: Pitam Mitra <pitamm@gmail.com> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Bockjoo Kim <bockjoo@phys.ufl.edu> Cc: bp@alien8.de Cc: hpa@zytor.com Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20190219075224.35058-1-kirill.shutemov@linux.intel.com Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202351
1 parent f9d230e commit 6f913de

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

arch/x86/boot/compressed/pgtable_64.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#include <linux/efi.h>
12
#include <asm/e820/types.h>
23
#include <asm/processor.h>
4+
#include <asm/efi.h>
35
#include "pgtable.h"
46
#include "../string.h"
57

@@ -37,18 +39,29 @@ int cmdline_find_option_bool(const char *option);
3739

3840
static unsigned long find_trampoline_placement(void)
3941
{
40-
unsigned long bios_start, ebda_start;
42+
unsigned long bios_start = 0, ebda_start = 0;
4143
unsigned long trampoline_start;
4244
struct boot_e820_entry *entry;
45+
char *signature;
4346
int i;
4447

4548
/*
4649
* Find a suitable spot for the trampoline.
4750
* This code is based on reserve_bios_regions().
4851
*/
4952

50-
ebda_start = *(unsigned short *)0x40e << 4;
51-
bios_start = *(unsigned short *)0x413 << 10;
53+
/*
54+
* EFI systems may not provide legacy ROM. The memory may not be mapped
55+
* at all.
56+
*
57+
* Only look for values in the legacy ROM for non-EFI system.
58+
*/
59+
signature = (char *)&boot_params->efi_info.efi_loader_signature;
60+
if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) &&
61+
strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) {
62+
ebda_start = *(unsigned short *)0x40e << 4;
63+
bios_start = *(unsigned short *)0x413 << 10;
64+
}
5265

5366
if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
5467
bios_start = BIOS_START_MAX;

0 commit comments

Comments
 (0)