From c86c7fbc829e27e2a4093f98ded9fbd75e515adb Mon Sep 17 00:00:00 2001 From: OGAWA Hirofumi Date: Mon, 3 Dec 2007 17:17:10 +0100 Subject: [PATCH 1/3] x86: disable hpet on shutdown If HPET was enabled by pci quirks, we use i8253 as initial clockevent because pci quirks doesn't run until pci is initialized. The above means the kernel (or something) is assuming HPET legacy replacement is disabled and can use i8253 at boot. If we used kexec, it isn't true. So, this patch disables HPET legacy replacement for kexec in machine_shutdown(). Signed-off-by: OGAWA Hirofumi Acked-by: Venkatesh Pallipadi Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- arch/x86/kernel/hpet.c | 14 ++++++++++++++ arch/x86/kernel/reboot_32.c | 4 ++++ arch/x86/kernel/reboot_64.c | 4 ++++ include/asm-x86/hpet.h | 1 + 4 files changed, 23 insertions(+) diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 53303f2e547..4a86ffd67ec 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -446,6 +446,20 @@ static __init int hpet_late_init(void) } fs_initcall(hpet_late_init); +void hpet_disable(void) +{ + if (is_hpet_capable()) { + unsigned long cfg = hpet_readl(HPET_CFG); + + if (hpet_legacy_int_enabled) { + cfg &= ~HPET_CFG_LEGACY; + hpet_legacy_int_enabled = 0; + } + cfg &= ~HPET_CFG_ENABLE; + hpet_writel(cfg, HPET_CFG); + } +} + #ifdef CONFIG_HPET_EMULATE_RTC /* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET diff --git a/arch/x86/kernel/reboot_32.c b/arch/x86/kernel/reboot_32.c index 9e2269d0091..bb1a0f889c5 100644 --- a/arch/x86/kernel/reboot_32.c +++ b/arch/x86/kernel/reboot_32.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "mach_reboot.h" #include @@ -326,6 +327,9 @@ static void native_machine_shutdown(void) #ifdef CONFIG_X86_IO_APIC disable_IO_APIC(); #endif +#ifdef CONFIG_HPET_TIMER + hpet_disable(); +#endif } void __attribute__((weak)) mach_reboot_fixups(void) diff --git a/arch/x86/kernel/reboot_64.c b/arch/x86/kernel/reboot_64.c index 71b13c5f581..53620a92a8f 100644 --- a/arch/x86/kernel/reboot_64.c +++ b/arch/x86/kernel/reboot_64.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* @@ -113,6 +114,9 @@ void machine_shutdown(void) disable_IO_APIC(); +#ifdef CONFIG_HPET_TIMER + hpet_disable(); +#endif local_irq_restore(flags); pci_iommu_shutdown(); diff --git a/include/asm-x86/hpet.h b/include/asm-x86/hpet.h index b1f3c1ea55d..ad8d6e75878 100644 --- a/include/asm-x86/hpet.h +++ b/include/asm-x86/hpet.h @@ -61,6 +61,7 @@ extern unsigned long force_hpet_address; extern int hpet_force_user; extern int is_hpet_enabled(void); extern int hpet_enable(void); +extern void hpet_disable(void); extern unsigned long hpet_readl(unsigned long a); extern void force_hpet_resume(void); From 0c1b2724069951b1902373e688042b2ec382f68f Mon Sep 17 00:00:00 2001 From: OGAWA Hirofumi Date: Mon, 3 Dec 2007 17:17:10 +0100 Subject: [PATCH 2/3] x86: disable hpet legacy replacement for kdump we should also add hpet_disable() for kdump. Signed-off-by: OGAWA Hirofumi Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- arch/x86/kernel/crash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 8bb482ff091..9a5fa0abfcc 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -139,6 +140,9 @@ void machine_crash_shutdown(struct pt_regs *regs) lapic_shutdown(); #if defined(CONFIG_X86_IO_APIC) disable_IO_APIC(); +#endif +#ifdef CONFIG_HPET_TIMER + hpet_disable(); #endif crash_save_cpu(regs, safe_smp_processor_id()); } From 17d57a9206b4de6ad082ac9f2d2346985abbd2aa Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Sat, 1 Dec 2007 18:34:06 -0700 Subject: [PATCH 3/3] x86: fix x86-32 early fixmap initialization. pageexec@freemail.hu writes: > i've just noticed that the chunk in i386/kernel/head.S ended up in a > weird place, namely, it's not going to be executed as it's just after > a 'jmp 3f' and before startup_32_smp, probably not what you intended. > on a sidenote, the whole thing can be done in a single insn, like: > > movl $(swapper_pg_pmd - __PAGE_OFFSET + 0x067), (swapper_pg_dir - > __PAGE_OFFSET+ 4092) Thanks for the reminder I thought we had fixed this problem a while ago. Needed to get fixed virtual address for USB debug and earlycon with mmio. Signed-off-by: "Eric W. Biederman" Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar --- arch/x86/kernel/head_32.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index 374b7ece896..ac0637a6d71 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S @@ -193,6 +193,12 @@ default_entry: jb 10b movl %edi,(init_pg_tables_end - __PAGE_OFFSET) + /* Do an early initialization of the fixmap area */ + movl $(swapper_pg_dir - __PAGE_OFFSET), %edx + movl $(swapper_pg_pmd - __PAGE_OFFSET), %eax + addl $0x007, %eax /* 0x007 = PRESENT+RW+USER */ + movl %eax, 4092(%edx) + xorl %ebx,%ebx /* This is the boot CPU (BSP) */ jmp 3f /* @@ -208,12 +214,6 @@ default_entry: .section .init.text,"ax",@progbits #endif - /* Do an early initialization of the fixmap area */ - movl $(swapper_pg_dir - __PAGE_OFFSET), %edx - movl $(swapper_pg_pmd - __PAGE_OFFSET), %eax - addl $0x007, %eax /* 0x007 = PRESENT+RW+USER */ - movl %eax, 4092(%edx) - #ifdef CONFIG_SMP ENTRY(startup_32_smp) cld