Commit f32ff538 authored by Tejun Heo's avatar Tejun Heo Committed by Ingo Molnar

x86: load pointer to pda into %gs while brining up a CPU

[ Based on original patch from Christoph Lameter and Mike Travis. ]

CPU startup code in head_64.S loaded address of a zero page into %gs
for temporary use till pda is loaded but address to the actual pda is
available at the point.  Load the real address directly instead.

This will help unifying percpu and pda handling later on.

This patch is mostly taken from Mike Travis' "x86_64: Fold pda into
per cpu area" patch.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 3e5d8f97
...@@ -13,6 +13,7 @@ extern unsigned char *trampoline_base; ...@@ -13,6 +13,7 @@ extern unsigned char *trampoline_base;
extern unsigned long init_rsp; extern unsigned long init_rsp;
extern unsigned long initial_code; extern unsigned long initial_code;
extern unsigned long initial_gs;
#define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE) #define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE)
#define TRAMPOLINE_BASE 0x6000 #define TRAMPOLINE_BASE 0x6000
......
...@@ -101,6 +101,7 @@ int acpi_save_state_mem(void) ...@@ -101,6 +101,7 @@ int acpi_save_state_mem(void)
stack_start.sp = temp_stack + sizeof(temp_stack); stack_start.sp = temp_stack + sizeof(temp_stack);
early_gdt_descr.address = early_gdt_descr.address =
(unsigned long)get_cpu_gdt_table(smp_processor_id()); (unsigned long)get_cpu_gdt_table(smp_processor_id());
initial_gs = (unsigned long)cpu_pda(smp_processor_id());
#endif #endif
initial_code = (unsigned long)wakeup_long64; initial_code = (unsigned long)wakeup_long64;
saved_magic = 0x123456789abcdef0; saved_magic = 0x123456789abcdef0;
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#include <asm/bios_ebda.h> #include <asm/bios_ebda.h>
#include <asm/trampoline.h> #include <asm/trampoline.h>
/* boot cpu pda */ /* boot cpu pda, referenced by head_64.S to initialize %gs for boot CPU */
static struct x8664_pda _boot_cpu_pda; struct x8664_pda _boot_cpu_pda;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* /*
......
...@@ -243,12 +243,15 @@ ENTRY(secondary_startup_64) ...@@ -243,12 +243,15 @@ ENTRY(secondary_startup_64)
movl %eax,%fs movl %eax,%fs
movl %eax,%gs movl %eax,%gs
/* /* Set up %gs.
* Setup up a dummy PDA. this is just for some early bootup code *
* that does in_interrupt() * %gs should point to the pda. For initial boot, make %gs point
* to the _boot_cpu_pda in data section. For a secondary CPU,
* initial_gs should be set to its pda address before the CPU runs
* this code.
*/ */
movl $MSR_GS_BASE,%ecx movl $MSR_GS_BASE,%ecx
movq $empty_zero_page,%rax movq initial_gs(%rip),%rax
movq %rax,%rdx movq %rax,%rdx
shrq $32,%rdx shrq $32,%rdx
wrmsr wrmsr
...@@ -274,6 +277,8 @@ ENTRY(secondary_startup_64) ...@@ -274,6 +277,8 @@ ENTRY(secondary_startup_64)
.align 8 .align 8
ENTRY(initial_code) ENTRY(initial_code)
.quad x86_64_start_kernel .quad x86_64_start_kernel
ENTRY(initial_gs)
.quad _boot_cpu_pda
__FINITDATA __FINITDATA
ENTRY(stack_start) ENTRY(stack_start)
......
...@@ -854,6 +854,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) ...@@ -854,6 +854,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
#else #else
cpu_pda(cpu)->pcurrent = c_idle.idle; cpu_pda(cpu)->pcurrent = c_idle.idle;
clear_tsk_thread_flag(c_idle.idle, TIF_FORK); clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
initial_gs = (unsigned long)cpu_pda(cpu);
#endif #endif
early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
initial_code = (unsigned long)start_secondary; initial_code = (unsigned long)start_secondary;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment