aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-07-21 17:16:52 -0400
committerIngo Molnar <mingo@kernel.org>2016-07-22 05:46:01 -0400
commit6a79296cb15d947bcb4558011fe066e5d8252b35 (patch)
treecd8da659f7b35829b38bd597f5be3cc78a9ad06a
parent30f027398b329c75c8f23a3c13be240b50866fdc (diff)
x86/boot: Simplify EBDA-vs-BIOS reservation logic
Both the intent and the effect of reserve_bios_regions() is simple: reserve the range from the apparent BIOS start (suitably filtered) through 1MB and, if the EBDA start address is sensible, extend that reservation downward to cover the EBDA as well. The code is overcomplicated, though, and contains head-scratchers like: if (ebda_start < BIOS_START_MIN) ebda_start = BIOS_START_MAX; That snipped is trying to say "if ebda_start < BIOS_START_MIN, ignore it". Simplify it: reorder the code so that it makes sense. This should have no functional effect under any circumstances. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Luis R. Rodriguez <mcgrof@suse.com> Cc: Mario Limonciello <mario_limonciello@dell.com> Cc: Matthew Garrett <mjg59@srcf.ucam.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Toshi Kani <toshi.kani@hp.com> Link: http://lkml.kernel.org/r/ef89c0c761be20ead8bd9a3275743e6259b6092a.1469135598.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/ebda.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/arch/x86/kernel/ebda.c b/arch/x86/kernel/ebda.c
index 6219eef20e2e..4312f8ae71b7 100644
--- a/arch/x86/kernel/ebda.c
+++ b/arch/x86/kernel/ebda.c
@@ -65,22 +65,6 @@ void __init reserve_bios_regions(void)
65 if (!x86_platform.legacy.reserve_bios_regions) 65 if (!x86_platform.legacy.reserve_bios_regions)
66 return; 66 return;
67 67
68 /* Get the start address of the EBDA page: */
69 ebda_start = get_bios_ebda();
70
71 /*
72 * Quirk: some old Dells seem to have a 4k EBDA without
73 * reporting so in their BIOS RAM size value, so just
74 * consider the memory above 640K to be off limits
75 * (bugzilla 2990).
76 *
77 * We detect this case by filtering for nonsensical EBDA
78 * addresses below 128K, where we can assume that they
79 * are bogus and bump it up to a fixed 640K value:
80 */
81 if (ebda_start < BIOS_START_MIN)
82 ebda_start = BIOS_START_MAX;
83
84 /* 68 /*
85 * BIOS RAM size is encoded in kilobytes, convert it 69 * BIOS RAM size is encoded in kilobytes, convert it
86 * to bytes to get a first guess at where the BIOS 70 * to bytes to get a first guess at where the BIOS
@@ -91,18 +75,22 @@ void __init reserve_bios_regions(void)
91 75
92 /* 76 /*
93 * If bios_start is less than 128K, assume it is bogus 77 * If bios_start is less than 128K, assume it is bogus
94 * and bump it up to 640K: 78 * and bump it up to 640K. Similarly, if bios_start is above 640K,
79 * don't trust it.
95 */ 80 */
96 if (bios_start < BIOS_START_MIN) 81 if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
97 bios_start = BIOS_START_MAX; 82 bios_start = BIOS_START_MAX;
98 83
84 /* Get the start address of the EBDA page: */
85 ebda_start = get_bios_ebda();
86
99 /* 87 /*
100 * Use the lower of the bios_start and ebda_start 88 * If the EBDA start address is sane and is below the BIOS region,
101 * as the starting point, but don't allow it to 89 * then also reserve everything from the EBDA start address up to
102 * go beyond 640K: 90 * the BIOS region.
103 */ 91 */
104 bios_start = min(bios_start, ebda_start); 92 if (ebda_start >= BIOS_START_MIN && ebda_start < bios_start)
105 bios_start = min(bios_start, BIOS_START_MAX); 93 bios_start = ebda_start;
106 94
107 /* Reserve all memory between bios_start and the 1MB mark: */ 95 /* Reserve all memory between bios_start and the 1MB mark: */
108 memblock_reserve(bios_start, 0x100000 - bios_start); 96 memblock_reserve(bios_start, 0x100000 - bios_start);