diff options
author | Brian Gerst <brgerst@gmail.com> | 2009-01-26 22:56:48 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2009-01-26 22:56:48 -0500 |
commit | b2d2f4312b117a6cc647c8521e2643a88771f757 (patch) | |
tree | cf512c6ed0cfc5081f095cfa1da974b1566bb043 /arch | |
parent | 89c9c4c58ee86e6e8802597271f23679e0c46647 (diff) |
x86: initialize per-cpu GDT segment in per-cpu setup
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/processor.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/Makefile | 3 | ||||
-rw-r--r-- | arch/x86/kernel/setup_percpu.c | 14 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/smpcommon.c | 25 | ||||
-rw-r--r-- | arch/x86/mach-voyager/voyager_smp.c | 2 | ||||
-rw-r--r-- | arch/x86/xen/smp.c | 1 |
7 files changed, 15 insertions, 35 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 48676b943b92..32c30b02b51f 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -778,7 +778,6 @@ extern struct desc_ptr early_gdt_descr; | |||
778 | extern void cpu_set_gdt(int); | 778 | extern void cpu_set_gdt(int); |
779 | extern void switch_to_new_gdt(void); | 779 | extern void switch_to_new_gdt(void); |
780 | extern void cpu_init(void); | 780 | extern void cpu_init(void); |
781 | extern void init_gdt(int cpu); | ||
782 | 781 | ||
783 | static inline unsigned long get_debugctlmsr(void) | 782 | static inline unsigned long get_debugctlmsr(void) |
784 | { | 783 | { |
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 73de055c29c2..37fa30bada17 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -60,8 +60,7 @@ obj-$(CONFIG_APM) += apm.o | |||
60 | obj-$(CONFIG_X86_SMP) += smp.o | 60 | obj-$(CONFIG_X86_SMP) += smp.o |
61 | obj-$(CONFIG_X86_SMP) += smpboot.o tsc_sync.o ipi.o | 61 | obj-$(CONFIG_X86_SMP) += smpboot.o tsc_sync.o ipi.o |
62 | obj-$(CONFIG_SMP) += setup_percpu.o | 62 | obj-$(CONFIG_SMP) += setup_percpu.o |
63 | obj-$(CONFIG_X86_32_SMP) += smpcommon.o | 63 | obj-$(CONFIG_X86_64_SMP) += tsc_sync.o |
64 | obj-$(CONFIG_X86_64_SMP) += tsc_sync.o smpcommon.o | ||
65 | obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o | 64 | obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o |
66 | obj-$(CONFIG_X86_MPPARSE) += mpparse.o | 65 | obj-$(CONFIG_X86_MPPARSE) += mpparse.o |
67 | obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o | 66 | obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o |
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index 599dc1cc1da8..bcca3a7b3748 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c | |||
@@ -40,6 +40,19 @@ unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = { | |||
40 | }; | 40 | }; |
41 | EXPORT_SYMBOL(__per_cpu_offset); | 41 | EXPORT_SYMBOL(__per_cpu_offset); |
42 | 42 | ||
43 | static inline void setup_percpu_segment(int cpu) | ||
44 | { | ||
45 | #ifdef CONFIG_X86_32 | ||
46 | struct desc_struct gdt; | ||
47 | |||
48 | pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF, | ||
49 | 0x2 | DESCTYPE_S, 0x8); | ||
50 | gdt.s = 1; | ||
51 | write_gdt_entry(get_cpu_gdt_table(cpu), | ||
52 | GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S); | ||
53 | #endif | ||
54 | } | ||
55 | |||
43 | /* | 56 | /* |
44 | * Great future plan: | 57 | * Great future plan: |
45 | * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data. | 58 | * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data. |
@@ -81,6 +94,7 @@ void __init setup_per_cpu_areas(void) | |||
81 | per_cpu_offset(cpu) = ptr - __per_cpu_start; | 94 | per_cpu_offset(cpu) = ptr - __per_cpu_start; |
82 | per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu); | 95 | per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu); |
83 | per_cpu(cpu_number, cpu) = cpu; | 96 | per_cpu(cpu_number, cpu) = cpu; |
97 | setup_percpu_segment(cpu); | ||
84 | /* | 98 | /* |
85 | * Copy data used in early init routines from the initial arrays to the | 99 | * Copy data used in early init routines from the initial arrays to the |
86 | * per cpu data areas. These arrays then become expendable and the | 100 | * per cpu data areas. These arrays then become expendable and the |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index def770b57b5a..f9dbcff43546 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -793,7 +793,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) | |||
793 | do_rest: | 793 | do_rest: |
794 | per_cpu(current_task, cpu) = c_idle.idle; | 794 | per_cpu(current_task, cpu) = c_idle.idle; |
795 | #ifdef CONFIG_X86_32 | 795 | #ifdef CONFIG_X86_32 |
796 | init_gdt(cpu); | ||
797 | /* Stack for startup_32 can be just as for start_secondary onwards */ | 796 | /* Stack for startup_32 can be just as for start_secondary onwards */ |
798 | irq_ctx_init(cpu); | 797 | irq_ctx_init(cpu); |
799 | #else | 798 | #else |
@@ -1186,9 +1185,6 @@ out: | |||
1186 | void __init native_smp_prepare_boot_cpu(void) | 1185 | void __init native_smp_prepare_boot_cpu(void) |
1187 | { | 1186 | { |
1188 | int me = smp_processor_id(); | 1187 | int me = smp_processor_id(); |
1189 | #ifdef CONFIG_X86_32 | ||
1190 | init_gdt(me); | ||
1191 | #endif | ||
1192 | switch_to_new_gdt(); | 1188 | switch_to_new_gdt(); |
1193 | /* already set me in cpu_online_mask in boot_cpu_init() */ | 1189 | /* already set me in cpu_online_mask in boot_cpu_init() */ |
1194 | cpumask_set_cpu(me, cpu_callout_mask); | 1190 | 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 index 5ec29a1a8465..000000000000 --- a/arch/x86/kernel/smpcommon.c +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /* | ||
2 | * SMP stuff which is common to all sub-architectures. | ||
3 | */ | ||
4 | #include <linux/module.h> | ||
5 | #include <asm/smp.h> | ||
6 | #include <asm/sections.h> | ||
7 | |||
8 | #ifdef CONFIG_X86_32 | ||
9 | /* | ||
10 | * Initialize the CPU's GDT. This is either the boot CPU doing itself | ||
11 | * (still using the master per-cpu area), or a CPU doing it for a | ||
12 | * secondary which will soon come up. | ||
13 | */ | ||
14 | __cpuinit void init_gdt(int cpu) | ||
15 | { | ||
16 | struct desc_struct gdt; | ||
17 | |||
18 | pack_descriptor(&gdt, __per_cpu_offset[cpu], 0xFFFFF, | ||
19 | 0x2 | DESCTYPE_S, 0x8); | ||
20 | gdt.s = 1; | ||
21 | |||
22 | write_gdt_entry(get_cpu_gdt_table(cpu), | ||
23 | GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S); | ||
24 | } | ||
25 | #endif | ||
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c index dd82f2052f34..331cd6d56483 100644 --- a/arch/x86/mach-voyager/voyager_smp.c +++ b/arch/x86/mach-voyager/voyager_smp.c | |||
@@ -530,7 +530,6 @@ static void __init do_boot_cpu(__u8 cpu) | |||
530 | /* init_tasks (in sched.c) is indexed logically */ | 530 | /* init_tasks (in sched.c) is indexed logically */ |
531 | stack_start.sp = (void *)idle->thread.sp; | 531 | stack_start.sp = (void *)idle->thread.sp; |
532 | 532 | ||
533 | init_gdt(cpu); | ||
534 | per_cpu(current_task, cpu) = idle; | 533 | per_cpu(current_task, cpu) = idle; |
535 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); | 534 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); |
536 | irq_ctx_init(cpu); | 535 | irq_ctx_init(cpu); |
@@ -1747,7 +1746,6 @@ static void __init voyager_smp_prepare_cpus(unsigned int max_cpus) | |||
1747 | 1746 | ||
1748 | static void __cpuinit voyager_smp_prepare_boot_cpu(void) | 1747 | static void __cpuinit voyager_smp_prepare_boot_cpu(void) |
1749 | { | 1748 | { |
1750 | init_gdt(smp_processor_id()); | ||
1751 | switch_to_new_gdt(); | 1749 | switch_to_new_gdt(); |
1752 | 1750 | ||
1753 | cpu_set(smp_processor_id(), cpu_online_map); | 1751 | cpu_set(smp_processor_id(), cpu_online_map); |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 72c2eb9b64cd..7735e3dd359c 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
@@ -281,7 +281,6 @@ static int __cpuinit xen_cpu_up(unsigned int cpu) | |||
281 | 281 | ||
282 | per_cpu(current_task, cpu) = idle; | 282 | per_cpu(current_task, cpu) = idle; |
283 | #ifdef CONFIG_X86_32 | 283 | #ifdef CONFIG_X86_32 |
284 | init_gdt(cpu); | ||
285 | irq_ctx_init(cpu); | 284 | irq_ctx_init(cpu); |
286 | #else | 285 | #else |
287 | clear_tsk_thread_flag(idle, TIF_FORK); | 286 | clear_tsk_thread_flag(idle, TIF_FORK); |