From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: toshi.kani@hp.com, linux-kernel@vger.kernel.org,
mario_limonciello@dell.com, bp@alien8.de, jpoimboe@redhat.com,
dvlasenk@redhat.com, akpm@linux-foundation.org, mcgrof@suse.com,
brgerst@gmail.com, torvalds@linux-foundation.org,
mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de,
mjg59@srcf.ucam.org, luto@kernel.org, peterz@infradead.org,
keescook@chromium.org
Subject: [tip:x86/boot] x86/boot: Simplify EBDA-vs-BIOS reservation logic
Date: Fri, 22 Jul 2016 03:26:04 -0700 [thread overview]
Message-ID: <tip-6a79296cb15d947bcb4558011fe066e5d8252b35@git.kernel.org> (raw)
In-Reply-To: <ef89c0c761be20ead8bd9a3275743e6259b6092a.1469135598.git.luto@kernel.org>
Commit-ID: 6a79296cb15d947bcb4558011fe066e5d8252b35
Gitweb: http://git.kernel.org/tip/6a79296cb15d947bcb4558011fe066e5d8252b35
Author: Andy Lutomirski <luto@kernel.org>
AuthorDate: Thu, 21 Jul 2016 14:16:52 -0700
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 22 Jul 2016 11:46:01 +0200
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>
---
arch/x86/kernel/ebda.c | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/arch/x86/kernel/ebda.c b/arch/x86/kernel/ebda.c
index 6219eef..4312f8a 100644
--- a/arch/x86/kernel/ebda.c
+++ b/arch/x86/kernel/ebda.c
@@ -65,22 +65,6 @@ void __init reserve_bios_regions(void)
if (!x86_platform.legacy.reserve_bios_regions)
return;
- /* Get the start address of the EBDA page: */
- ebda_start = get_bios_ebda();
-
- /*
- * Quirk: some old Dells seem to have a 4k EBDA without
- * reporting so in their BIOS RAM size value, so just
- * consider the memory above 640K to be off limits
- * (bugzilla 2990).
- *
- * We detect this case by filtering for nonsensical EBDA
- * addresses below 128K, where we can assume that they
- * are bogus and bump it up to a fixed 640K value:
- */
- if (ebda_start < BIOS_START_MIN)
- ebda_start = BIOS_START_MAX;
-
/*
* BIOS RAM size is encoded in kilobytes, convert it
* to bytes to get a first guess at where the BIOS
@@ -91,18 +75,22 @@ void __init reserve_bios_regions(void)
/*
* If bios_start is less than 128K, assume it is bogus
- * and bump it up to 640K:
+ * and bump it up to 640K. Similarly, if bios_start is above 640K,
+ * don't trust it.
*/
- if (bios_start < BIOS_START_MIN)
+ if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
bios_start = BIOS_START_MAX;
+ /* Get the start address of the EBDA page: */
+ ebda_start = get_bios_ebda();
+
/*
- * Use the lower of the bios_start and ebda_start
- * as the starting point, but don't allow it to
- * go beyond 640K:
+ * If the EBDA start address is sane and is below the BIOS region,
+ * then also reserve everything from the EBDA start address up to
+ * the BIOS region.
*/
- bios_start = min(bios_start, ebda_start);
- bios_start = min(bios_start, BIOS_START_MAX);
+ if (ebda_start >= BIOS_START_MIN && ebda_start < bios_start)
+ bios_start = ebda_start;
/* Reserve all memory between bios_start and the 1MB mark: */
memblock_reserve(bios_start, 0x100000 - bios_start);
prev parent reply other threads:[~2016-07-22 10:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 21:16 [PATCH 0/2] x86/boot: Further reserve_boot_regions() cleanups Andy Lutomirski
2016-07-21 21:16 ` [PATCH 1/2] x86/boot: Clarify what x86_legacy_features.reserve_bios_regions does Andy Lutomirski
2016-07-22 10:25 ` [tip:x86/boot] " tip-bot for Andy Lutomirski
2016-07-21 21:16 ` [PATCH 2/2] x86/boot: Simplify EBDA-vs-BIOS reservation logic Andy Lutomirski
2016-07-22 10:26 ` tip-bot for Andy Lutomirski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-6a79296cb15d947bcb4558011fe066e5d8252b35@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mario_limonciello@dell.com \
--cc=mcgrof@suse.com \
--cc=mingo@kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=toshi.kani@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome