mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
arm64: Reduce the kernel executable pages
When creating the kernel page tables we create them all executable to allow the kernel to boot. We can reduce the number of l2 blocks or l3 pages created as executable by looking where the end of the .text section is and only marking memory up to this as executable (rounded up to the block/page size). Memory after the .text is marked as execute never as it will be data. Reviewed by: alc Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45063
This commit is contained in:
parent
95059bef24
commit
e6928c33f6
1 changed files with 18 additions and 1 deletions
|
|
@ -598,7 +598,14 @@ common:
|
|||
#endif
|
||||
|
||||
/* Get the number of blocks/pages to allocate, rounded down */
|
||||
lsr x10, x8, #(PTE_SHIFT)
|
||||
lsr x14, x8, #(PTE_SHIFT)
|
||||
|
||||
ldr x25, =etext
|
||||
ldr x8, =((1 << PTE_SHIFT) - 1)
|
||||
add x25, x25, x8
|
||||
mov x8, #(KERNBASE)
|
||||
sub x25, x25, x8
|
||||
lsr x25, x25, #(PTE_SHIFT)
|
||||
|
||||
/* Create the kernel space PTE table */
|
||||
adrp x6, LL_PAGE_TABLE
|
||||
|
|
@ -606,6 +613,16 @@ common:
|
|||
mov x7, #(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
|
||||
mov x8, #(KERNBASE)
|
||||
mov x9, x28
|
||||
mov x10, x25
|
||||
bl BUILD_PTE_FUNC
|
||||
|
||||
/* Create the kernel space XN PTE table */
|
||||
lsl x10, x25, #(PTE_SHIFT)
|
||||
ldr x7, =(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK) | ATTR_S1_XN)
|
||||
ldr x8, =(KERNBASE)
|
||||
add x8, x8, x10
|
||||
add x9, x28, x10
|
||||
sub x10, x14, x25
|
||||
bl BUILD_PTE_FUNC
|
||||
|
||||
#undef PTE_SHIFT
|
||||
|
|
|
|||
Loading…
Reference in a new issue