2525DEFINE_PER_CPU (struct Xgt_desc_struct , cpu_gdt_descr );
2626EXPORT_PER_CPU_SYMBOL (cpu_gdt_descr );
2727
28- struct i386_pda * _cpu_pda [NR_CPUS ] __read_mostly ;
29- EXPORT_SYMBOL (_cpu_pda );
28+ DEFINE_PER_CPU (struct desc_struct , cpu_gdt [GDT_ENTRIES ]);
29+
30+ DEFINE_PER_CPU (struct i386_pda , _cpu_pda );
31+ EXPORT_PER_CPU_SYMBOL (_cpu_pda );
3032
3133static int cachesize_override __cpuinitdata = -1 ;
3234static int disable_x86_fxsr __cpuinitdata ;
@@ -609,52 +611,6 @@ struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
609611 return regs ;
610612}
611613
612- static __cpuinit int alloc_gdt (int cpu )
613- {
614- struct Xgt_desc_struct * cpu_gdt_descr = & per_cpu (cpu_gdt_descr , cpu );
615- struct desc_struct * gdt ;
616- struct i386_pda * pda ;
617-
618- gdt = (struct desc_struct * )cpu_gdt_descr -> address ;
619- pda = cpu_pda (cpu );
620-
621- /*
622- * This is a horrible hack to allocate the GDT. The problem
623- * is that cpu_init() is called really early for the boot CPU
624- * (and hence needs bootmem) but much later for the secondary
625- * CPUs, when bootmem will have gone away
626- */
627- if (NODE_DATA (0 )-> bdata -> node_bootmem_map ) {
628- BUG_ON (gdt != NULL || pda != NULL );
629-
630- gdt = alloc_bootmem_pages (PAGE_SIZE );
631- pda = alloc_bootmem (sizeof (* pda ));
632- /* alloc_bootmem(_pages) panics on failure, so no check */
633-
634- memset (gdt , 0 , PAGE_SIZE );
635- memset (pda , 0 , sizeof (* pda ));
636- } else {
637- /* GDT and PDA might already have been allocated if
638- this is a CPU hotplug re-insertion. */
639- if (gdt == NULL )
640- gdt = (struct desc_struct * )get_zeroed_page (GFP_KERNEL );
641-
642- if (pda == NULL )
643- pda = kmalloc_node (sizeof (* pda ), GFP_KERNEL , cpu_to_node (cpu ));
644-
645- if (unlikely (!gdt || !pda )) {
646- free_pages ((unsigned long )gdt , 0 );
647- kfree (pda );
648- return 0 ;
649- }
650- }
651-
652- cpu_gdt_descr -> address = (unsigned long )gdt ;
653- cpu_pda (cpu ) = pda ;
654-
655- return 1 ;
656- }
657-
658614/* Initial PDA used by boot CPU */
659615struct i386_pda boot_pda = {
660616 ._pda = & boot_pda ,
@@ -670,31 +626,17 @@ static inline void set_kernel_fs(void)
670626 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_PDA ) : "memory" );
671627}
672628
673- /* Initialize the CPU's GDT and PDA. The boot CPU does this for
674- itself, but secondaries find this done for them. */
675- __cpuinit int init_gdt (int cpu , struct task_struct * idle )
629+ /* Initialize the CPU's GDT and PDA. This is either the boot CPU doing itself
630+ (still using cpu_gdt_table), or a CPU doing it for a secondary which
631+ will soon come up. */
632+ __cpuinit void init_gdt (int cpu , struct task_struct * idle )
676633{
677634 struct Xgt_desc_struct * cpu_gdt_descr = & per_cpu (cpu_gdt_descr , cpu );
678- struct desc_struct * gdt ;
679- struct i386_pda * pda ;
680-
681- /* For non-boot CPUs, the GDT and PDA should already have been
682- allocated. */
683- if (!alloc_gdt (cpu )) {
684- printk (KERN_CRIT "CPU%d failed to allocate GDT or PDA\n" , cpu );
685- return 0 ;
686- }
635+ struct desc_struct * gdt = per_cpu (cpu_gdt , cpu );
636+ struct i386_pda * pda = & per_cpu (_cpu_pda , cpu );
687637
688- gdt = (struct desc_struct * )cpu_gdt_descr -> address ;
689- pda = cpu_pda (cpu );
690-
691- BUG_ON (gdt == NULL || pda == NULL );
692-
693- /*
694- * Initialize the per-CPU GDT with the boot GDT,
695- * and set up the GDT descriptor:
696- */
697638 memcpy (gdt , cpu_gdt_table , GDT_SIZE );
639+ cpu_gdt_descr -> address = (unsigned long )gdt ;
698640 cpu_gdt_descr -> size = GDT_SIZE - 1 ;
699641
700642 pack_descriptor ((u32 * )& gdt [GDT_ENTRY_PDA ].a ,
@@ -706,17 +648,12 @@ __cpuinit int init_gdt(int cpu, struct task_struct *idle)
706648 pda -> _pda = pda ;
707649 pda -> cpu_number = cpu ;
708650 pda -> pcurrent = idle ;
709-
710- return 1 ;
711651}
712652
713653void __cpuinit cpu_set_gdt (int cpu )
714654{
715655 struct Xgt_desc_struct * cpu_gdt_descr = & per_cpu (cpu_gdt_descr , cpu );
716656
717- /* Reinit these anyway, even if they've already been done (on
718- the boot CPU, this will transition from the boot gdt+pda to
719- the real ones). */
720657 load_gdt (cpu_gdt_descr );
721658 set_kernel_fs ();
722659}
@@ -804,13 +741,8 @@ void __cpuinit cpu_init(void)
804741 struct task_struct * curr = current ;
805742
806743 /* Set up the real GDT and PDA, so we can transition from the
807- boot versions. */
808- if (!init_gdt (cpu , curr )) {
809- /* failed to allocate something; not much we can do... */
810- for (;;)
811- local_irq_enable ();
812- }
813-
744+ boot_gdt_table & boot_pda. */
745+ init_gdt (cpu , curr );
814746 cpu_set_gdt (cpu );
815747 _cpu_init (cpu , curr );
816748}
0 commit comments