Re: [PATCH v5 7/8] execmem: add support for cache of large ROX pages

2024-10-16 Thread Luis Chamberlain
On Wed, Oct 16, 2024 at 01:40:55PM +0300, Mike Rapoport wrote: > On Tue, Oct 15, 2024 at 01:11:54PM -0700, Luis Chamberlain wrote: > > On Tue, Oct 15, 2024 at 08:54:29AM +0300, Mike Rapoport wrote: > > > On Mon, Oct 14, 2024 at 09:09:49PM -0700, Luis Chamberlain wrote: > > > > Mike, please run this

[PATCH 1/2] um: Fix passing '-n' to linker for stub_exe

2024-10-16 Thread Nathan Chancellor
When building stub_exe with clang, there is an error because '-n' is not a recognized flag by the clang driver (which is being used to invoke the linker): clang: error: unknown argument: '-n' '-n' should be passed along to the linker, as it is the short flag for '--nmagic', so prefix it with '-

[PATCH 0/2] um: Fix a couple of issues with stub_exe when building with clang

2024-10-16 Thread Nathan Chancellor
ng '-n' to linker for stub_exe um: Disable auto variable initialization for stub_exe.c arch/um/kernel/skas/Makefile | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) --- base-commit: 41ab5fe7471ff38d2909d1c93b88197a89c6a00f change-id: 20241016-uml-fix-stub_exe-clang-cb8047

[PATCH 2/2] um: Disable auto variable initialization for stub_exe.c

2024-10-16 Thread Nathan Chancellor
When automatic variable initialization is enabled via CONFIG_INIT_STACK_ALL_{PATTERN,ZERO}, clang will insert a call to memset() to initialize an object created with __builtin_alloca(). This ultimately breaks the build when linking stub_exe because it is a standalone executable that does not includ

Re: [PATCH v6 6/8] x86/module: prepare module loading for ROX allocations of text

2024-10-16 Thread Steven Rostedt
On Wed, 16 Oct 2024 15:24:22 +0300 Mike Rapoport wrote: > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c > index 8da0e66ca22d..b498897b213c 100644 > --- a/arch/x86/kernel/ftrace.c > +++ b/arch/x86/kernel/ftrace.c > @@ -118,10 +118,13 @@ ftrace_modify_code_direct(unsigned long ip

Re: [PATCH v6 2/8] mm: vmalloc: don't account for number of nodes for HUGE_VMAP allocations

2024-10-16 Thread Uladzislau Rezki
On Wed, Oct 16, 2024 at 03:24:18PM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > vmalloc allocations with VM_ALLOW_HUGE_VMAP that do not explicitly > specify node ID will use huge pages only if size_per_node is larger than > a huge page. > Still the actual allocated memory i

Re: [PATCH v6 1/8] mm: vmalloc: group declarations depending on CONFIG_MMU together

2024-10-16 Thread Uladzislau Rezki
On Wed, Oct 16, 2024 at 03:24:17PM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > There are a couple of declarations that depend on CONFIG_MMU in > include/linux/vmalloc.h spread all over the file. > > Group them all together to improve code readability. > > No functional c

Re: [RFC PATCH v1 01/57] mm: Add macros ahead of supporting boot-time page size selection

2024-10-16 Thread Ryan Roberts
+ Albert Ou, Alexander Gordeev, Brian Cain, Guo Ren, Heiko Carstens, Michael Ellerman, Michal Simek, Palmer Dabbelt, Paul Walmsley, Vasily Gorbik, Vineet Gupta. This was a rather tricky series to get the recipients correct for and my script did not realize that "supporter" was a pseudonym for "ma

[PATCH v6 4/8] module: prepare to handle ROX allocations for text

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" In order to support ROX allocations for module text, it is necessary to handle modifications to the code, such as relocations and alternatives patching, without write access to that memory. One option is to use text patching, but this would make module loading e

[PATCH v6 5/8] arch: introduce set_direct_map_valid_noflush()

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Add an API that will allow updates of the direct/linear map for a set of physically contiguous pages. It will be used in the following patches. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Christoph Hellwig --- arch/arm64/include/asm/set_memory.h

[PATCH v6 3/8] asm-generic: introduce text-patching.h

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Several architectures support text patching, but they name the header files that declare patching functions differently. Make all such headers consistently named text-patching.h and add an empty header in asm-generic for architectures that do not support text pa

[PATCH v6 2/8] mm: vmalloc: don't account for number of nodes for HUGE_VMAP allocations

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" vmalloc allocations with VM_ALLOW_HUGE_VMAP that do not explicitly specify node ID will use huge pages only if size_per_node is larger than a huge page. Still the actual allocated memory is not distributed between nodes and there is no advantage in such approach.

[PATCH v6 8/8] x86/module: enable ROX caches for module text on 64 bit

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Enable execmem's cache of PMD_SIZE'ed pages mapped as ROX for module text allocations on 64 bit. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/Kconfig | 1 + arch/x86/mm/init.c | 37 - 2 files changed, 37 insertio

[PATCH v6 7/8] execmem: add support for cache of large ROX pages

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" 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

[PATCH v6 6/8] x86/module: prepare module loading for ROX allocations of text

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" When module text memory will be allocated with ROX permissions, the memory at the actual address where the module will live will contain invalid instructions and there will be a writable copy that contains the actual module code. Update relocations and alternati

[PATCH v6 1/8] mm: vmalloc: group declarations depending on CONFIG_MMU together

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" There are a couple of declarations that depend on CONFIG_MMU in include/linux/vmalloc.h spread all over the file. Group them all together to improve code readability. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Christoph Hellw

[PATCH v6 0/8] x86/module: use large ROX pages for text allocations

2024-10-16 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Hi, This is an updated version of execmem ROX caches. Andrew, Luis, there is a conflict with Suren's "page allocation tag compression" patches: https://lore.kernel.org/all/20241014203646.1952505-1-sur...@google.com Probably taking this via mmotm would be more

Re: [PATCH v5 7/8] execmem: add support for cache of large ROX pages

2024-10-16 Thread Mike Rapoport
On Tue, Oct 15, 2024 at 01:11:54PM -0700, Luis Chamberlain wrote: > On Tue, Oct 15, 2024 at 08:54:29AM +0300, Mike Rapoport wrote: > > On Mon, Oct 14, 2024 at 09:09:49PM -0700, Luis Chamberlain wrote: > > > Mike, please run this with kmemleak enabled and running, and also try to > > > get > > > to

Re: [PATCH v9 02/10] um: use execveat to create userspace MMs

2024-10-16 Thread Berg, Benjamin
Hi Nathan, On Tue, 2024-10-15 at 19:34 -0700, Nathan Chancellor wrote: > On Thu, Sep 19, 2024 at 02:45:03PM +0200, Benjamin Berg wrote: > ... > > diff --git a/arch/um/kernel/skas/Makefile > > b/arch/um/kernel/skas/Makefile > > index 6f86d53e3d69..fbb61968055f 100644 > > --- a/arch/um/kernel/skas/M