execmem-add-support-for-cache-of-large-rox-pages.patch removed from -mm tree
The quilt patch titled
Subject: execmem: add support for cache of large ROX pages
has been removed from the -mm tree. Its filename was
execmem-add-support-for-cache-of-large-rox-pages.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "Mike Rapoport (Microsoft)" <[email protected]>
Subject: execmem: add support for cache of large ROX pages
Date: Wed, 23 Oct 2024 19:27:10 +0300
Using large pages to map text areas reduces iTLB pressure and improves performance.
Extend execmem_alloc() with an ability to use huge pages with ROX permissions as a cache for smaller allocations.
To populate the cache, a writable large page is allocated from vmalloc with VM_ALLOW_HUGE_VMAP, filled with invalid instructions and then remapped as ROX.
The direct map alias of that large page is exculded from the direct map.
Portions of that large page are handed out to execmem_alloc() callers without any changes to the permissions.
When the memory is freed with execmem_free() it is invalidated again so that it won't contain stale instructions.
An architecture has to implement execmem_fill_trapping_insns() callback and select ARCH_HAS_EXECMEM_ROX configuration option to be able to use the ROX cache.
The cache is enabled on per-range basis when an architecture sets EXECMEM_ROX_CACHE flag in definition of an execmem_range.
---
arch/Kconfig | 8 include/linux/execmem.h | 14 + mm/execmem.c | 325 +++++++++++++++++++++++++++++++++++++- mm/internal.h | 1 mm/vmalloc.c | 5 5 files changed, 345 insertions(+), 8 deletions(-)
arch/Kconfig renamed from arch/Kconfig~execmem-add-support-for-cache-of-large-rox-pages +8 -0
@@ -1024,6 +1024,14 @@ config ARCH_WANTS_EXECMEM_LATE enough entropy for module space randomization, for instance arm64. +config ARCH_HAS_EXECMEM_ROX + bool + depends on MMU && !HIGHMEM + help + For architectures that support allocations of executable memory + with read-only execute permissions. Architecture must implement + execmem_fill_trapping_insns() callback to enable this. + config HAVE_IRQ_EXIT_ON_IRQ_STACK bool help
include/linux/execmem.h renamed from include/linux/execmem.h~execmem-add-support-for-cache-of-large-rox-pages +14 -0
@@ -53,6 +53,20 @@ enum execmem_range_flags { EXECMEM_ROX_CACHE = (1 << 1), }; +#ifdef CONFIG_ARCH_HAS_EXECMEM_ROX +/** +* execmem_fill_trapping_insns - set memory to contain instructions that +* will trap +* @ptr: pointer to memory to fill +* @size: size of the range to fill +* @writable: is the memory poited by @ptr is writable or ROX +* +* A hook for architecures to fill execmem ranges with invalid instructions. +* Architectures that use EXECMEM_ROX_CACHE must implement this. +*/ +void execmem_fill_trapping_insns (void *ptr,size_t size,bool writable); +#endif +/** * struct execmem_range - definition of an address space suitable for code and * related data allocations
mm/execmem.c renamed from mm/execmem.c~execmem-add-support-for-cache-of-large-rox-pages +317 -8
380 lines not on this page · raw message
mm/internal.h renamed from mm/internal.h~execmem-add-support-for-cache-of-large-rox-pages +1 -0
@@ -1234,6 +1234,7 @@ size_t splice_folio_into_pipe(struct pipvoid __init vmalloc_init (void );int __must_check vmap_pages_range_noflush (unsigned long addr,unsigned long end,pgprot_t prot,struct page **pages,unsigned int page_shift); +unsigned int get_vm_area_page_order (struct vm_struct *vm);#else static inline void vmalloc_init (void ) {
mm/vmalloc.c renamed from mm/vmalloc.c~execmem-add-support-for-cache-of-large-rox-pages +5 -0
@@ -3023,6 +3023,11 @@ static inline unsigned int vm_area_page_#endif } +unsigned int get_vm_area_page_order (struct vm_struct *vm) +{ +return vm_area_page_order (vm); +} +static inline void set_vm_area_page_order (struct vm_struct *vm,unsigned int order) {#ifdef CONFIG_HAVE_ARCH_HUGE_VMALLOC
_
Patches currently in -mm which might be from [email protected] are