x86-64: no 2 MB padding that nothing uses. .bss is padded to 2 MB twice for SEV (AMD_MEM_ENCRYPT, off here): about 1.6 MB of zeroes. The entry text is padded to 2 MB on both sides for page-table isolation (off here): about 1.6 MB inside the kernel text. --- a/arch/x86/kernel/vmlinux.lds.S 2026-10-04 20:42:00.430388814 +0200 +++ b/arch/x86/kernel/vmlinux.lds.S 2026-10-04 21:08:01.771340631 +0200 @@ -65,8 +65,18 @@ __end_rodata_hpage_align = .; \ __end_rodata_aligned = .; +/* + * PLANCK: the entry text is PMD-aligned on both sides so that page-table isolation can map it into the + * user page tables with one large page. Without PTI the two alignments are up to 4 MB of padding + * inside the kernel text that is never freed. + */ +#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION #define ALIGN_ENTRY_TEXT_BEGIN . = ALIGN(PMD_SIZE); #define ALIGN_ENTRY_TEXT_END . = ALIGN(PMD_SIZE); +#else +#define ALIGN_ENTRY_TEXT_BEGIN . = ALIGN(PAGE_SIZE); +#define ALIGN_ENTRY_TEXT_END . = ALIGN(PAGE_SIZE); +#endif /* * This section contains data which will be mapped as decrypted. Memory @@ -76,14 +86,24 @@ * Note: We use a separate section so that only this section gets * decrypted to avoid exposing more than we wish. */ +/* + * PLANCK: the two PMD_SIZE alignments exist so that an SEV guest can remap the section decrypted with + * large pages. Without AMD_MEM_ENCRYPT nothing is ever put into it and nothing frees the padding: on a + * small kernel that is up to 2 MB of bss holding zeroes. Page alignment keeps the symbols valid. + */ +#ifdef CONFIG_AMD_MEM_ENCRYPT +#define BSS_DECRYPTED_ALIGN . = ALIGN(PMD_SIZE); +#else +#define BSS_DECRYPTED_ALIGN . = ALIGN(PAGE_SIZE); +#endif #define BSS_DECRYPTED \ - . = ALIGN(PMD_SIZE); \ + BSS_DECRYPTED_ALIGN \ __start_bss_decrypted = .; \ __pi___start_bss_decrypted = .; \ *(.bss..decrypted); \ . = ALIGN(PAGE_SIZE); \ __start_bss_decrypted_unused = .; \ - . = ALIGN(PMD_SIZE); \ + BSS_DECRYPTED_ALIGN \ __end_bss_decrypted = .; \ __pi___end_bss_decrypted = .; \