[RFC PATCH 25/56] x86/vmlinux.lds: Define __init_alt_end

David Kaplan
2025-10-13T14:35:53Z

With the alternative related information at the beginning of the .init
section, __init_alt_end defines the end of the alternative sections. The
memory from __init_begin to __init_alt_end must stick around to support
re-patching.

Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
arch/x86/kernel/vmlinux.lds.S | 5 +++++
arch/x86/tools/relocs.c | 1 +
2 files changed, 6 insertions(+)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index c4a0bb13d095..e02044da9971 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -262,6 +262,11 @@ SECTIONS
*(.altinstr_replacement)
}

+ /* Everything from here until __init_end is always freed */
+ . = ALIGN(PAGE_SIZE);
+ .init.alt.end : AT(ADDR(.init.alt.end) - LOAD_OFFSET) {
+ __init_alt_end = .;
+ }

INIT_TEXT_SECTION(PAGE_SIZE)

diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index e5a2b9a912d1..2054ffbf5fd4 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -71,6 +71,7 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
*/
[S_REL] =
"^(__init_(begin|end)|"
+ "__init_alt_end|"
"__x86_cpu_dev_(start|end)|"
"__alt_instructions(_end)?|"
"(__iommu_table|__apicdrivers|__smp_locks)(_end)?|"
--
2.34.1