Skip to contentSkip to conversation

Place __kernel_entry at the beginning of text section

PATCH Superseded Rong Xu 3 participants 4 messages Nov 25, 2024 – Nov 26, 2024 MIPS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Rong Xu

author
#0 lore raw

PATCH 1/1 Place __kernel_entry at the beginning of text section

Mark __kernel_entry as ".head.text" and place HEAD_TEXT before TEXT_TEXT in the linker script. This ensures that __kernel_entry will be placed at the beginning of text section.

Drop mips from scripts/head-object-list.txt.

---
 arch/mips/kernel/head.S        | 1 +
 arch/mips/kernel/vmlinux.lds.S | 1 +
 scripts/head-object-list.txt   | 1 -
 3 files changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/head.S +1 -0
index e90695b2b60e..6d5fc498c6f9 100644
@@ -26,6 +26,7 @@
 
 #include <kernel-entry-init.h>
 
+	__HEAD
 	/*
 	 * For the moment disable interrupts, mark the kernel mode and
 	 * set ST0_KX so that the CPU does not spit fire when using
arch/mips/kernel/vmlinux.lds.S +1 -0
index d575f945d422..c9c1ba85ac7b 100644
@@ -62,6 +62,7 @@ SECTIONS
 	_text = .;	/* Text and read-only data */
 	_stext = .;
 	.text : {
+		HEAD_TEXT
 		TEXT_TEXT
 		SCHED_TEXT
 		LOCK_TEXT
scripts/head-object-list.txt +0 -1
index fd5d00bac447..f12b4a7b8406 100644
@@ -23,7 +23,6 @@ arch/m68k/coldfire/head.o
 arch/m68k/kernel/head.o
 arch/m68k/kernel/sun3-head.o
 arch/microblaze/kernel/head.o
-arch/mips/kernel/head.o
 arch/nios2/kernel/head.o
 arch/openrisc/kernel/head.o
 arch/parisc/kernel/head.o

base-commit: 3596c721c4348b2a964e43f9296a0c01509ba927

Signature · 1 line
2.47.0.338.g60cca15819-goog
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Rong Xu

Mark __kernel_entry as ".head.text" and place HEAD_TEXT before TEXT_TEXT in the linker script. This ensures that __kernel_entry will be placed at the beginning of text section.

Drop mips from scripts/head-object-list.txt.

Works for me on my RTL9302C based board

Quoted 11 lines
---
  arch/mips/kernel/head.S        | 1 +
  arch/mips/kernel/vmlinux.lds.S | 1 +
  scripts/head-object-list.txt   | 1 -
  3 files changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/head.S +0 -0
index e90695b2b60e..6d5fc498c6f9 100644

arch/mips/kernel/head.S line 29

Quoted 4 lines
arch/mips/kernel/head.S +1 -0
@@ -26,6 +26,7 @@
 
  #include <kernel-entry-init.h>
 
+	__HEAD

I'm not and expert on any of this but... should this go below the setup_c0_status_* macros (just before the CONFIG_NO_EXCEPT_FILL) line? I don't think it makes any actual difference but as a reader it feels more logical that the __HEAD annotation is applying to the .fill and __kernel_entry.

Quoted 29 lines
arch/mips/kernel/head.S +0 -0
  	/*
  	 * For the moment disable interrupts, mark the kernel mode and
  	 * set ST0_KX so that the CPU does not spit fire when using
arch/mips/kernel/vmlinux.lds.S +1 -0
index d575f945d422..c9c1ba85ac7b 100644
@@ -62,6 +62,7 @@ SECTIONS
  	_text = .;	/* Text and read-only data */
  	_stext = .;
  	.text : {
+		HEAD_TEXT
  		TEXT_TEXT
  		SCHED_TEXT
  		LOCK_TEXT
scripts/head-object-list.txt +0 -1
index fd5d00bac447..f12b4a7b8406 100644
@@ -23,7 +23,6 @@ arch/m68k/coldfire/head.o
  arch/m68k/kernel/head.o
  arch/m68k/kernel/sun3-head.o
  arch/microblaze/kernel/head.o
-arch/mips/kernel/head.o
  arch/nios2/kernel/head.o
  arch/openrisc/kernel/head.o
  arch/parisc/kernel/head.o

base-commit: 3596c721c4348b2a964e43f9296a0c01509ba927

#2 lore raw
Quoted 30 lines · Chris Packham
Quoted 8 lines · Rong Xu

Mark __kernel_entry as ".head.text" and place HEAD_TEXT before TEXT_TEXT in the linker script. This ensures that __kernel_entry will be placed at the beginning of text section.

Drop mips from scripts/head-object-list.txt.

Works for me on my RTL9302C based board

Quoted 14 lines
---
  arch/mips/kernel/head.S        | 1 +
  arch/mips/kernel/vmlinux.lds.S | 1 +
  scripts/head-object-list.txt   | 1 -
  3 files changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/head.S +0 -0
index e90695b2b60e..6d5fc498c6f9 100644
@@ -26,6 +26,7 @@
 
  #include <kernel-entry-init.h>
 
Quoted 7 lines

arch/mips/kernel/head.S line 29

Quoted 1 line
arch/mips/kernel/head.S +1 -0
+     __HEAD

I'm not and expert on any of this but... should this go below the setup_c0_status_* macros (just before the CONFIG_NO_EXCEPT_FILL) line? I don't think it makes any actual difference but as a reader it feels more logical that the __HEAD annotation is applying to the .fill and __kernel_entry.

Agree.

Having __HEAD right before the allocated code would be better.

We have one more section marker, __REF, some lines below. This is placed right before the affected code.

Rong, could please send v2 as Chris suggested?

Then, I will insert this to my tree to avoid regression.

I will drop the previous commit
(MIPS: move _stext definition to vmlinux.lds.S). It changed the location of _stext when CONFIG_NO_EXCEPT_FILL is disabled.

Thanks.

Quoted 30 lines
Quoted 30 lines
arch/mips/kernel/head.S +0 -0
      /*
       * For the moment disable interrupts, mark the kernel mode and
       * set ST0_KX so that the CPU does not spit fire when using
arch/mips/kernel/vmlinux.lds.S +1 -0
index d575f945d422..c9c1ba85ac7b 100644
@@ -62,6 +62,7 @@ SECTIONS
      _text = .;      /* Text and read-only data */
      _stext = .;
      .text : {
+             HEAD_TEXT
              TEXT_TEXT
              SCHED_TEXT
              LOCK_TEXT
scripts/head-object-list.txt +0 -1
index fd5d00bac447..f12b4a7b8406 100644
@@ -23,7 +23,6 @@ arch/m68k/coldfire/head.o
  arch/m68k/kernel/head.o
  arch/m68k/kernel/sun3-head.o
  arch/microblaze/kernel/head.o
-arch/mips/kernel/head.o
  arch/nios2/kernel/head.o
  arch/openrisc/kernel/head.o
  arch/parisc/kernel/head.o

base-commit: 3596c721c4348b2a964e43f9296a0c01509ba927

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#3 lore raw

Thanks Masahiro and Chris for the review!

I just sent out patch v2. I verified that v2 has pretty much the same layout (except for
some debug info caused layout changes).

-Rong

Quoted 101 lines · Masahiro Yamada
Quoted 30 lines · Chris Packham
Quoted 8 lines · Rong Xu

Mark __kernel_entry as ".head.text" and place HEAD_TEXT before TEXT_TEXT in the linker script. This ensures that __kernel_entry will be placed at the beginning of text section.

Drop mips from scripts/head-object-list.txt.

Works for me on my RTL9302C based board

Quoted 14 lines
---
  arch/mips/kernel/head.S        | 1 +
  arch/mips/kernel/vmlinux.lds.S | 1 +
  scripts/head-object-list.txt   | 1 -
  3 files changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/head.S +0 -0
index e90695b2b60e..6d5fc498c6f9 100644
@@ -26,6 +26,7 @@
 
  #include <kernel-entry-init.h>
 
Quoted 7 lines

arch/mips/kernel/head.S line 29

Quoted 1 line
arch/mips/kernel/head.S +1 -0
+     __HEAD

I'm not and expert on any of this but... should this go below the setup_c0_status_* macros (just before the CONFIG_NO_EXCEPT_FILL) line? I don't think it makes any actual difference but as a reader it feels more logical that the __HEAD annotation is applying to the .fill and __kernel_entry.

Agree.

Having __HEAD right before the allocated code would be better.

We have one more section marker, __REF, some lines below. This is placed right before the affected code.

Rong, could please send v2 as Chris suggested?

Then, I will insert this to my tree to avoid regression.

I will drop the previous commit
(MIPS: move _stext definition to vmlinux.lds.S). It changed the location of _stext when CONFIG_NO_EXCEPT_FILL is disabled.

Thanks.

Quoted 29 lines
Quoted 29 lines
arch/mips/kernel/head.S +0 -0
      /*
       * For the moment disable interrupts, mark the kernel mode and
       * set ST0_KX so that the CPU does not spit fire when using
arch/mips/kernel/vmlinux.lds.S +1 -0
index d575f945d422..c9c1ba85ac7b 100644
@@ -62,6 +62,7 @@ SECTIONS
      _text = .;      /* Text and read-only data */
      _stext = .;
      .text : {
+             HEAD_TEXT
              TEXT_TEXT
              SCHED_TEXT
              LOCK_TEXT
scripts/head-object-list.txt +0 -1
index fd5d00bac447..f12b4a7b8406 100644
@@ -23,7 +23,6 @@ arch/m68k/coldfire/head.o
  arch/m68k/kernel/head.o
  arch/m68k/kernel/sun3-head.o
  arch/microblaze/kernel/head.o
-arch/mips/kernel/head.o
  arch/nios2/kernel/head.o
  arch/openrisc/kernel/head.o
  arch/parisc/kernel/head.o
Quoted 1 line
Quoted 1 line

base-commit: 3596c721c4348b2a964e43f9296a0c01509ba927

--
Best Regards
Masahiro Yamada