Skip to contentSkip to conversation

Recieve boot_param from RDI Instead of RSI

PATCH NAK Khalid Ali 3 participants 4 messages Jun 23, 2025

Subsystems (2)
lore
Share & tools
lore

Khalid Ali

author
#0 lore raw

PATCH 1/3 Recieve boot_param from RDI Instead of RSI

From: Khalid Ali <[email protected]>

Adjust the kernel entry point to recieve arguments from RDI instead of RSI.

---
 arch/x86/kernel/head_64.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/head_64.S +2 -2
index dfb5390e5c9a..d24fea15b6a6 100644
@@ -43,7 +43,7 @@ SYM_CODE_START_NOALIGN(startup_64)
 	 * for us.  These identity mapped page tables map all of the
 	 * kernel pages and possibly all of memory.
 	 *
-	 * %RSI holds the physical address of the boot_params structure
+	 * %RDI holds the physical address of the boot_params structure
 	 * provided by the bootloader. Preserve it in %R15 so C function calls
 	 * will not clobber it.
 	 *
@@ -56,7 +56,7 @@ SYM_CODE_START_NOALIGN(startup_64)
 	 * compiled to run at we first fixup the physical addresses in our page
 	 * tables and then reload them.
 	 */
-	mov	%rsi, %r15
+	mov	%rdi, %r15
 
 	/* Set up the stack for verify_cpu() */
 	leaq	__top_init_kernel_stack(%rip), %rsp
Signature · 1 line
2.49.0
reviewer Nacked-by on v1 1/3 NAK
#1 lore raw
Quoted 24 lines · Khalid Ali

From: Khalid Ali <[email protected]>

Adjust the kernel entry point to recieve arguments from RDI instead of RSI.

---
arch/x86/kernel/head_64.S | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/head_64.S +1 -1
index dfb5390e5c9a..d24fea15b6a6 100644
@@ -43,7 +43,7 @@ SYM_CODE_START_NOALIGN(startup_64)
 	 * for us.  These identity mapped page tables map all of the
 	 * kernel pages and possibly all of memory.
 	 *
-	 * %RSI holds the physical address of the boot_params structure
+	 * %RDI holds the physical address of the boot_params structure
 	 * provided by the bootloader. Preserve it in %R15 so C function calls
 	 * will not clobber it.
 	 *

arch/x86/kernel/head_64.S SYM_CODE_START_NOALIGN(startup_64) · line 62

Quoted 8 lines
arch/x86/kernel/head_64.S +1 -1
@@ -56,7 +56,7 @@ SYM_CODE_START_NOALIGN(startup_64)
 	 * compiled to run at we first fixup the physical addresses in our page
 	 * tables and then reload them.
 	 */
-	mov	%rsi, %r15
+	mov	%rdi, %r15
 
 	/* Set up the stack for verify_cpu() */
 	leaq	__top_init_kernel_stack(%rip), %rsp

This is an ABI.

author
#2 lore raw
Quoted 31 lines · Khalid Ali
Quoted 30 lines

From: Khalid Ali <[email protected]>

Adjust the kernel entry point to recieve arguments from RDI instead of RSI.

---
arch/x86/kernel/head_64.S | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/head_64.S +2 -2
index dfb5390e5c9a..d24fea15b6a6 100644
@@ -43,7 +43,7 @@ SYM_CODE_START_NOALIGN(startup_64)
       * for us.  These identity mapped page tables map all of the
       * kernel pages and possibly all of memory.
       *
-       * %RSI holds the physical address of the boot_params structure
+       * %RDI holds the physical address of the boot_params structure
       * provided by the bootloader. Preserve it in %R15 so C function calls
       * will not clobber it.
       *
@@ -56,7 +56,7 @@ SYM_CODE_START_NOALIGN(startup_64)
       * compiled to run at we first fixup the physical addresses in our page
       * tables and then reload them.
       */
-      mov     %rsi, %r15
+      mov     %rdi, %r15
 
Quoted 6 lines

arch/x86/kernel/head_64.S SYM_CODE_START_NOALIGN(startup_64) · line 62

Quoted 2 lines
arch/x86/kernel/head_64.S +0 -0
      /* Set up the stack for verify_cpu() */
      leaq    __top_init_kernel_stack(%rip), %rsp

This is an ABI.

Peter, thanks for the response but if i ask you:
What is specific reason that this patch is wrong?
Why used RSI instead of RDI at the first place?

I broke my patch reference and it became stand alone each one, however this is one of three series. This makes the entry more ABI complaint, if there is no specific reason of objection.

Thanks

#3 lore raw
Quoted 37 lines · Khalid Ali
Quoted 37 lines · Khalid Ali
Quoted 24 lines

From: Khalid Ali <[email protected]>

Adjust the kernel entry point to recieve arguments from RDI instead of RSI.

---
arch/x86/kernel/head_64.S | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/head_64.S +1 -1
index dfb5390e5c9a..d24fea15b6a6 100644
@@ -43,7 +43,7 @@ SYM_CODE_START_NOALIGN(startup_64)
       * for us.  These identity mapped page tables map all of the
       * kernel pages and possibly all of memory.
       *
-       * %RSI holds the physical address of the boot_params structure
+       * %RDI holds the physical address of the boot_params structure
       * provided by the bootloader. Preserve it in %R15 so C function calls
       * will not clobber it.
       *

arch/x86/kernel/head_64.S SYM_CODE_START_NOALIGN(startup_64) · line 62

Quoted 8 lines
arch/x86/kernel/head_64.S +1 -1
@@ -56,7 +56,7 @@ SYM_CODE_START_NOALIGN(startup_64)
       * compiled to run at we first fixup the physical addresses in our page
       * tables and then reload them.
       */
-      mov     %rsi, %r15
+      mov     %rdi, %r15
 
      /* Set up the stack for verify_cpu() */
      leaq    __top_init_kernel_stack(%rip), %rsp

This is an ABI.

Quoted 5 lines
Quoted 1 line

Peter, thanks for the response but if i ask you:
What is specific reason that this patch is wrong?
Why used RSI instead of RDI at the first place?

It is defined in Documentation/arch/x86/boot.rst

IIRC some hypervisors can boot the uncompressed image directly.

Brian Gerst