]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.1/x86-boot-compressed-64-do-not-read-legacy-rom-on-efi-system.patch
Linux 5.0.1
[thirdparty/kernel/stable-queue.git] / releases / 5.0.1 / x86-boot-compressed-64-do-not-read-legacy-rom-on-efi-system.patch
CommitLineData
8f593f65
GKH
1From 6f913de3231e1d70a871135b38219da7810df218 Mon Sep 17 00:00:00 2001
2From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
3Date: Tue, 19 Feb 2019 10:52:24 +0300
4Subject: x86/boot/compressed/64: Do not read legacy ROM on EFI system
5
6From: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
7
8commit 6f913de3231e1d70a871135b38219da7810df218 upstream.
9
10EFI systems do not necessarily provide a legacy ROM. If the ROM is missing
11the memory is not mapped at all.
12
13Trying to dereference values in the legacy ROM area leads to a crash on
14Macbook Pro.
15
16Only look for values in the legacy ROM area for non-EFI system.
17
18Fixes: 3548e131ec6a ("x86/boot/compressed/64: Find a place for 32-bit trampoline")
19Reported-by: Pitam Mitra <pitamm@gmail.com>
20Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
21Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
22Tested-by: Bockjoo Kim <bockjoo@phys.ufl.edu>
23Cc: bp@alien8.de
24Cc: hpa@zytor.com
25Cc: stable@vger.kernel.org
26Link: https://lkml.kernel.org/r/20190219075224.35058-1-kirill.shutemov@linux.intel.com
27Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202351
28Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30---
31 arch/x86/boot/compressed/pgtable_64.c | 19 ++++++++++++++++---
32 1 file changed, 16 insertions(+), 3 deletions(-)
33
34--- a/arch/x86/boot/compressed/pgtable_64.c
35+++ b/arch/x86/boot/compressed/pgtable_64.c
36@@ -1,5 +1,7 @@
37+#include <linux/efi.h>
38 #include <asm/e820/types.h>
39 #include <asm/processor.h>
40+#include <asm/efi.h>
41 #include "pgtable.h"
42 #include "../string.h"
43
44@@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char
45
46 static unsigned long find_trampoline_placement(void)
47 {
48- unsigned long bios_start, ebda_start;
49+ unsigned long bios_start = 0, ebda_start = 0;
50 unsigned long trampoline_start;
51 struct boot_e820_entry *entry;
52+ char *signature;
53 int i;
54
55 /*
56@@ -47,8 +50,18 @@ static unsigned long find_trampoline_pla
57 * This code is based on reserve_bios_regions().
58 */
59
60- ebda_start = *(unsigned short *)0x40e << 4;
61- bios_start = *(unsigned short *)0x413 << 10;
62+ /*
63+ * EFI systems may not provide legacy ROM. The memory may not be mapped
64+ * at all.
65+ *
66+ * Only look for values in the legacy ROM for non-EFI system.
67+ */
68+ signature = (char *)&boot_params->efi_info.efi_loader_signature;
69+ if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) &&
70+ strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) {
71+ ebda_start = *(unsigned short *)0x40e << 4;
72+ bios_start = *(unsigned short *)0x413 << 10;
73+ }
74
75 if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
76 bios_start = BIOS_START_MAX;