[tip: x86/cleanups] x86/build: Only align ENTRY_TEXT to PMD_SIZE if necessary
From: tip-bot2 for Hamza Mahfooz
Date: Thu Jul 09 2026 - 19:15:02 EST
The following commit has been merged into the x86/cleanups branch of tip:
Commit-ID: fa84683b892e2590401e655bebe6ba461367adc7
Gitweb: https://git.kernel.org/tip/fa84683b892e2590401e655bebe6ba461367adc7
Author: Hamza Mahfooz <hamzamahfooz@xxxxxxxxxxxxxxxxxxx>
AuthorDate: Tue, 23 Jun 2026 11:24:29 -04:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Thu, 09 Jul 2026 15:34:23 -07:00
x86/build: Only align ENTRY_TEXT to PMD_SIZE if necessary
PTI requires the begin and end of ENTRY_TEXT be aligned to PMD_SIZE. SRSO
requires srso_alias_untrain_ret to be 2M aligned. This costs between 2-4 MiB
of RAM (depending on the size of the preceding section). So, only align when
either of the two are enabled.
Co-developed-by: Jared White <jaredwhite@xxxxxxxxxxxxx>
Signed-off-by: Jared White <jaredwhite@xxxxxxxxxxxxx>
Signed-off-by: Hamza Mahfooz <hamzamahfooz@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://patch.msgid.link/20260623152430.1473481-1-hamzamahfooz@xxxxxxxxxxxxxxxxxxx
---
arch/x86/kernel/vmlinux.lds.S | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 74e336d..10caf92 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -65,9 +65,15 @@ const_cpu_current_top_of_stack = cpu_current_top_of_stack;
__end_rodata_hpage_align = .; \
__end_rodata_aligned = .;
+#if defined(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION) || defined(CONFIG_MITIGATION_SRSO)
#define ALIGN_ENTRY_TEXT_BEGIN . = ALIGN(PMD_SIZE);
#define ALIGN_ENTRY_TEXT_END . = ALIGN(PMD_SIZE);
#else
+#define ALIGN_ENTRY_TEXT_BEGIN
+#define ALIGN_ENTRY_TEXT_END
+#endif
+
+#else
#define X86_ALIGN_RODATA_BEGIN
#define X86_ALIGN_RODATA_END \