Skip to content

Commit 13b0566

Browse files
committed
vmlinux.lds.h: CFI: Reduce alignment of jump-table to function alignment
Due to undocumented, hysterical raisins on x86, the CFI jump-table sections in .text are needlessly aligned to PMD_SIZE in the vmlinux linker script. When compiling a CFI-enabled arm64 kernel with a 64KiB page-size, a PMD maps 512MiB of virtual memory and so the .text section increases to a whopping 940MiB and blows the final Image up to 960MiB. Others report a link failure. Since the CFI jump-table requires only instruction alignment, reduce the alignment directives to function alignment for parity with other parts of the .text section. This reduces the size of the .text section for the aforementioned 64KiB page size arm64 kernel to 19MiB for a much more reasonable total Image size of 39MiB. Cc: Sami Tolvanen <[email protected]> Cc: Mark Rutland <[email protected]> Cc: "Mohan Rao .vanimina" <[email protected]> Cc: Kees Cook <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/all/CAL_GTzigiNOMYkOPX1KDnagPhJtFNqSK=1USNbS0wUL4PW6-Uw@mail.gmail.com/ Fixes: cf68fff ("add support for Clang CFI") Reviewed-by: Mark Rutland <[email protected]> Tested-by: Mark Rutland <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 05d6f6d commit 13b0566

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

include/asm-generic/vmlinux.lds.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,9 @@
543543
*/
544544
#ifdef CONFIG_CFI_CLANG
545545
#define TEXT_CFI_JT \
546-
. = ALIGN(PMD_SIZE); \
546+
ALIGN_FUNCTION(); \
547547
__cfi_jt_start = .; \
548548
*(.text..L.cfi.jumptable .text..L.cfi.jumptable.*) \
549-
. = ALIGN(PMD_SIZE); \
550549
__cfi_jt_end = .;
551550
#else
552551
#define TEXT_CFI_JT

0 commit comments

Comments
 (0)