Skip to content

Commit 8f6be6d

Browse files
Brian GerstKAGA-KOKO
authored andcommitted
x86/smpboot: Remove initial_gs
Given its CPU#, each CPU can find its own per-cpu offset, and directly set GSBASE accordingly. The global variable can be eliminated. Signed-off-by: Brian Gerst <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Usama Arif <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Usama Arif <[email protected]> Tested-by: Guilherme G. Piccoli <[email protected]> Reviewed-by: David Woodhouse <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c253b64 commit 8f6be6d

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

arch/x86/include/asm/realmode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ extern struct real_mode_header *real_mode_header;
5959
extern unsigned char real_mode_blob_end[];
6060

6161
extern unsigned long initial_code;
62-
extern unsigned long initial_gs;
6362
extern unsigned long initial_stack;
6463
#ifdef CONFIG_AMD_MEM_ENCRYPT
6564
extern unsigned long initial_vc_handler;

arch/x86/kernel/acpi/sleep.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ int x86_acpi_suspend_lowlevel(void)
127127
* value is in the actual %rsp register.
128128
*/
129129
current->thread.sp = (unsigned long)temp_stack + sizeof(temp_stack);
130-
initial_gs = per_cpu_offset(smp_processor_id());
131130
smpboot_control = smp_processor_id();
132131
#endif
133132
initial_code = (unsigned long)wakeup_long64;

arch/x86/kernel/head_64.S

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,10 @@ SYM_CODE_START_NOALIGN(startup_64)
6666

6767
leaq _text(%rip), %rdi
6868

69-
/*
70-
* initial_gs points to initial fixed_percpu_data struct with storage for
71-
* the stack protector canary. Global pointer fixups are needed at this
72-
* stage, so apply them as is done in fixup_pointer(), and initialize %gs
73-
* such that the canary can be accessed at %gs:40 for subsequent C calls.
74-
*/
69+
/* Setup GSBASE to allow stack canary access for C code */
7570
movl $MSR_GS_BASE, %ecx
76-
movq initial_gs(%rip), %rax
77-
movq $_text, %rdx
78-
subq %rdx, %rax
79-
addq %rdi, %rax
80-
movq %rax, %rdx
71+
leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
72+
movl %edx, %eax
8173
shrq $32, %rdx
8274
wrmsr
8375

@@ -294,8 +286,11 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
294286
* the per cpu areas are set up.
295287
*/
296288
movl $MSR_GS_BASE,%ecx
297-
movl initial_gs(%rip),%eax
298-
movl initial_gs+4(%rip),%edx
289+
#ifndef CONFIG_SMP
290+
leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
291+
#endif
292+
movl %edx, %eax
293+
shrq $32, %rdx
299294
wrmsr
300295

301296
/* Setup and Load IDT */
@@ -437,7 +432,6 @@ SYM_CODE_END(vc_boot_ghcb)
437432
__REFDATA
438433
.balign 8
439434
SYM_DATA(initial_code, .quad x86_64_start_kernel)
440-
SYM_DATA(initial_gs, .quad INIT_PER_CPU_VAR(fixed_percpu_data))
441435
#ifdef CONFIG_AMD_MEM_ENCRYPT
442436
SYM_DATA(initial_vc_handler, .quad handle_vc_boot_ghcb)
443437
#endif

arch/x86/kernel/smpboot.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,6 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
10591059
#ifdef CONFIG_X86_32
10601060
/* Stack for startup_32 can be just as for start_secondary onwards */
10611061
per_cpu(pcpu_hot.top_of_stack, cpu) = task_top_of_stack(idle);
1062-
#else
1063-
initial_gs = per_cpu_offset(cpu);
10641062
#endif
10651063
return 0;
10661064
}

0 commit comments

Comments
 (0)