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

Commit 11e3a840 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Tejun Heo
Browse files

x86: split loading percpu segments from loading gdt



Impact: split out a function, no functional change

Xen needs to be able to access percpu data from very early on.  For
various reasons, it cannot also load the gdt at that time.   It does,
however, have a pefectly functional gdt at that point, so there's no
pressing need to reload the gdt.

Split the function to load the segment registers off, so Xen can call
it directly.

Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 552be871
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -769,6 +769,7 @@ extern struct desc_ptr early_gdt_descr;


extern void cpu_set_gdt(int);
extern void cpu_set_gdt(int);
extern void switch_to_new_gdt(int);
extern void switch_to_new_gdt(int);
extern void load_percpu_segment(int);
extern void cpu_init(void);
extern void cpu_init(void);


static inline unsigned long get_debugctlmsr(void)
static inline unsigned long get_debugctlmsr(void)
+12 −6
Original line number Original line Diff line number Diff line
@@ -253,6 +253,16 @@ static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)


__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;
__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;


void load_percpu_segment(int cpu)
{
#ifdef CONFIG_X86_32
	loadsegment(fs, __KERNEL_PERCPU);
#else
	loadsegment(gs, 0);
	wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu));
#endif
}

/* Current gdt points %fs at the "master" per-cpu area: after this,
/* Current gdt points %fs at the "master" per-cpu area: after this,
 * it's on the real one. */
 * it's on the real one. */
void switch_to_new_gdt(int cpu)
void switch_to_new_gdt(int cpu)
@@ -263,12 +273,8 @@ void switch_to_new_gdt(int cpu)
	gdt_descr.size = GDT_SIZE - 1;
	gdt_descr.size = GDT_SIZE - 1;
	load_gdt(&gdt_descr);
	load_gdt(&gdt_descr);
	/* Reload the per-cpu base */
	/* Reload the per-cpu base */
#ifdef CONFIG_X86_32

	loadsegment(fs, __KERNEL_PERCPU);
	load_percpu_segment(cpu);
#else
	loadsegment(gs, 0);
	wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu));
#endif
}
}


static struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
static struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};