mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 09:31:50 +00:00
x86: load new GDT after setting up boot cpu per-cpu area
Impact: sync 32 and 64-bit code Merge load_gs_base() into switch_to_new_gdt(). Load the GDT and per-cpu state for the boot cpu when its new area is set up. Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
1825b8edc2
commit
2697fbd5fa
@ -394,11 +394,6 @@ union irq_stack_union {
|
|||||||
|
|
||||||
DECLARE_PER_CPU(union irq_stack_union, irq_stack_union);
|
DECLARE_PER_CPU(union irq_stack_union, irq_stack_union);
|
||||||
DECLARE_PER_CPU(char *, irq_stack_ptr);
|
DECLARE_PER_CPU(char *, irq_stack_ptr);
|
||||||
|
|
||||||
static inline void load_gs_base(int cpu)
|
|
||||||
{
|
|
||||||
wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu));
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void print_cpu_info(struct cpuinfo_x86 *);
|
extern void print_cpu_info(struct cpuinfo_x86 *);
|
||||||
|
@ -258,12 +258,17 @@ __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;
|
|||||||
void switch_to_new_gdt(void)
|
void switch_to_new_gdt(void)
|
||||||
{
|
{
|
||||||
struct desc_ptr gdt_descr;
|
struct desc_ptr gdt_descr;
|
||||||
|
int cpu = smp_processor_id();
|
||||||
|
|
||||||
gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
|
gdt_descr.address = (long)get_cpu_gdt_table(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 */
|
||||||
#ifdef CONFIG_X86_32
|
#ifdef CONFIG_X86_32
|
||||||
asm("mov %0, %%fs" : : "r" (__KERNEL_PERCPU) : "memory");
|
loadsegment(fs, __KERNEL_PERCPU);
|
||||||
|
#else
|
||||||
|
loadsegment(gs, 0);
|
||||||
|
wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,10 +973,6 @@ void __cpuinit cpu_init(void)
|
|||||||
struct task_struct *me;
|
struct task_struct *me;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
loadsegment(fs, 0);
|
|
||||||
loadsegment(gs, 0);
|
|
||||||
load_gs_base(cpu);
|
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
if (cpu != 0 && percpu_read(node_number) == 0 &&
|
if (cpu != 0 && percpu_read(node_number) == 0 &&
|
||||||
cpu_to_node(cpu) != NUMA_NO_NODE)
|
cpu_to_node(cpu) != NUMA_NO_NODE)
|
||||||
@ -993,6 +994,8 @@ void __cpuinit cpu_init(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
switch_to_new_gdt();
|
switch_to_new_gdt();
|
||||||
|
loadsegment(fs, 0);
|
||||||
|
|
||||||
load_idt((const struct desc_ptr *)&idt_descr);
|
load_idt((const struct desc_ptr *)&idt_descr);
|
||||||
|
|
||||||
memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
|
memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
|
||||||
|
@ -112,14 +112,14 @@ void __init setup_per_cpu_areas(void)
|
|||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
per_cpu(x86_cpu_to_node_map, cpu) =
|
per_cpu(x86_cpu_to_node_map, cpu) =
|
||||||
early_per_cpu_map(x86_cpu_to_node_map, cpu);
|
early_per_cpu_map(x86_cpu_to_node_map, cpu);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Up to this point, the boot CPU has been using .data.init
|
* Up to this point, the boot CPU has been using .data.init
|
||||||
* area. Reload %gs offset for the boot CPU.
|
* area. Reload any changed state for the boot CPU.
|
||||||
*/
|
*/
|
||||||
if (cpu == boot_cpu_id)
|
if (cpu == boot_cpu_id)
|
||||||
load_gs_base(cpu);
|
switch_to_new_gdt();
|
||||||
#endif
|
|
||||||
|
|
||||||
DBG("PERCPU: cpu %4d %p\n", cpu, ptr);
|
DBG("PERCPU: cpu %4d %p\n", cpu, ptr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user