From: Rene Herman <rene.herman@gmail.com>
To: akpm@osdl.org
Cc: ak@suse.de, jeremy@goop.org, rusty@rustcorp.com.au,
zach@vmware.com, Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86_64: sync up probe_roms() with i386
Date: Mon, 29 Jan 2007 14:46:29 +0100 [thread overview]
Message-ID: <45BDFAB5.40606@gmail.com> (raw)
In-Reply-To: <200701102244.l0AMiWIA010198@shell0.pdx.osdl.net>
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
Hi Andrew.
This syncs up the x86_64 probe_roms() with the i386 version as just
submitted.
===
Sync up with i386. Specifically, be careful about touching the
legacy ROMs; in virtualized environments they may not be mapped.
Crosscompiled, but not booted due to lack of hardware.
Signed-off-by: Rene Herman <rene.herman@gmail.com>
===
Rene
[-- Attachment #2: x86_64_sync_probe_roms_with_i386.diff --]
[-- Type: text/plain, Size: 1934 bytes --]
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index af425a8..0b3d237 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -183,22 +183,31 @@ static struct resource video_ram_resourc
.flags = IORESOURCE_RAM,
};
-#define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
+#define ROMSIGNATURE 0xaa55
-static int __init romchecksum(unsigned char *rom, unsigned long length)
+static int __init romsignature(const unsigned char *rom)
{
- unsigned char *p, sum = 0;
+ const unsigned short * const ptr = (const unsigned short *)rom;
+ unsigned short sig;
- for (p = rom; p < rom + length; p++)
- sum += *p;
- return sum == 0;
+ return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE;
+}
+
+static int __init romchecksum(const unsigned char *rom, unsigned long length)
+{
+ unsigned char sum, c;
+
+ for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--)
+ sum += c;
+ return !length && !sum;
}
static void __init probe_roms(void)
{
+ const unsigned char *rom;
unsigned long start, length, upper;
- unsigned char *rom;
- int i;
+ unsigned char c;
+ int i;
/* video rom */
upper = adapter_rom_resources[0].start;
@@ -209,8 +218,11 @@ static void __init probe_roms(void)
video_rom_resource.start = start;
+ if (probe_kernel_address(rom, c) != 0)
+ continue;
+
/* 0 < length <= 0x7f * 512, historically */
- length = rom[2] * 512;
+ length = c * 512;
/* if checksum okay, trust length byte */
if (length && romchecksum(rom, length))
@@ -245,8 +257,11 @@ static void __init probe_roms(void)
if (!romsignature(rom))
continue;
+ if (probe_kernel_address(rom, c) != 0)
+ continue;
+
/* 0 < length <= 0x7f * 512, historically */
- length = rom[2] * 512;
+ length = c * 512;
/* but accept any length that fits if checksum okay */
if (!length || start + length > upper || !romchecksum(rom, length))
next prev parent reply other threads:[~2007-01-29 13:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-10 22:44 - romsignature-checksum-cleanup-2.patch removed from -mm tree akpm
2007-01-29 13:46 ` Rene Herman
2007-01-29 13:52 ` Andi Kleen
2007-01-29 13:46 ` [PATCH] i386: probe_roms() cleanup Rene Herman
2007-01-29 13:46 ` Rene Herman [this message]
2007-01-29 16:55 ` [PATCH] x86_64: sync up probe_roms() with i386 Rene Herman
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=45BDFAB5.40606@gmail.com \
--to=rene.herman@gmail.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=zach@vmware.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.