Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0adad171 authored by Rene Herman's avatar Rene Herman Committed by Andi Kleen
Browse files

[PATCH] i386: probe_roms() cleanup



Remove the assumption that if the first page of a legacy ROM is mapped,
it'll all be mapped. This'll also stop people reading this code from
wondering if they're looking at a bug...

Signed-off-by: default avatarRene Herman <rene.herman@gmail.com>
Signed-off-by: default avatarMartin Murray <murrayma@citi.umich.edu>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 0949be35
Loading
Loading
Loading
Loading
+18 −11
Original line number Original line Diff line number Diff line
@@ -161,25 +161,26 @@ static struct resource standard_io_resources[] = { {


static int __init romsignature(const unsigned char *rom)
static int __init romsignature(const unsigned char *rom)
{
{
	const unsigned short * const ptr = (const unsigned short *)rom;
	unsigned short sig;
	unsigned short sig;


	return probe_kernel_address((const unsigned short *)rom, sig) == 0 &&
	return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE;
	       sig == ROMSIGNATURE;
}
}


static int __init romchecksum(unsigned char *rom, unsigned long length)
static int __init romchecksum(const unsigned char *rom, unsigned long length)
{
{
	unsigned char sum;
	unsigned char sum, c;


	for (sum = 0; length; length--)
	for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--)
		sum += *rom++;
		sum += c;
	return sum == 0;
	return !length && !sum;
}
}


static void __init probe_roms(void)
static void __init probe_roms(void)
{
{
	const unsigned char *rom;
	unsigned long start, length, upper;
	unsigned long start, length, upper;
	unsigned char *rom;
	unsigned char c;
	int i;
	int i;


	/* video rom */
	/* video rom */
@@ -191,8 +192,11 @@ static void __init probe_roms(void)


		video_rom_resource.start = start;
		video_rom_resource.start = start;


		if (probe_kernel_address(rom + 2, c) != 0)
			continue;

		/* 0 < length <= 0x7f * 512, historically */
		/* 0 < length <= 0x7f * 512, historically */
		length = rom[2] * 512;
		length = c * 512;


		/* if checksum okay, trust length byte */
		/* if checksum okay, trust length byte */
		if (length && romchecksum(rom, length))
		if (length && romchecksum(rom, length))
@@ -226,8 +230,11 @@ static void __init probe_roms(void)
		if (!romsignature(rom))
		if (!romsignature(rom))
			continue;
			continue;


		if (probe_kernel_address(rom + 2, c) != 0)
			continue;

		/* 0 < length <= 0x7f * 512, historically */
		/* 0 < length <= 0x7f * 512, historically */
		length = rom[2] * 512;
		length = c * 512;


		/* but accept any length that fits if checksum okay */
		/* but accept any length that fits if checksum okay */
		if (!length || start + length > upper || !romchecksum(rom, length))
		if (!length || start + length > upper || !romchecksum(rom, length))