From ea3ed258cdde9af3bea07e8a5dc27701be6fa79d Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 27 Feb 2008 20:57:40 +0100 Subject: [PATCH] --- yaml --- r: 88677 b: refs/heads/master c: e3100c82abd9aa643dc15828202aceeae3504e03 h: refs/heads/master i: 88675: 66c6a9b681ca0163dc49091165d87e5efee956a0 v: v3 --- [refs] | 2 +- trunk/arch/x86/mm/ioremap.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4be8c04de802..3f4881ace4ad 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b8c2d3dfbc117dff26058fbac316b8acfc2cb5f7 +refs/heads/master: e3100c82abd9aa643dc15828202aceeae3504e03 diff --git a/trunk/arch/x86/mm/ioremap.c b/trunk/arch/x86/mm/ioremap.c index 868bbde74698..17f518839028 100644 --- a/trunk/arch/x86/mm/ioremap.c +++ b/trunk/arch/x86/mm/ioremap.c @@ -35,6 +35,18 @@ unsigned long __phys_addr(unsigned long x) } EXPORT_SYMBOL(__phys_addr); +static inline int phys_addr_valid(unsigned long addr) +{ + return addr < (1UL << boot_cpu_data.x86_phys_bits); +} + +#else + +static inline int phys_addr_valid(unsigned long addr) +{ + return 1; +} + #endif int page_is_ram(unsigned long pagenr) @@ -118,6 +130,13 @@ static void __iomem *__ioremap(resource_size_t phys_addr, unsigned long size, if (!size || last_addr < phys_addr) return NULL; + if (!phys_addr_valid(phys_addr)) { + printk(KERN_WARNING "ioremap: invalid physical address %lx\n", + phys_addr); + WARN_ON_ONCE(1); + return NULL; + } + /* * Don't remap the low PCI/ISA area, it's always mapped.. */