Skip to content

Commit 601eaec

Browse files
Russell Kingctmarinas
authored andcommitted
arm64: consolidate rox page protection logic
Consolidate the arm64 decision making for the page protections used for executable pages, used by both the trampoline code and the kernel text mapping code. Acked-by: Mark Rutland <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent f679495 commit 601eaec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/arm64/mm/mmu.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,17 @@ static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end,
663663
vm_area_add_early(vma);
664664
}
665665

666+
static pgprot_t kernel_exec_prot(void)
667+
{
668+
return rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
669+
}
670+
666671
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
667672
static int __init map_entry_trampoline(void)
668673
{
669674
int i;
670675

671-
pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
676+
pgprot_t prot = kernel_exec_prot();
672677
phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start);
673678

674679
/* The trampoline is always mapped and can therefore be global */
@@ -723,7 +728,7 @@ static void __init map_kernel(pgd_t *pgdp)
723728
* mapping to install SW breakpoints. Allow this (only) when
724729
* explicitly requested with rodata=off.
725730
*/
726-
pgprot_t text_prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
731+
pgprot_t text_prot = kernel_exec_prot();
727732

728733
/*
729734
* If we have a CPU that supports BTI and a kernel built for

0 commit comments

Comments
 (0)