[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251013143444.3999-24-david.kaplan@amd.com>
Date: Mon, 13 Oct 2025 09:34:11 -0500
From: David Kaplan <david.kaplan@....com>
To: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>, Ingo Molnar
<mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>,
<x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>
CC: Alexander Graf <graf@...zon.com>, Boris Ostrovsky
<boris.ostrovsky@...cle.com>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 23/56] x86/vmlinux.lds: Move alternative sections
Move the sections containing information relevant to alternative
replacements to the beginning of the .init section. This information will
need to be kept around to support dynamic mitigations, and putting it at
the start of the section makes it easier to conditionally free it.
No functional change.
Signed-off-by: David Kaplan <david.kaplan@....com>
---
arch/x86/kernel/vmlinux.lds.S | 98 +++++++++++++++++------------------
1 file changed, 49 insertions(+), 49 deletions(-)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index d7af4a64c211..e0db3f4c97df 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -211,6 +211,55 @@ SECTIONS
__init_begin = .; /* paired with __init_end */
}
+#ifdef CONFIG_MITIGATION_RETPOLINE
+ /*
+ * List of instructions that call/jmp/jcc to retpoline thunks
+ * __x86_indirect_thunk_*(). These instructions can be patched along
+ * with alternatives, after which the section can be freed.
+ */
+ . = ALIGN(8);
+ .retpoline_sites : AT(ADDR(.retpoline_sites) - LOAD_OFFSET) {
+ __retpoline_sites = .;
+ *(.retpoline_sites)
+ __retpoline_sites_end = .;
+ }
+
+ . = ALIGN(8);
+ .return_sites : AT(ADDR(.return_sites) - LOAD_OFFSET) {
+ __return_sites = .;
+ *(.return_sites)
+ __return_sites_end = .;
+ }
+
+ . = ALIGN(8);
+ .call_sites : AT(ADDR(.call_sites) - LOAD_OFFSET) {
+ __call_sites = .;
+ *(.call_sites)
+ __call_sites_end = .;
+ }
+#endif
+ /*
+ * struct alt_inst entries. From the header (alternative.h):
+ * "Alternative instructions for different CPU types or capabilities"
+ * Think locking instructions on spinlocks.
+ */
+ . = ALIGN(8);
+ .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
+ __alt_instructions = .;
+ *(.altinstructions)
+ __alt_instructions_end = .;
+ }
+
+ /*
+ * And here are the replacement instructions. The linker sticks
+ * them as binary blobs. The .altinstructions has enough data to
+ * get the address and the length of them to patch the kernel safely.
+ */
+ .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
+ *(.altinstr_replacement)
+ }
+
+
INIT_TEXT_SECTION(PAGE_SIZE)
/*
@@ -243,34 +292,6 @@ SECTIONS
}
#endif
-#ifdef CONFIG_MITIGATION_RETPOLINE
- /*
- * List of instructions that call/jmp/jcc to retpoline thunks
- * __x86_indirect_thunk_*(). These instructions can be patched along
- * with alternatives, after which the section can be freed.
- */
- . = ALIGN(8);
- .retpoline_sites : AT(ADDR(.retpoline_sites) - LOAD_OFFSET) {
- __retpoline_sites = .;
- *(.retpoline_sites)
- __retpoline_sites_end = .;
- }
-
- . = ALIGN(8);
- .return_sites : AT(ADDR(.return_sites) - LOAD_OFFSET) {
- __return_sites = .;
- *(.return_sites)
- __return_sites_end = .;
- }
-
- . = ALIGN(8);
- .call_sites : AT(ADDR(.call_sites) - LOAD_OFFSET) {
- __call_sites = .;
- *(.call_sites)
- __call_sites_end = .;
- }
-#endif
-
#ifdef CONFIG_X86_KERNEL_IBT
. = ALIGN(8);
.ibt_endbr_seal : AT(ADDR(.ibt_endbr_seal) - LOAD_OFFSET) {
@@ -289,27 +310,6 @@ SECTIONS
}
#endif
- /*
- * struct alt_inst entries. From the header (alternative.h):
- * "Alternative instructions for different CPU types or capabilities"
- * Think locking instructions on spinlocks.
- */
- . = ALIGN(8);
- .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
- __alt_instructions = .;
- *(.altinstructions)
- __alt_instructions_end = .;
- }
-
- /*
- * And here are the replacement instructions. The linker sticks
- * them as binary blobs. The .altinstructions has enough data to
- * get the address and the length of them to patch the kernel safely.
- */
- .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
- *(.altinstr_replacement)
- }
-
. = ALIGN(8);
.apicdrivers : AT(ADDR(.apicdrivers) - LOAD_OFFSET) {
__apicdrivers = .;
--
2.34.1
Powered by blists - more mailing lists