From 23be8c7ddf4fd31a14579a2109c89845f7a0fbb6 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Tue, 15 Jan 2008 16:44:37 +0100 Subject: x86: fix boot crash on HIGHMEM4G && SPARSEMEM Denys Fedoryshchenko reported a bootup crash when he upgraded his system from 3GB to 4GB RAM: http://lkml.org/lkml/2008/1/7/9 the bug is due to HIGHMEM4G && SPARSEMEM kernels making pfn_to_page() to return an invalid pointer when the pfn is in a memory hole. The 256 MB PCI aperture at the end of RAM was not mapped by sparsemem, and hence the pfn was not valid. But set_highmem_pages_init() iterated this range without checking the pfn's validity first. this bug was probably present in the sparsemem code ever since sparsemem has been introduced in v2.6.13. It was masked due to HIGHMEM64G using larger memory regions in sparsemem_32.h: #ifdef CONFIG_X86_PAE #define SECTION_SIZE_BITS 30 #define MAX_PHYSADDR_BITS 36 #define MAX_PHYSMEM_BITS 36 #else #define SECTION_SIZE_BITS 26 #define MAX_PHYSADDR_BITS 32 #define MAX_PHYSMEM_BITS 32 #endif which creates 1GB sparsemem regions instead of 64MB sparsemem regions. So in practice we only ever created true sparsemem holes on x86 with HIGHMEM4G - but that was rarely used by distros. ( btw., we could probably save 2MB of mem_map[]s on X86_PAE if we reduced the sparsemem region size to 256 MB. ) Signed-off-by: Ingo Molnar Acked-by: Thomas Gleixner --- arch/x86/mm/init_32.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index c7d19471261dc7..3c76d194fd2cce 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -321,8 +321,13 @@ extern void set_highmem_pages_init(int); static void __init set_highmem_pages_init(int bad_ppro) { int pfn; - for (pfn = highstart_pfn; pfn < highend_pfn; pfn++) - add_one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro); + for (pfn = highstart_pfn; pfn < highend_pfn; pfn++) { + /* + * Holes under sparsemem might not have no mem_map[]: + */ + if (pfn_valid(pfn)) + add_one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro); + } totalram_pages += totalhigh_pages; } #endif /* CONFIG_FLATMEM */ -- cgit 1.2.3-korg From d43a3312c77eb6bbf71fbadefb1683f6d197bf91 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 15 Jan 2008 16:44:38 +0100 Subject: x86: asm-x86/msr.h: pull in linux/types.h Since the msr.h header uses types like __u32, it should pull in linux/types.h. [ mingo@elte.hu: affects user-space that includes this header. We dont actually like user-space including raw kernel headers but it's a longstanding practice and it's easy for the kernel to be nice about this. ] Signed-off-by: Mike Frysinger Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar --- include/asm-x86/msr.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h index 664a2fa7adc90b..80b027081b3ce5 100644 --- a/include/asm-x86/msr.h +++ b/include/asm-x86/msr.h @@ -3,6 +3,10 @@ #include +#ifndef __ASSEMBLY__ +# include +#endif + #ifdef __i386__ #ifdef __KERNEL__ -- cgit 1.2.3-korg From 8ee291f87c5dcebcf9c3a0ee4e021586897db364 Mon Sep 17 00:00:00 2001 From: Bernhard Walle Date: Tue, 15 Jan 2008 16:44:38 +0100 Subject: x86: fix RTC_AIE with CONFIG_HPET_EMULATE_RTC In the current code, RTC_AIE doesn't work if the RTC relies on CONFIG_HPET_EMULATE_RTC because the code sets the RTC_AIE flag in hpet_set_rtc_irq_bit(). The interrupt handles does accidentally check for RTC_PIE and not RTC_AIE when comparing the time which was set in hpet_set_alarm_time(). I now verified on a test system here that without the patch applied, the attached test program fails on a system that has HPET with 2.6.24-rc7-default. That's not critical since I guess the problem has been there for several kernel releases, but as the fix is quite obvious. Configuration is CONFIG_RTC=y and CONFIG_HPET_EMULATE_RTC=y. Signed-off-by: Bernhard Walle Acked-by: Thomas Gleixner Signed-off-by: Ingo Molnar --- arch/x86/kernel/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 4a86ffd67ec5e2..2f99ee206b9527 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -657,7 +657,7 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) hpet_pie_count = 0; } - if (hpet_rtc_flags & RTC_PIE && + if (hpet_rtc_flags & RTC_AIE && (curr_time.tm_sec == hpet_alarm_time.tm_sec) && (curr_time.tm_min == hpet_alarm_time.tm_min) && (curr_time.tm_hour == hpet_alarm_time.tm_hour)) -- cgit 1.2.3-korg