Skip to contentSkip to conversation

x86/head_64: move parameter close to call function

PATCH In review Wei Yang 2 participants 3 messages Mar 15, 2024 – Mar 16, 2024 x86

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 x86/head_64: move parameter close to call function

startup_64_setup_env is first introduced by 'commit 866b556efa12 ("x86/head/64: Install startup GDT")'. Then 'commit 469693d8f622 ("x86/head/64: Re-enable stack protection")' insert some code which leverage %rdi, which is removed by 'commit 8f6be6d870e8 ("x86/smpboot:
Remove initial_gs")'.

This left the parameter of startup_64_setup_env a little far away from where it is used. Let's move them together for better understanding.

CC Joerg Roedel <[email protected]>
CC Michael Roth <[email protected]>
CC Brian Gerst <[email protected]>
CC Ard Biesheuvel <[email protected]>
---
 arch/x86/kernel/head_64.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/head_64.S +1 -2
index 3dbd05f93859..5fb8bb7cdabe 100644
@@ -69,8 +69,6 @@ SYM_CODE_START_NOALIGN(startup_64)
 	/* Set up the stack for verify_cpu() */
 	leaq	(__end_init_task - TOP_OF_KERNEL_STACK_PADDING - PTREGS_SIZE)(%rip), %rsp
 
-	leaq	_text(%rip), %rdi
-
 	/* Setup GSBASE to allow stack canary access for C code */
 	movl	$MSR_GS_BASE, %ecx
 	leaq	INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
@@ -78,6 +76,7 @@ SYM_CODE_START_NOALIGN(startup_64)
 	shrq	$32,  %rdx
 	wrmsr
 
+	leaq	_text(%rip), %rdi
 	call	startup_64_setup_env
 
 	/* Now switch to __KERNEL_CS so IRET works reliably */
Signature · 1 line
2.34.1
#1 lore raw

Hello Richard,

Quoted 10 lines · Wei Yang

startup_64_setup_env is first introduced by 'commit 866b556efa12 ("x86/head/64: Install startup GDT")'. Then 'commit 469693d8f622 ("x86/head/64: Re-enable stack protection")' insert some code which leverage %rdi, which is removed by 'commit 8f6be6d870e8 ("x86/smpboot:
Remove initial_gs")'.

This left the parameter of startup_64_setup_env a little far away from where it is used. Let's move them together for better understanding.

Quoted 9 lines
CC Joerg Roedel <[email protected]>
CC Michael Roth <[email protected]>
CC Brian Gerst <[email protected]>
CC Ard Biesheuvel <[email protected]>
---
 arch/x86/kernel/head_64.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

The code that you are fixing here no longer exists.

If you are going to send patches in the middle of the merge window, please make sure that you are at least up to date with Linus's tree at the time you send the patch.

Quoted 24 lines
arch/x86/kernel/head_64.S +1 -3
index 3dbd05f93859..5fb8bb7cdabe 100644
@@ -69,8 +69,6 @@ SYM_CODE_START_NOALIGN(startup_64)
        /* Set up the stack for verify_cpu() */
        leaq    (__end_init_task - TOP_OF_KERNEL_STACK_PADDING - PTREGS_SIZE)(%rip), %rsp
 
-       leaq    _text(%rip), %rdi
-
        /* Setup GSBASE to allow stack canary access for C code */
        movl    $MSR_GS_BASE, %ecx
        leaq    INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
@@ -78,6 +76,7 @@ SYM_CODE_START_NOALIGN(startup_64)
        shrq    $32,  %rdx
        wrmsr
 
+       leaq    _text(%rip), %rdi
        call    startup_64_setup_env
 
        /* Now switch to __KERNEL_CS so IRET works reliably */
--

2.34.1

author
#2 lore raw
Quoted 23 lines · Ard Biesheuvel

Hello Richard,

Quoted 10 lines · Wei Yang

startup_64_setup_env is first introduced by 'commit 866b556efa12 ("x86/head/64: Install startup GDT")'. Then 'commit 469693d8f622 ("x86/head/64: Re-enable stack protection")' insert some code which leverage %rdi, which is removed by 'commit 8f6be6d870e8 ("x86/smpboot:
Remove initial_gs")'.

This left the parameter of startup_64_setup_env a little far away from where it is used. Let's move them together for better understanding.

Quoted 9 lines
CC Joerg Roedel <[email protected]>
CC Michael Roth <[email protected]>
CC Brian Gerst <[email protected]>
CC Ard Biesheuvel <[email protected]>
---
 arch/x86/kernel/head_64.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 6 lines

The code that you are fixing here no longer exists.

If you are going to send patches in the middle of the merge window, please make sure that you are at least up to date with Linus's tree at the time you send the patch.

Thanks, will do it next time.

Signature · 2 lines
Wei Yang
Help you, Help me