aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/cpu/common.c')
-rw-r--r--arch/x86/kernel/cpu/common.c71
1 files changed, 27 insertions, 44 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index c49498d40830..7976a6a0f65c 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -881,47 +881,32 @@ __setup("clearcpuid=", setup_disablecpuid);
881#ifdef CONFIG_X86_64 881#ifdef CONFIG_X86_64
882struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table }; 882struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
883 883
884static char boot_cpu_stack[IRQSTACKSIZE] __page_aligned_bss; 884DEFINE_PER_CPU_PAGE_ALIGNED(char[IRQ_STACK_SIZE], irq_stack);
885#ifdef CONFIG_SMP
886DEFINE_PER_CPU(char *, irq_stack_ptr); /* will be set during per cpu init */
887#else
888DEFINE_PER_CPU(char *, irq_stack_ptr) =
889 per_cpu_var(irq_stack) + IRQ_STACK_SIZE - 64;
890#endif
891
892DEFINE_PER_CPU(unsigned long, kernel_stack) =
893 (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
894EXPORT_PER_CPU_SYMBOL(kernel_stack);
895
896DEFINE_PER_CPU(unsigned int, irq_count) = -1;
885 897
886void __cpuinit pda_init(int cpu) 898void __cpuinit pda_init(int cpu)
887{ 899{
888 struct x8664_pda *pda = cpu_pda(cpu);
889
890 /* Setup up data that may be needed in __get_free_pages early */ 900 /* Setup up data that may be needed in __get_free_pages early */
891 loadsegment(fs, 0); 901 loadsegment(fs, 0);
892 loadsegment(gs, 0); 902 loadsegment(gs, 0);
893 903
894 load_pda_offset(cpu); 904 load_pda_offset(cpu);
895
896 pda->cpunumber = cpu;
897 pda->irqcount = -1;
898 pda->kernelstack = (unsigned long)stack_thread_info() -
899 PDA_STACKOFFSET + THREAD_SIZE;
900 pda->active_mm = &init_mm;
901 pda->mmu_state = 0;
902
903 if (cpu == 0) {
904 /* others are initialized in smpboot.c */
905 pda->pcurrent = &init_task;
906 pda->irqstackptr = boot_cpu_stack;
907 pda->irqstackptr += IRQSTACKSIZE - 64;
908 } else {
909 if (!pda->irqstackptr) {
910 pda->irqstackptr = (char *)
911 __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
912 if (!pda->irqstackptr)
913 panic("cannot allocate irqstack for cpu %d",
914 cpu);
915 pda->irqstackptr += IRQSTACKSIZE - 64;
916 }
917
918 if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
919 pda->nodenumber = cpu_to_node(cpu);
920 }
921} 905}
922 906
923static char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + 907static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
924 DEBUG_STKSZ] __page_aligned_bss; 908 [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ])
909 __aligned(PAGE_SIZE);
925 910
926extern asmlinkage void ignore_sysret(void); 911extern asmlinkage void ignore_sysret(void);
927 912
@@ -979,15 +964,18 @@ void __cpuinit cpu_init(void)
979 struct tss_struct *t = &per_cpu(init_tss, cpu); 964 struct tss_struct *t = &per_cpu(init_tss, cpu);
980 struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu); 965 struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu);
981 unsigned long v; 966 unsigned long v;
982 char *estacks = NULL;
983 struct task_struct *me; 967 struct task_struct *me;
984 int i; 968 int i;
985 969
986 /* CPU 0 is initialised in head64.c */ 970 /* CPU 0 is initialised in head64.c */
987 if (cpu != 0) 971 if (cpu != 0)
988 pda_init(cpu); 972 pda_init(cpu);
989 else 973
990 estacks = boot_exception_stacks; 974#ifdef CONFIG_NUMA
975 if (cpu != 0 && percpu_read(node_number) == 0 &&
976 cpu_to_node(cpu) != NUMA_NO_NODE)
977 percpu_write(node_number, cpu_to_node(cpu));
978#endif
991 979
992 me = current; 980 me = current;
993 981
@@ -1021,18 +1009,13 @@ void __cpuinit cpu_init(void)
1021 * set up and load the per-CPU TSS 1009 * set up and load the per-CPU TSS
1022 */ 1010 */
1023 if (!orig_ist->ist[0]) { 1011 if (!orig_ist->ist[0]) {
1024 static const unsigned int order[N_EXCEPTION_STACKS] = { 1012 static const unsigned int sizes[N_EXCEPTION_STACKS] = {
1025 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER, 1013 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ,
1026 [DEBUG_STACK - 1] = DEBUG_STACK_ORDER 1014 [DEBUG_STACK - 1] = DEBUG_STKSZ
1027 }; 1015 };
1016 char *estacks = per_cpu(exception_stacks, cpu);
1028 for (v = 0; v < N_EXCEPTION_STACKS; v++) { 1017 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
1029 if (cpu) { 1018 estacks += sizes[v];
1030 estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
1031 if (!estacks)
1032 panic("Cannot allocate exception "
1033 "stack %ld %d\n", v, cpu);
1034 }
1035 estacks += PAGE_SIZE << order[v];
1036 orig_ist->ist[v] = t->x86_tss.ist[v] = 1019 orig_ist->ist[v] = t->x86_tss.ist[v] =
1037 (unsigned long)estacks; 1020 (unsigned long)estacks;
1038 } 1021 }