Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: ensure _stext and _etext are page-aligned

Currently we have separate ALIGN_DEBUG_RO{,_MIN} directives to align
_etext and __init_begin. While we ensure that __init_begin is
page-aligned, we do not provide the same guarantee for _etext. This is
not problematic currently as the alignment of __init_begin is sufficient
to prevent issues when we modify permissions.

Subsequent patches will assume page alignment of segments of the kernel
we wish to map with different permissions. To ensure this, move _etext
after the ALIGN_DEBUG_RO_MIN for the init section. This renders the
prior ALIGN_DEBUG_RO irrelevant, and hence it is removed. Likewise,
upgrade to ALIGN_DEBUG_RO_MIN(PAGE_SIZE) for _stext.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Jeremy Linton <jeremy.linton@arm.com>
Cc: Laura Abbott <labbott@fedoraproject.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Mark Rutland and committed by
Catalin Marinas
fca082bf 11509a30

+2 -3
+2 -3
arch/arm64/kernel/vmlinux.lds.S
··· 95 95 _text = .; 96 96 HEAD_TEXT 97 97 } 98 - ALIGN_DEBUG_RO 98 + ALIGN_DEBUG_RO_MIN(PAGE_SIZE) 99 99 .text : { /* Real text segment */ 100 100 _stext = .; /* Text and read-only data */ 101 101 __exception_text_start = .; ··· 116 116 RO_DATA(PAGE_SIZE) 117 117 EXCEPTION_TABLE(8) 118 118 NOTES 119 - ALIGN_DEBUG_RO 120 - _etext = .; /* End of text and rodata section */ 121 119 122 120 ALIGN_DEBUG_RO_MIN(PAGE_SIZE) 121 + _etext = .; /* End of text and rodata section */ 123 122 __init_begin = .; 124 123 125 124 INIT_TEXT_SECTION(8)