[PATCH v6 7/8] execmem: add support for cache of large ROX pages
Luis Chamberlain
mcgrof at kernel.org
Sat Oct 19 15:46:09 PDT 2024
On Wed, Oct 16, 2024 at 03:24:23PM +0300, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt at kernel.org>
>
> 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.
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof at kernel.org>
Luis
More information about the linux-riscv
mailing list