Place __kernel_entry at the beginning of text section
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
@@ -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
@@ -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
@@ -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
Quoted 8 lines · Rong Xu
Mark
__kernel_entryas ".head.text" and placeHEAD_TEXTbeforeTEXT_TEXTin the linker script. This ensures that__kernel_entrywill be placed at the beginning of text section.Drop mips from
scripts/head-object-list.txt.Signed-off-by Rong Xu <[email protected]>Reported-by Chris Packham <[email protected]>
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
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 usingarch/mips/kernel/vmlinux.lds.S +1
-0@@ -62,6 +62,7 @@ SECTIONS _text = .; /* Text and read-only data */ _stext = .; .text : { + HEAD_TEXT TEXT_TEXT SCHED_TEXT LOCK_TEXTscripts/head-object-list.txt +0
-1@@ -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.obase-commit:
3596c721c4348b2a964e43f9296a0c01509ba927
Quoted 30 lines · Chris Packham
Quoted 8 lines · Rong Xu
Mark
__kernel_entryas ".head.text" and placeHEAD_TEXTbeforeTEXT_TEXTin the linker script. This ensures that__kernel_entrywill be placed at the beginning of text section.Drop mips from
scripts/head-object-list.txt.Signed-off-by Rong Xu <[email protected]>Reported-by Chris Packham <[email protected]>Works for me on my RTL9302C based board
Tested-by Chris Packham <[email protected]>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@@ -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+ __HEADI'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__HEADannotation 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 usingarch/mips/kernel/vmlinux.lds.S +1
-0@@ -62,6 +62,7 @@ SECTIONS _text = .; /* Text and read-only data */ _stext = .; .text : { + HEAD_TEXT TEXT_TEXT SCHED_TEXT LOCK_TEXTscripts/head-object-list.txt +0
-1@@ -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.obase-commit:
3596c721c4348b2a964e43f9296a0c01509ba927
Signature · 2 lines
Best Regards Masahiro Yamada
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_entryas ".head.text" and placeHEAD_TEXTbeforeTEXT_TEXTin the linker script. This ensures that__kernel_entrywill be placed at the beginning of text section.Drop mips from
scripts/head-object-list.txt.Signed-off-by Rong Xu <[email protected]>Reported-by Chris Packham <[email protected]>Works for me on my RTL9302C based board
Tested-by Chris Packham <[email protected]>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@@ -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+ __HEADI'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__HEADannotation is applying to the .fill and__kernel_entry.Agree.
Having
__HEADright 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_stextdefinition tovmlinux.lds.S). It changed the location of_stextwhenCONFIG_NO_EXCEPT_FILLis 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 usingarch/mips/kernel/vmlinux.lds.S +1
-0@@ -62,6 +62,7 @@ SECTIONS _text = .; /* Text and read-only data */ _stext = .; .text : { + HEAD_TEXT TEXT_TEXT SCHED_TEXT LOCK_TEXTscripts/head-object-list.txt +0
-1@@ -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.oQuoted 1 line
Quoted 1 line
base-commit:
3596c721c4348b2a964e43f9296a0c01509ba927--
Best Regards
Masahiro Yamada