From: Ard Biesheuvel <[email protected]> Wire up the existing support for the execmem ROX cache on arm64, so that it will be used for module .text and .init.text regions. This will be relied upon by a subsequent patch in order to allocate those regions from a single chunk of memory.
Signed-off-by: Ard Biesheuvel <[email protected]> --- arch/arm64/Kconfig | 1 + arch/arm64/mm/init.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b3afe0688919..080b97b0bbd5 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -27,6 +27,7 @@ config ARM64 select ARCH_HAS_DMA_OPS if XEN select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI + select ARCH_HAS_EXECMEM_ROX select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 97987f850a33..e6c98045046e 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -531,7 +531,8 @@ struct execmem_info __init *execmem_arch_setup(void) [EXECMEM_DEFAULT] = { .start = start, .end = end, - .pgprot = PAGE_KERNEL, + .pgprot = PAGE_KERNEL_ROX, + .flags = EXECMEM_ROX_CACHE, .alignment = 1, .fallback_start = fallback_start, .fallback_end = fallback_end, @@ -548,9 +549,25 @@ struct execmem_info __init *execmem_arch_setup(void) .pgprot = PAGE_KERNEL, .alignment = 1, }, + [EXECMEM_MODULE_DATA] = { + .start = start, + .end = end, + .pgprot = PAGE_KERNEL, + .alignment = 1, + .fallback_start = fallback_start, + .fallback_end = fallback_end, + }, }, }; + if (!system_supports_bbml2_noabort()) + execmem_info.ranges[EXECMEM_DEFAULT].flags |= EXECMEM_NO_HUGE_VMAP; + return &execmem_info; } + +void execmem_fill_trapping_insns(void *ptr, size_t size) +{ + memset32(ptr, AARCH64_BREAK_FAULT, size / sizeof(__le32)); +} #endif /* CONFIG_EXECMEM */ -- 2.55.0.860.g4b6b3295ed-goog
