Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2d2f431 authored by Brian Gerst's avatar Brian Gerst Committed by Tejun Heo
Browse files

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: default avatarBrian Gerst <brgerst@gmail.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 89c9c4c5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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)
{
+1 −2
Original line number Diff line number Diff line
@@ -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
+14 −0
Original line number Diff line number Diff line
@@ -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
+0 −4
Original line number Diff line number Diff line
@@ -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 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
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);

arch/x86/kernel/smpcommon.c

deleted100644 → 0
+0 −25
Original line number Diff line number Diff line
/*
 * 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
Loading