* [PATCH 0/3] riscv: Align section markers with other archs
@ 2026-11-11 16:43 Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 1/3] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2026-11-11 16:43 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Ard Biesheuvel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Patch #3 of this series was sent out as part of a EFI series [0] that
implements generic support for carrying image info data inside the stub,
and after Sashiko found another related issue, I decided to break it out
into this series. IOW, patch #3 is a resend.
The point of these changes is to harmonize all architectures that
support EFI in terms of the section markers, so that generic zboot code
can refer to them without arch specific #ifdefs. Other generic tools
probably benefit from this too.
If the maintainers are onboard with this, kindly put it on a stable
topic branch so I can refer to it from the EFI tree.
[0] https://lore.kernel.org/all/20261110121731.2728824-12-ardb+git@google.com/
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-riscv@lists.infradead.org
Ard Biesheuvel (3):
riscv: Use _stext not _text to denote the start of kernel code
riscv: Make _text point to the start of the kernel image
riscv: Rename __init_text_end to __inittext_end like other archs
arch/riscv/include/asm/sections.h | 2 +-
arch/riscv/kernel/image-vars.h | 2 +-
arch/riscv/kernel/setup.c | 2 +-
arch/riscv/kernel/vmlinux.lds.S | 6 +++---
drivers/firmware/efi/libstub/riscv-stub.c | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] riscv: Use _stext not _text to denote the start of kernel code
2026-11-11 16:43 [PATCH 0/3] riscv: Align section markers with other archs Ard Biesheuvel
@ 2026-11-11 16:43 ` Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 2/3] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2026-11-11 16:43 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Ard Biesheuvel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
On RISC-V, _text and _stext currently refer to the same location, i.e.,
the start of the .text output section, which follows the image header
(.head.text) emitted by HEAD_TEXT_SECTION. _start is the symbol that
refers to the actual start of the image.
On most other architectures, _text refers to the start of the image, and
_stext to the start of the kernel code, and generic code (such as the
EFI stub) may start relying on this distinction.
So switch the only user of _text in arch/riscv, i.e., the "Kernel code"
resource that is exposed via /proc/iomem (and from which the "Kernel
image" resource inherits its start address), over to _stext. This is a
no-op given that both symbols currently resolve to the same address, but
it permits _text to be moved to the start of the image, making it an
alias of _start.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/kernel/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index d79f99b86033..e6112d424fde 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -91,7 +91,7 @@ static int __init add_kernel_resources(void)
* child nodes.
*/
- code_res.start = __pa_symbol(_text);
+ code_res.start = __pa_symbol(_stext);
code_res.end = __pa_symbol(_etext) - 1;
code_res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] riscv: Make _text point to the start of the kernel image
2026-11-11 16:43 [PATCH 0/3] riscv: Align section markers with other archs Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 1/3] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
@ 2026-11-11 16:43 ` Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 3/3] riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
2026-11-12 4:35 ` [PATCH 0/3] riscv: Align section markers with " Jisheng Zhang
3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2026-11-11 16:43 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Ard Biesheuvel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
On RISC-V, _text currently refers to the start of the .text output
section, which is placed after the image header (.head.text), and is
therefore equal to _stext. On most other architectures such, _text
refers to the start of the image, and is used as such by generic code,
e.g., to describe the kernel mapping in /proc/kcore and in the ELF
headers of the vmcore, and by the EFI stub.
Now that arch/riscv no longer uses _text to refer to the start of the
kernel code, move it to the start of the image so that it is equal to
_start, and the distinction between _text and _stext is the same as on
other architectures.
This also means that the image header is no longer omitted from the
/proc/kcore and vmcore kernel text mappings. Other users of _text, such
as kallsyms and ftrace, only use it as a reference point to calculate
relative offsets, and are not affected by this change.
Note that, as on arm64, _text will no longer appear in /proc/kallsyms
unless CONFIG_KALLSYMS_ALL=y, given that it now lives outside of the
[_stext, _etext) range. User space tools such as perf already fall back
to _stext in this case.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/kernel/vmlinux.lds.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 1f4f8496941a..9849a3e4d102 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -28,11 +28,11 @@ SECTIONS
/* Beginning of code and text segment */
. = LOAD_OFFSET;
_start = .;
+ _text = .;
HEAD_TEXT_SECTION
. = ALIGN(PAGE_SIZE);
.text : {
- _text = .;
_stext = .;
TEXT_TEXT
SCHED_TEXT
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] riscv: Rename __init_text_end to __inittext_end like other archs
2026-11-11 16:43 [PATCH 0/3] riscv: Align section markers with other archs Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 1/3] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 2/3] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
@ 2026-11-11 16:43 ` Ard Biesheuvel
2026-11-12 4:35 ` [PATCH 0/3] riscv: Align section markers with " Jisheng Zhang
3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2026-11-11 16:43 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Ard Biesheuvel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Align RISC-V with arm64, LoongArch and x86, and drop the underscore
between 'init' and 'text' in the section markers. This allows the value
to be captured by generic EFI stub code that can be shared between all
those architectures.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/include/asm/sections.h | 2 +-
arch/riscv/kernel/image-vars.h | 2 +-
arch/riscv/kernel/vmlinux.lds.S | 4 ++--
drivers/firmware/efi/libstub/riscv-stub.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/include/asm/sections.h b/arch/riscv/include/asm/sections.h
index a393d5035c54..4a882a28f414 100644
--- a/arch/riscv/include/asm/sections.h
+++ b/arch/riscv/include/asm/sections.h
@@ -11,7 +11,7 @@
extern char _start[];
extern char _start_kernel[];
extern char __init_data_begin[], __init_data_end[];
-extern char __init_text_begin[], __init_text_end[];
+extern char __inittext_begin[], __inittext_end[];
extern char __alt_start[], __alt_end[];
extern char __exittext_begin[], __exittext_end[];
diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h
index 7b44b94f1283..bf703eba3fa5 100644
--- a/arch/riscv/kernel/image-vars.h
+++ b/arch/riscv/kernel/image-vars.h
@@ -27,7 +27,7 @@ __efistub__start = _start;
__efistub__start_kernel = _start_kernel;
__efistub__end = _end;
__efistub__edata = _edata;
-__efistub___init_text_end = __init_text_end;
+__efistub___inittext_end = __inittext_end;
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
__efistub_sysfb_primary_display = sysfb_primary_display;
#endif
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 9849a3e4d102..ba939c7365b2 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -46,7 +46,7 @@ SECTIONS
. = ALIGN(SECTION_ALIGN);
__init_begin = .;
- __init_text_begin = .;
+ __inittext_begin = .;
.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
_sinittext = .; \
INIT_TEXT \
@@ -72,7 +72,7 @@ SECTIONS
}
__exittext_end = .;
- __init_text_end = .;
+ __inittext_end = .;
. = ALIGN(SECTION_ALIGN);
#ifdef CONFIG_EFI
. = ALIGN(PECOFF_SECTION_ALIGNMENT);
diff --git a/drivers/firmware/efi/libstub/riscv-stub.c b/drivers/firmware/efi/libstub/riscv-stub.c
index 725b634c5179..5cbc50a814e1 100644
--- a/drivers/firmware/efi/libstub/riscv-stub.c
+++ b/drivers/firmware/efi/libstub/riscv-stub.c
@@ -34,7 +34,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
efi_status_t status;
kernel_size = _edata - _start;
- kernel_codesize = __init_text_end - _start;
+ kernel_codesize = __inittext_end - _start;
kernel_memsize = kernel_size + (_end - _edata);
*image_addr = (unsigned long)_start;
*reserve_size = kernel_memsize;
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] riscv: Align section markers with other archs
2026-11-11 16:43 [PATCH 0/3] riscv: Align section markers with other archs Ard Biesheuvel
` (2 preceding siblings ...)
2026-11-11 16:43 ` [PATCH 3/3] riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
@ 2026-11-12 4:35 ` Jisheng Zhang
3 siblings, 0 replies; 5+ messages in thread
From: Jisheng Zhang @ 2026-11-12 4:35 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-arm-kernel, Ard Biesheuvel, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, linux-riscv
On Wed, Nov 11, 2026 at 05:43:46PM +0100, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Patch #3 of this series was sent out as part of a EFI series [0] that
> implements generic support for carrying image info data inside the stub,
> and after Sashiko found another related issue, I decided to break it out
> into this series. IOW, patch #3 is a resend.
>
> The point of these changes is to harmonize all architectures that
> support EFI in terms of the section markers, so that generic zboot code
> can refer to them without arch specific #ifdefs. Other generic tools
> probably benefit from this too.
>
> If the maintainers are onboard with this, kindly put it on a stable
> topic branch so I can refer to it from the EFI tree.
>
> [0] https://lore.kernel.org/all/20261110121731.2728824-12-ardb+git@google.com/
>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: Alexandre Ghiti <alex@ghiti.fr>
> Cc: linux-riscv@lists.infradead.org
For the series:
Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
>
> Ard Biesheuvel (3):
> riscv: Use _stext not _text to denote the start of kernel code
> riscv: Make _text point to the start of the kernel image
> riscv: Rename __init_text_end to __inittext_end like other archs
>
> arch/riscv/include/asm/sections.h | 2 +-
> arch/riscv/kernel/image-vars.h | 2 +-
> arch/riscv/kernel/setup.c | 2 +-
> arch/riscv/kernel/vmlinux.lds.S | 6 +++---
> drivers/firmware/efi/libstub/riscv-stub.c | 2 +-
> 5 files changed, 7 insertions(+), 7 deletions(-)
>
>
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> --
> 2.56.0.611.g1030f0b940-goog
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-12 4:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 16:43 [PATCH 0/3] riscv: Align section markers with other archs Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 1/3] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 2/3] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
2026-11-11 16:43 ` [PATCH 3/3] riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
2026-11-12 4:35 ` [PATCH 0/3] riscv: Align section markers with " Jisheng Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox