Commit 950f9d95 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Ingo Molnar

x86: fix the missing BIOS area check in page_is_ram

page_is_ram has a FIXME since ages, which reminds to sanity check the
BIOS area between 640k and 1M, which is sometimes falsely reported as
RAM in the e820 tables.

Implement the sanity check. Move the BIOS range defines from
pageattr.c into e820.h to avoid duplicate defines.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 5f5192b9
...@@ -42,13 +42,18 @@ int page_is_ram(unsigned long pagenr) ...@@ -42,13 +42,18 @@ int page_is_ram(unsigned long pagenr)
*/ */
if (e820.map[i].type != E820_RAM) if (e820.map[i].type != E820_RAM)
continue; continue;
/*
* !!!FIXME!!! Some BIOSen report areas as RAM that
* are not. Notably the 640->1Mb area. We need a sanity
* check here.
*/
addr = (e820.map[i].addr + PAGE_SIZE-1) >> PAGE_SHIFT; addr = (e820.map[i].addr + PAGE_SIZE-1) >> PAGE_SHIFT;
end = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT; end = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT;
/*
* Sanity check: Some BIOSen report areas as RAM that
* are not. Notably the 640->1Mb area, which is the
* PCI BIOS area.
*/
if (addr >= (BIOS_BEGIN >> PAGE_SHIFT) &&
end < (BIOS_END >> PAGE_SHIFT))
continue;
if ((pagenr >= addr) && (pagenr < end)) if ((pagenr >= addr) && (pagenr < end))
return 1; return 1;
} }
......
...@@ -9,18 +9,13 @@ ...@@ -9,18 +9,13 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <asm/e820.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
/*
* We must allow the BIOS range to be executable:
*/
#define BIOS_BEGIN 0x000a0000
#define BIOS_END 0x00100000
static inline int static inline int
within(unsigned long addr, unsigned long start, unsigned long end) within(unsigned long addr, unsigned long start, unsigned long end)
{ {
......
...@@ -25,6 +25,9 @@ struct e820map { ...@@ -25,6 +25,9 @@ struct e820map {
#define ISA_START_ADDRESS 0xa0000 #define ISA_START_ADDRESS 0xa0000
#define ISA_END_ADDRESS 0x100000 #define ISA_END_ADDRESS 0x100000
#define BIOS_BEGIN 0x000a0000
#define BIOS_END 0x00100000
#ifdef __KERNEL__ #ifdef __KERNEL__
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
# include "e820_32.h" # include "e820_32.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment