diff options
author | James Bottomley <James.Bottomley@SteelEye.com> | 2007-01-22 10:18:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-01-22 22:39:36 -0500 |
commit | 9ee79a3d372fcb6729893437f4923c5efd1f85db (patch) | |
tree | 6a220d2935ed4c539e41a9ad7057bfbc21deafd8 /arch/i386 | |
parent | ebcccd14b73831fa7fbc197e1d2b9c710a65731e (diff) |
[PATCH] x86: fix PDA variables to work during boot
The current PDA code, which went in in post 2.6.19 has a flaw in that it
doesn't correctly cycle the GDT and %GS segment through the boot PDA,
the CPU PDA and finally the per-cpu PDA.
The bug generally doesn't show up if the boot CPU id is zero, but
everything falls apart for a non zero boot CPU id. The basically kills
voyager which is perfectly capable of doing non zero CPU id boots, so
voyager currently won't boot without this.
The fix is to be careful and actually do the GDT setups correctly.
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/kernel/cpu/common.c | 13 | ||||
-rw-r--r-- | arch/i386/kernel/smpboot.c | 9 | ||||
-rw-r--r-- | arch/i386/mach-voyager/voyager_smp.c | 6 |
3 files changed, 21 insertions, 7 deletions
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index 8689d62abd4a..8a8bbdaaf38a 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c | |||
@@ -710,11 +710,8 @@ __cpuinit int init_gdt(int cpu, struct task_struct *idle) | |||
710 | return 1; | 710 | return 1; |
711 | } | 711 | } |
712 | 712 | ||
713 | /* Common CPU init for both boot and secondary CPUs */ | 713 | void __cpuinit cpu_set_gdt(int cpu) |
714 | static void __cpuinit _cpu_init(int cpu, struct task_struct *curr) | ||
715 | { | 714 | { |
716 | struct tss_struct * t = &per_cpu(init_tss, cpu); | ||
717 | struct thread_struct *thread = &curr->thread; | ||
718 | struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu); | 715 | struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu); |
719 | 716 | ||
720 | /* Reinit these anyway, even if they've already been done (on | 717 | /* Reinit these anyway, even if they've already been done (on |
@@ -722,6 +719,13 @@ static void __cpuinit _cpu_init(int cpu, struct task_struct *curr) | |||
722 | the real ones). */ | 719 | the real ones). */ |
723 | load_gdt(cpu_gdt_descr); | 720 | load_gdt(cpu_gdt_descr); |
724 | set_kernel_gs(); | 721 | set_kernel_gs(); |
722 | } | ||
723 | |||
724 | /* Common CPU init for both boot and secondary CPUs */ | ||
725 | static void __cpuinit _cpu_init(int cpu, struct task_struct *curr) | ||
726 | { | ||
727 | struct tss_struct * t = &per_cpu(init_tss, cpu); | ||
728 | struct thread_struct *thread = &curr->thread; | ||
725 | 729 | ||
726 | if (cpu_test_and_set(cpu, cpu_initialized)) { | 730 | if (cpu_test_and_set(cpu, cpu_initialized)) { |
727 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); | 731 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); |
@@ -807,6 +811,7 @@ void __cpuinit cpu_init(void) | |||
807 | local_irq_enable(); | 811 | local_irq_enable(); |
808 | } | 812 | } |
809 | 813 | ||
814 | cpu_set_gdt(cpu); | ||
810 | _cpu_init(cpu, curr); | 815 | _cpu_init(cpu, curr); |
811 | } | 816 | } |
812 | 817 | ||
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index dea7ef9d3e82..8c6c8c52b95c 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c | |||
@@ -596,6 +596,12 @@ static void __cpuinit start_secondary(void *unused) | |||
596 | void __devinit initialize_secondary(void) | 596 | void __devinit initialize_secondary(void) |
597 | { | 597 | { |
598 | /* | 598 | /* |
599 | * switch to the per CPU GDT we already set up | ||
600 | * in do_boot_cpu() | ||
601 | */ | ||
602 | cpu_set_gdt(current_thread_info()->cpu); | ||
603 | |||
604 | /* | ||
599 | * We don't actually need to load the full TSS, | 605 | * We don't actually need to load the full TSS, |
600 | * basically just the stack pointer and the eip. | 606 | * basically just the stack pointer and the eip. |
601 | */ | 607 | */ |
@@ -972,9 +978,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) | |||
972 | /* Stack for startup_32 can be just as for start_secondary onwards */ | 978 | /* Stack for startup_32 can be just as for start_secondary onwards */ |
973 | stack_start.esp = (void *) idle->thread.esp; | 979 | stack_start.esp = (void *) idle->thread.esp; |
974 | 980 | ||
975 | start_pda = cpu_pda(cpu); | ||
976 | cpu_gdt_descr = per_cpu(cpu_gdt_descr, cpu); | ||
977 | |||
978 | irq_ctx_init(cpu); | 981 | irq_ctx_init(cpu); |
979 | 982 | ||
980 | x86_cpu_to_apicid[cpu] = apicid; | 983 | x86_cpu_to_apicid[cpu] = apicid; |
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c index 55428e656a3f..74aeedf277f4 100644 --- a/arch/i386/mach-voyager/voyager_smp.c +++ b/arch/i386/mach-voyager/voyager_smp.c | |||
@@ -773,6 +773,12 @@ initialize_secondary(void) | |||
773 | #endif | 773 | #endif |
774 | 774 | ||
775 | /* | 775 | /* |
776 | * switch to the per CPU GDT we already set up | ||
777 | * in do_boot_cpu() | ||
778 | */ | ||
779 | cpu_set_gdt(current_thread_info()->cpu); | ||
780 | |||
781 | /* | ||
776 | * We don't actually need to load the full TSS, | 782 | * We don't actually need to load the full TSS, |
777 | * basically just the stack pointer and the eip. | 783 | * basically just the stack pointer and the eip. |
778 | */ | 784 | */ |