x86: initialize per-cpu GDT segment in per-cpu setup
authorBrian Gerst <brgerst@gmail.com>
Tue, 27 Jan 2009 03:56:48 +0000 (12:56 +0900)
committerTejun Heo <tj@kernel.org>
Tue, 27 Jan 2009 03:56:48 +0000 (12:56 +0900)
Impact: cleanup

Rename init_gdt() to setup_percpu_segment(), and move it to
setup_percpu.c.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

arch/x86/include/asm/processor.h
arch/x86/kernel/Makefile
arch/x86/kernel/setup_percpu.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/smpcommon.c [deleted file]
arch/x86/mach-voyager/voyager_smp.c
arch/x86/xen/smp.c

index 48676b9..32c30b0 100644 (file)
@@ -778,7 +778,6 @@ extern struct desc_ptr              early_gdt_descr;
 extern void cpu_set_gdt(int);
 extern void switch_to_new_gdt(void);
 extern void cpu_init(void);
-extern void init_gdt(int cpu);
 
 static inline unsigned long get_debugctlmsr(void)
 {
index 73de055..37fa30b 100644 (file)
@@ -60,8 +60,7 @@ obj-$(CONFIG_APM)             += apm.o
 obj-$(CONFIG_X86_SMP)          += smp.o
 obj-$(CONFIG_X86_SMP)          += smpboot.o tsc_sync.o ipi.o
 obj-$(CONFIG_SMP)              += setup_percpu.o
-obj-$(CONFIG_X86_32_SMP)       += smpcommon.o
-obj-$(CONFIG_X86_64_SMP)       += tsc_sync.o smpcommon.o
+obj-$(CONFIG_X86_64_SMP)       += tsc_sync.o
 obj-$(CONFIG_X86_TRAMPOLINE)   += trampoline_$(BITS).o
 obj-$(CONFIG_X86_MPPARSE)      += mpparse.o
 obj-$(CONFIG_X86_LOCAL_APIC)   += apic.o nmi.o
index 599dc1c..bcca3a7 100644 (file)
@@ -40,6 +40,19 @@ unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
 };
 EXPORT_SYMBOL(__per_cpu_offset);
 
+static inline void setup_percpu_segment(int cpu)
+{
+#ifdef CONFIG_X86_32
+       struct desc_struct gdt;
+
+       pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
+                       0x2 | DESCTYPE_S, 0x8);
+       gdt.s = 1;
+       write_gdt_entry(get_cpu_gdt_table(cpu),
+                       GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
+#endif
+}
+
 /*
  * Great future plan:
  * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
@@ -81,6 +94,7 @@ void __init setup_per_cpu_areas(void)
                per_cpu_offset(cpu) = ptr - __per_cpu_start;
                per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
                per_cpu(cpu_number, cpu) = cpu;
+               setup_percpu_segment(cpu);
                /*
                 * Copy data used in early init routines from the initial arrays to the
                 * per cpu data areas.  These arrays then become expendable and the
index def770b..f9dbcff 100644 (file)
@@ -793,7 +793,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
 do_rest:
        per_cpu(current_task, cpu) = c_idle.idle;
 #ifdef CONFIG_X86_32
-       init_gdt(cpu);
        /* Stack for startup_32 can be just as for start_secondary onwards */
        irq_ctx_init(cpu);
 #else
@@ -1186,9 +1185,6 @@ out:
 void __init native_smp_prepare_boot_cpu(void)
 {
        int me = smp_processor_id();
-#ifdef CONFIG_X86_32
-       init_gdt(me);
-#endif
        switch_to_new_gdt();
        /* already set me in cpu_online_mask in boot_cpu_init() */
        cpumask_set_cpu(me, cpu_callout_mask);
diff --git a/arch/x86/kernel/smpcommon.c b/arch/x86/kernel/smpcommon.c
deleted file mode 100644 (file)
index 5ec29a1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SMP stuff which is common to all sub-architectures.
- */
-#include <linux/module.h>
-#include <asm/smp.h>
-#include <asm/sections.h>
-
-#ifdef CONFIG_X86_32
-/*
- * Initialize the CPU's GDT.  This is either the boot CPU doing itself
- * (still using the master per-cpu area), or a CPU doing it for a
- * secondary which will soon come up.
- */
-__cpuinit void init_gdt(int cpu)
-{
-       struct desc_struct gdt;
-
-       pack_descriptor(&gdt, __per_cpu_offset[cpu], 0xFFFFF,
-                       0x2 | DESCTYPE_S, 0x8);
-       gdt.s = 1;
-
-       write_gdt_entry(get_cpu_gdt_table(cpu),
-                       GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
-}
-#endif
index dd82f20..331cd6d 100644 (file)
@@ -530,7 +530,6 @@ static void __init do_boot_cpu(__u8 cpu)
        /* init_tasks (in sched.c) is indexed logically */
        stack_start.sp = (void *)idle->thread.sp;
 
-       init_gdt(cpu);
        per_cpu(current_task, cpu) = idle;
        early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
        irq_ctx_init(cpu);
@@ -1747,7 +1746,6 @@ static void __init voyager_smp_prepare_cpus(unsigned int max_cpus)
 
 static void __cpuinit voyager_smp_prepare_boot_cpu(void)
 {
-       init_gdt(smp_processor_id());
        switch_to_new_gdt();
 
        cpu_set(smp_processor_id(), cpu_online_map);
index 72c2eb9..7735e3d 100644 (file)
@@ -281,7 +281,6 @@ static int __cpuinit xen_cpu_up(unsigned int cpu)
 
        per_cpu(current_task, cpu) = idle;
 #ifdef CONFIG_X86_32
-       init_gdt(cpu);
        irq_ctx_init(cpu);
 #else
        clear_tsk_thread_flag(idle, TIF_FORK);