BIOS reserved regions block iomem registration
PATCH 1/1 BIOS reserved regions block iomem registration
arch/i386/kernel/setup.c:register_memory() marks e820 memory regions - some of which are "reserved". These "reserved" regions prevent FLASH chip drivers from registering the memory range occupied by BIOS code:
bash-2.05# cat /proc/iomem
.
.
.
fec00000-fec003ff : reserved
fee00000-fee00fff : reserved
fff80000-ffffffff : reserved
The last range marked as "reserved" (fff80000-ffffffff) is occupied by the FLASH chip containing the BIOS code. I'd like the MTD drivers to register the correct ranges like this:
fec00000-fec003ff : reserved
fee00000-fee00fff : reserved
ffb00000-ffffffff : amd76xrom
fff80000-ffffffff : mtd0
That way the iomem resources will be correct and can be used to map FLASH chip updates.
There are at least two ways to fix this problem:
1) Don't mark the BIOS reserved regions. Some BIOSes don't mark these and the kernel works fine. This is a trivial patch of removing the "reserved" line in setup.c:register_memory(). See remove_reserved.patch.
2) Leave the "reserved" regions but mark them with a IORESOURCE_GUESS so that they can be removed by a driver that knows better and is capable of correctly using the memory range. See resource_guess_flag.patch.
Both of these patches were made on 2.4.20, but will likely apply trivially to any 2.4.x or 2.6.
Signature · 2 lines
Thayne Harbaugh Linux Networx
arch/i386/kernel/setup.c +0 -1
@@ -1047,7 +1047,6 @@case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ; -default : res->name ="reserved" ; } res->start = e820.map[i].addr; res->end = res->start + e820.map[i].size -1 ;
kernel/resource.c +66 -0
78 lines not on this page · raw message
include/linux/ioport.h +10 -0
@@ -42,6 +42,15 @@#define IORESOURCE_SHADOWABLE 0x00010000#define IORESOURCE_BUS_HAS_VGA 0x00080000 +#define IORESOURCE_GUESS 0x08000000/* These regions are reserved +but it's unknown if it's +100% accurate. Must not have +children. Can be removed by +request_resource_remove_guess() +which will also kfree() the +resource - handles for these +aren't tracked by anything. */ +#define IORESOURCE_UNSET 0x20000000#define IORESOURCE_AUTO 0x40000000#define IORESOURCE_BUSY 0x80000000/* Driver has marked this resource busy */
@@ -87,6 +96,7 @@extern int check_resource (struct resource *root,unsigned long ,unsigned long );extern int request_resource (struct resource *root,struct resource *new); +extern int request_resource_remove_guess (struct resource *root,struct resource *new);extern int release_resource (struct resource *new); extern int allocate_resource(struct resource *root, struct resource *new, unsigned long size,
kernel/ksyms.c +1 -0
@@ -431,6 +431,7 @@/* resource handling */ EXPORT_SYMBOL (request_resource); +EXPORT_SYMBOL (request_resource_remove_guess);EXPORT_SYMBOL (release_resource);EXPORT_SYMBOL (allocate_resource);EXPORT_SYMBOL (check_resource);
Quoted 5 lines
1) Don't mark the BIOS reserved regions. Some BIOSes don't mark these and the kernel works fine. This is a trivial patch of removing the "reserved" line in setup.c:register_memory(). See remove_reserved.patch.
Er, the previous remove_reserved.patch wouldn't work. This should be more correct.
Signature · 2 lines
Thayne Harbaugh Linux Networx
arch/i386/kernel/setup.c +3 -1
@@ -1042,12 +1042,14 @@struct resource *res;if (e820.map[i].addr + e820.map[i].size >0x100000000ULL )continue ; +if (e820.map[i].type ==E820_RESERVED ) +continue ; res =alloc_bootmem_low (sizeof (struct resource ));switch (e820.map[i].type) {case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ; -default : res->name ="reserved" ; +default : res->name ="unknown" ; } res->start = e820.map[i].addr; res->end = res->start + e820.map[i].size -1 ;
In message <1066849062.6281.190.camel@tubarao> you write:
Quoted 3 lines
arch/i386/kernel/setup.c:register_memory() marks e820 memory regions - some of which are "reserved". These "reserved" regions prevent FLASH chip drivers from registering the memory range occupied by BIOS code:
Not trivial, sorry.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.