[PATCH v5 03/15] nios2: define virtual address space for modules

2024-04-22 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" nios2 uses kmalloc() to implement module_alloc() because CALL26/PCREL26 cannot reach all of vmalloc address space. Define module space as 32MiB below the kernel base and switch nios2 to use vmalloc for module allocations. Suggested-by: Thomas Gleix

[PATCH v5 02/15] mips: module: rename MODULE_START to MODULES_VADDR

2024-04-22 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" and MODULE_END to MODULES_END to match other architectures that define custom address space for modules. Signed-off-by: Mike Rapoport (IBM) --- arch/mips/include/asm/pgtable-64.h | 4 ++-- arch/mips/kernel/module.c | 4 ++-- arch/mips/

[PATCH v5 01/15] arm64: module: remove unneeded call to kasan_alloc_module_shadow()

2024-04-22 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Since commit f6f37d9320a1 ("arm64: select KASAN_VMALLOC for SW/HW_TAGS modes") KASAN_VMALLOC is always enabled when KASAN is on. This means that allocations in module_alloc() will be tracked by KASAN protection for vmalloc() and that kasan

[PATCH v5 00/15] mm: jit/text allocator

2024-04-22 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Hi, Since v3 I looked into making execmem more of an utility toolbox, as we discussed at LPC with Mark Rutland, but it was getting more hairier than having a struct describing architecture constraints and a type identifying the consumer of execmem. And

Re: [PATCH v4 14/15] kprobes: remove dependency on CONFIG_MODULES

2024-04-20 Thread Mike Rapoport
On Sat, Apr 20, 2024 at 06:15:00PM +0900, Masami Hiramatsu wrote: > On Sat, 20 Apr 2024 10:33:38 +0300 > Mike Rapoport wrote: > > > On Fri, Apr 19, 2024 at 03:59:40PM +, Christophe Leroy wrote: > > > > > > > > > Le 19/04/2024 à 17:49,

Re: [PATCH v4 14/15] kprobes: remove dependency on CONFIG_MODULES

2024-04-20 Thread Mike Rapoport
On Fri, Apr 19, 2024 at 03:59:40PM +, Christophe Leroy wrote: > > > Le 19/04/2024 à 17:49, Mike Rapoport a écrit : > > Hi Masami, > > > > On Thu, Apr 18, 2024 at 06:16:15AM +0900, Masami Hiramatsu wrote: > >> Hi Mike, > >> > >> On Thu

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-19 Thread Mike Rapoport
On Fri, Apr 19, 2024 at 02:42:16PM -0700, Song Liu wrote: > On Fri, Apr 19, 2024 at 1:00 PM Mike Rapoport wrote: > > > > On Fri, Apr 19, 2024 at 10:32:39AM -0700, Song Liu wrote: > > > On Fri, Apr 19, 2024 at 10:03 AM Mike Rapoport wrote: > > >

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-19 Thread Mike Rapoport
On Fri, Apr 19, 2024 at 10:32:39AM -0700, Song Liu wrote: > On Fri, Apr 19, 2024 at 10:03 AM Mike Rapoport wrote: > [...] > > > > > > > > [1] https://lore.kernel.org/all/20240411160526.2093408-1-r...@kernel.org > > > > > > For the ROX to work, w

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-19 Thread Mike Rapoport
On Fri, Apr 19, 2024 at 08:54:40AM -0700, Song Liu wrote: > On Thu, Apr 18, 2024 at 11:56 PM Mike Rapoport wrote: > > > > On Thu, Apr 18, 2024 at 02:01:22PM -0700, Song Liu wrote: > > > On Thu, Apr 18, 2024 at 10:54 AM Mike Rapoport wrote: > > > > > > &g

Re: [PATCH v4 14/15] kprobes: remove dependency on CONFIG_MODULES

2024-04-19 Thread Mike Rapoport
Hi Masami, On Thu, Apr 18, 2024 at 06:16:15AM +0900, Masami Hiramatsu wrote: > Hi Mike, > > On Thu, 11 Apr 2024 19:00:50 +0300 > Mike Rapoport wrote: > > > From: "Mike Rapoport (IBM)" > > > > kprobes depended on CONFIG_MODULES because it has to a

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-19 Thread Mike Rapoport
On Thu, Apr 18, 2024 at 02:01:22PM -0700, Song Liu wrote: > On Thu, Apr 18, 2024 at 10:54 AM Mike Rapoport wrote: > > > > On Thu, Apr 18, 2024 at 09:13:27AM -0700, Song Liu wrote: > > > On Thu, Apr 18, 2024 at 8:37 AM Mike Rapoport wrote: > > > > > > >

Re: [RFC PATCH 3/7] module: [

2024-04-18 Thread Mike Rapoport
On Thu, Apr 18, 2024 at 10:31:16PM +0300, Nadav Amit wrote: > > > On 18 Apr 2024, at 13:20, Mike Rapoport wrote: > > > > On Tue, Apr 16, 2024 at 12:36:08PM +0300, Nadav Amit wrote: > >> > >> > >> > >> I might be missing something,

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-18 Thread Mike Rapoport
On Thu, Apr 18, 2024 at 09:13:27AM -0700, Song Liu wrote: > On Thu, Apr 18, 2024 at 8:37 AM Mike Rapoport wrote: > > > > > > > > I'm looking at execmem_types more as definition of the consumers, maybe > > > > I > > > > should have named the enum

Re: [PATCH v4 14/15] kprobes: remove dependency on CONFIG_MODULES

2024-04-18 Thread Mike Rapoport
Hi Masami, On Thu, Apr 18, 2024 at 06:16:15AM +0900, Masami Hiramatsu wrote: > Hi Mike, > > On Thu, 11 Apr 2024 19:00:50 +0300 > Mike Rapoport wrote: > > > From: "Mike Rapoport (IBM)" > > > > kprobes depended on CONFIG_MODULES because it has to a

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-18 Thread Mike Rapoport
On Wed, Apr 17, 2024 at 04:32:49PM -0700, Song Liu wrote: > On Tue, Apr 16, 2024 at 12:23 AM Mike Rapoport wrote: > > > > On Mon, Apr 15, 2024 at 06:36:39PM +0100, Mark Rutland wrote: > > > On Mon, Apr 15, 2024 at 09:52:41AM +0200, Peter Zijlstra wrote: > > > >

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

2024-04-18 Thread Mike Rapoport
On Tue, Apr 16, 2024 at 09:52:34AM +0200, Peter Zijlstra wrote: > On Mon, Apr 15, 2024 at 08:00:26PM +0300, Mike Rapoport wrote: > > On Mon, Apr 15, 2024 at 12:47:50PM +0200, Peter Zijlstra wrote: > > > On Thu, Apr 11, 2024 at 07:05:25PM +0300, Mike Rapoport wrote: > >

Re: [RFC PATCH 3/7] module: prepare to handle ROX allocations for text

2024-04-18 Thread Mike Rapoport
On Tue, Apr 16, 2024 at 12:36:08PM +0300, Nadav Amit wrote: > > > > On 11 Apr 2024, at 19:05, Mike Rapoport wrote: > > > > @@ -2440,7 +2479,24 @@ static int post_relocation(struct module *mod, const > > struct load_info *info) > > add_kallsyms(mod,

Re: [PATCH v20 2/5] ring-buffer: Introducing ring-buffer mapping functions

2024-04-18 Thread Mike Rapoport
On Sat, Apr 06, 2024 at 06:36:46PM +0100, Vincent Donnefort wrote: > In preparation for allowing the user-space to map a ring-buffer, add > a set of mapping functions: > > ring_buffer_{map,unmap}() > > And controls on the ring-buffer: > > ring_buffer_map_get_reader() /* swap reader and

Re: [PATCH v20 0/5] Introducing trace buffer mapping by user-space

2024-04-16 Thread Mike Rapoport
(added linux-mm) On Wed, Apr 10, 2024 at 01:56:12PM -0400, Steven Rostedt wrote: > > Hi Andrew, et.al. > > Linus said it's a hard requirement that this code gets an Acked-by (or > Reviewed-by) from the memory sub-maintainers before he will accept it. > He was upset that we faulted in pages one

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-16 Thread Mike Rapoport
On Mon, Apr 15, 2024 at 06:36:39PM +0100, Mark Rutland wrote: > On Mon, Apr 15, 2024 at 09:52:41AM +0200, Peter Zijlstra wrote: > > On Thu, Apr 11, 2024 at 07:00:41PM +0300, Mike Rapoport wrote: > > > +/** > > > + * enum execmem_type - types

Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-15 Thread Mike Rapoport
On Mon, Apr 15, 2024 at 12:43:16PM +0200, Peter Zijlstra wrote: > On Thu, Apr 11, 2024 at 07:05:24PM +0300, Mike Rapoport wrote: > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > > index 45a280f2161c..b4d6868df573 100644 > > --- a/arch/x86

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

2024-04-15 Thread Mike Rapoport
On Mon, Apr 15, 2024 at 12:47:50PM +0200, Peter Zijlstra wrote: > On Thu, Apr 11, 2024 at 07:05:25PM +0300, Mike Rapoport wrote: > > > To populate the cache, a writable large page is allocated from vmalloc with > > VM_ALLOW_HUGE_VMAP, filled with invalid instructions and then r

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-15 Thread Mike Rapoport
On Mon, Apr 15, 2024 at 09:52:41AM +0200, Peter Zijlstra wrote: > On Thu, Apr 11, 2024 at 07:00:41PM +0300, Mike Rapoport wrote: > > +/** > > + * enum execmem_type - types of executable memory ranges > > + * > > + * There are several subsystems that

Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-14 Thread Mike Rapoport
On Fri, Apr 12, 2024 at 11:08:00AM +0200, Ingo Molnar wrote: > > * Mike Rapoport wrote: > > > for (s = start; s < end; s++) { > > void *addr = (void *)s + *s; > > + void *wr_addr = addr + module_writable_offset(mod, addr); > >

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

2024-04-14 Thread Mike Rapoport
On Fri, Apr 12, 2024 at 06:07:19AM +, Christophe Leroy wrote: > > > Le 11/04/2024 à 18:05, Mike Rapoport a écrit : > > From: "Mike Rapoport (IBM)" > > > > vmalloc allocations with VM_ALLOW_HUGE_VMAP that do not explictly > > specify node I

Re: [PATCH v4 06/15] mm/execmem, arch: convert simple overrides of module_alloc to execmem

2024-04-14 Thread Mike Rapoport
On Thu, Apr 11, 2024 at 10:53:46PM +0200, Sam Ravnborg wrote: > Hi Mike. > > On Thu, Apr 11, 2024 at 07:00:42PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (IBM)" > > > > Several architectures override module_alloc() only to define address > >

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-14 Thread Mike Rapoport
On Fri, Apr 12, 2024 at 11:16:10AM +0200, Ingo Molnar wrote: > > * Mike Rapoport wrote: > > > +/** > > + * enum execmem_type - types of executable memory ranges > > + * > > + * There are several subsystems that allocate executable memory. > > + * Arch

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-14 Thread Mike Rapoport
On Thu, Apr 11, 2024 at 12:42:05PM -0700, Luis Chamberlain wrote: > On Thu, Apr 11, 2024 at 07:00:41PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (IBM)" > > > > module_alloc() is used everywhere as a mean to allocate memory for code. > >

[RFC PATCH 7/7] x86/module: enable ROX caches for module text

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Enable execmem's cache of PMD_SIZE'ed pages mapped as ROX for module text allocations. Signed-off-by: Mike Rapoport (IBM) --- arch/x86/mm/init.c | 29 + 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/x86/m

[RFC PATCH 6/7] execmem: add support for cache of large ROX pages

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Using large pages to map text areas reduces iTLB pressure and improves performance. Extend execmem_alloc() with an ability to use PMD_SIZE'ed pages with ROX permissions as a cache for smaller allocations. To populate the cache, a writable large page is

[RFC PATCH 5/7] x86/module: perpare module loading for ROX allocations of text

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" 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 al

[RFC PATCH 4/7] ftrace: Add swap_func to ftrace_process_locs()

2024-04-11 Thread Mike Rapoport
From: Song Liu ftrace_process_locs sorts module mcount, which is inside RO memory. Add a ftrace_swap_func so that archs can use RO-memory-poke function to do the sorting. Signed-off-by: Song Liu Signed-off-by: Mike Rapoport (IBM) --- include/linux/ftrace.h | 2 ++ kernel/trace/ftrace.c

[RFC PATCH 3/7] module: prepare to handle ROX allocations for text

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" 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 modu

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

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" vmalloc allocations with VM_ALLOW_HUGE_VMAP that do not explictly specify node ID will use huge pages only if size_per_node is larger than PMD_SIZE. Still the actual allocated memory is not distributed between nodes and there is no advantage in suc

[RFC PATCH 1/7] asm-generic: introduce text-patching.h

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" 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 su

[RFC PATCH 0/7] x86/module: use large ROX pages for text allocations

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Hi, These patches add support for using large ROX pages for allocations of executable memory on x86. They address Andy's comments [1] about having executable mappings for code that was not completely formed. The approach taken is to allocate ROX me

[PATCH v4 15/15] bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" BPF just-in-time compiler depended on CONFIG_MODULES because it used module_alloc() to allocate memory for the generated code. Since code allocations are now implemented with execmem, drop dependency of CONFIG_BPF_JIT on CONFIG_MODULES and make

[PATCH v4 14/15] kprobes: remove dependency on CONFIG_MODULES

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" kprobes depended on CONFIG_MODULES because it has to allocate memory for code. Since code allocations are now implemented with execmem, kprobes can be enabled in non-modular kernels. Add #ifdef CONFIG_MODULE guards for the code dealing with kprobes insi

[PATCH v4 13/15] powerpc: use CONFIG_EXECMEM instead of CONFIG_MODULES where appropiate

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" There are places where CONFIG_MODULES guards the code that depends on memory allocation being done with module_alloc(). Replace CONFIG_MODULES with CONFIG_EXECMEM in such places. Signed-off-by: Mike Rapoport (IBM) --- arch/powerpc/Kconfig

[PATCH v4 12/15] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Dynamic ftrace must allocate memory for code and this was impossible without CONFIG_MODULES. With execmem separated from the modules code, execmem_text_alloc() is available regardless of CONFIG_MODULES. Remove dependency of dynamic ftrace on CONFIG_MODULE

[PATCH v4 11/15] arch: make execmem setup available regardless of CONFIG_MODULES

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" execmem does not depend on modules, on the contrary modules use execmem. To make execmem available when CONFIG_MODULES=n, for instance for kprobes, split execmem_params initialization out from arch/*/kernel/module.c and compile it when CONFIG_EXECMEM=y

[PATCH v4 10/15] powerpc: extend execmem_params for kprobes allocations

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" powerpc overrides kprobes::alloc_insn_page() to remove writable permissions when STRICT_MODULE_RWX is on. Add definition of EXECMEM_KRPOBES to execmem_params to allow using the generic kprobes::alloc_insn_page() with the desired permissions. As po

[PATCH v4 09/15] riscv: extend execmem_params for generated code allocations

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" The memory allocations for kprobes and BPF on RISC-V are not placed in the modules area and these custom allocations are implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Slightly reorder execmem_params initialization to suppo

[PATCH v4 08/15] arm64: extend execmem_info for generated code allocations

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" The memory allocations for kprobes and BPF on arm64 can be placed anywhere in vmalloc address space and currently this is implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec() in arm64. Define EXECMEM_KPROBES and EXECMEM_BPF range

[PATCH v4 07/15] mm/execmem, arch: convert remaining overrides of module_alloc to execmem

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Extend execmem parameters to accommodate more complex overrides of module_alloc() by architectures. This includes specification of a fallback range required by arm, arm64 and powerpc, EXECMEM_MODULE_DATA type required by powerpc, support for allocatio

[PATCH v4 06/15] mm/execmem, arch: convert simple overrides of module_alloc to execmem

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Several architectures override module_alloc() only to define address range for code allocations different than VMALLOC address space. Provide a generic implementation in execmem that uses the parameters for address space ranges, required alignmen

[PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" module_alloc() is used everywhere as a mean to allocate memory for code. Beside being semantically wrong, this unnecessarily ties all subsystems that need to allocate code, such as ftrace, kprobes and BPF to modules and puts the burden of code

[PATCH v4 04/15] module: make module_memory_{alloc,free} more self-contained

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Move the logic related to the memory allocation and freeing into module_memory_alloc() and module_memory_free(). Signed-off-by: Mike Rapoport (IBM) --- kernel/module/main.c | 64 +++- 1 file changed, 39 inserti

[PATCH v4 03/15] nios2: define virtual address space for modules

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" nios2 uses kmalloc() to implement module_alloc() because CALL26/PCREL26 cannot reach all of vmalloc address space. Define module space as 32MiB below the kernel base and switch nios2 to use vmalloc for module allocations. Suggested-by: Thomas Gleix

[PATCH v4 02/15] mips: module: rename MODULE_START to MODULES_VADDR

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" and MODULE_END to MODULES_END to match other architectures that define custom address space for modules. Signed-off-by: Mike Rapoport (IBM) --- arch/mips/include/asm/pgtable-64.h | 4 ++-- arch/mips/kernel/module.c | 4 ++-- arch/mips/

[PATCH v4 01/15] arm64: module: remove uneeded call to kasan_alloc_module_shadow()

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Since commit f6f37d9320a1 ("arm64: select KASAN_VMALLOC for SW/HW_TAGS modes") KASAN_VMALLOC is always enabled when KASAN is on. This means that allocations in module_alloc() will be tracked by KASAN protection for vmalloc() and that kasan

[PATCH v4 00/15] mm: jit/text allocator

2024-04-11 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Hi, Since v3 I looked into making execmem more of an utility toolbox, as we discussed at LPC with Mark Rutland, but it was getting more hairier than having a struct describing architecture constraints and a type identifying the consumer of execmem. And

Re: [RFC][PATCH 3/4] kprobes: Allow kprobes with CONFIG_MODULES=n

2024-03-06 Thread Mike Rapoport
On Wed, Mar 06, 2024 at 12:05:10PM -0800, Calvin Owens wrote: > If something like this is merged down the road, it can go in at leisure > once the module_alloc change is in: it's a one-way dependency. > > Signed-off-by: Calvin Owens > --- > arch/Kconfig| 2 +- >

Re: [RFC][PATCH 0/4] Make bpf_jit and kprobes work with CONFIG_MODULES=n

2024-03-06 Thread Mike Rapoport
might as well do it > > now. And for that I'd just like to ask you paint the bikeshed with > > Song Liu as he's been the one slowly making way to help us get there > > with the "module: replace module_layout with module_memory", > > and Mike Rapoport as he's

Re: [PATCH RFC v2 04/27] mm: migrate/mempolicy: Add hook to modify migration target gfp

2023-11-27 Thread Mike Rapoport
On Mon, Nov 27, 2023 at 11:52:56AM +, Alexandru Elisei wrote: > Hi Mike, > > I really appreciate you having a look! > > On Sat, Nov 25, 2023 at 12:03:22PM +0200, Mike Rapoport wrote: > > On Sun, Nov 19, 2023 at 04:56:58PM +, Alexandru Elisei wrote: > &

Re: [PATCH RFC v2 04/27] mm: migrate/mempolicy: Add hook to modify migration target gfp

2023-11-25 Thread Mike Rapoport
On Sun, Nov 19, 2023 at 04:56:58PM +, Alexandru Elisei wrote: > It might be desirable for an architecture to modify the gfp flags used to > allocate the destination page for migration based on the page that it is > being replaced. For example, if an architectures has metadata associated > with

Re: [PATCH v3 04/13] mm/execmem, arch: convert remaining overrides of module_alloc to execmem

2023-10-30 Thread Mike Rapoport
On Thu, Oct 26, 2023 at 11:24:39AM +0100, Will Deacon wrote: > On Thu, Oct 26, 2023 at 11:58:00AM +0300, Mike Rapoport wrote: > > On Mon, Oct 23, 2023 at 06:14:20PM +0100, Will Deacon wrote: > > > On Mon, Sep 18, 2023 at 10:29:46AM +0300, Mike Rapoport wrote: > > > >

Re: [PATCH v3 04/13] mm/execmem, arch: convert remaining overrides of module_alloc to execmem

2023-10-26 Thread Mike Rapoport
Hi Will, On Mon, Oct 23, 2023 at 06:14:20PM +0100, Will Deacon wrote: > Hi Mike, > > On Mon, Sep 18, 2023 at 10:29:46AM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (IBM)" > > > > Extend execmem parameters to accommodate more complex overrides o

Re: [PATCH v3 03/13] mm/execmem, arch: convert simple overrides of module_alloc to execmem

2023-10-26 Thread Mike Rapoport
Hi Rick, Sorry for the delay, I was a bit preoccupied with $stuff. On Thu, Oct 05, 2023 at 06:09:07PM +, Edgecombe, Rick P wrote: > On Thu, 2023-10-05 at 08:26 +0300, Mike Rapoport wrote: > > On Wed, Oct 04, 2023 at 03:39:26PM +, Edgecombe, Rick P wrote: > > > On Tue, 2

Re: [PATCH v3 04/13] mm/execmem, arch: convert remaining overrides of module_alloc to execmem

2023-10-04 Thread Mike Rapoport
On Wed, Oct 04, 2023 at 12:29:36AM +, Edgecombe, Rick P wrote: > On Mon, 2023-09-18 at 10:29 +0300, Mike Rapoport wrote: > > diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c > > index 5f71a0cf4399..9d37375e2f05 100644 > > --- a/arch/x86/kernel/module.c >

Re: [PATCH v3 03/13] mm/execmem, arch: convert simple overrides of module_alloc to execmem

2023-10-04 Thread Mike Rapoport
On Wed, Oct 04, 2023 at 03:39:26PM +, Edgecombe, Rick P wrote: > On Tue, 2023-10-03 at 17:29 -0700, Rick Edgecombe wrote: > > It seems a bit weird to copy all of this. Is it trying to be faster > > or > > something? > > > > Couldn't it just check r->start in execmem_text/data_alloc() path and

Re: [PATCH v3 10/13] arch: make execmem setup available regardless of CONFIG_MODULES

2023-09-26 Thread Mike Rapoport
Hi Arnd, On Tue, Sep 26, 2023 at 09:33:48AM +0200, Arnd Bergmann wrote: > On Mon, Sep 18, 2023, at 09:29, Mike Rapoport wrote: > > index a42e4cd11db2..c0b536e398b4 100644 > > --- a/arch/arm/mm/init.c > > +++ b/arch/arm/mm/init.c > > +#ifdef CONFIG_XIP_KERNEL > >

Re: [PATCH v3 02/13] mm: introduce execmem_text_alloc() and execmem_free()

2023-09-26 Thread Mike Rapoport
On Sat, Sep 23, 2023 at 03:36:01PM -0700, Song Liu wrote: > On Sat, Sep 23, 2023 at 8:39 AM Mike Rapoport wrote: > > > > On Thu, Sep 21, 2023 at 03:34:18PM -0700, Song Liu wrote: > > > On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport wrote: > > > > > > >

Re: [PATCH v3 09/13] powerpc: extend execmem_params for kprobes allocations

2023-09-23 Thread Mike Rapoport
Hi Christophe, On Fri, Sep 22, 2023 at 10:32:46AM +, Christophe Leroy wrote: > Hi Mike, > > Le 18/09/2023 à 09:29, Mike Rapoport a écrit : > > From: "Mike Rapoport (IBM)" > > > > powerpc overrides kprobes::alloc_insn_page() to remove writable &

Re: [PATCH v3 09/13] powerpc: extend execmem_params for kprobes allocations

2023-09-23 Thread Mike Rapoport
On Thu, Sep 21, 2023 at 03:30:46PM -0700, Song Liu wrote: > On Mon, Sep 18, 2023 at 12:31 AM Mike Rapoport wrote: > > > [...] > > @@ -135,5 +138,13 @@ struct execmem_params __init *execmem_arch_params(void) > > > > range->pgprot = prot; >

Re: [PATCH v3 08/13] riscv: extend execmem_params for generated code allocations

2023-09-23 Thread Mike Rapoport
On Fri, Sep 22, 2023 at 12:37:07PM +0200, Alexandre Ghiti wrote: > Hi Mike, > > On 18/09/2023 09:29, Mike Rapoport wrote: > > From: "Mike Rapoport (IBM)" > > > > The memory allocations for kprobes and BPF on RISC-V are not placed in > > th

Re: [PATCH v3 06/13] mm/execmem: introduce execmem_data_alloc()

2023-09-23 Thread Mike Rapoport
On Thu, Sep 21, 2023 at 03:52:21PM -0700, Song Liu wrote: > On Mon, Sep 18, 2023 at 12:31 AM Mike Rapoport wrote: > > > [...] > > diff --git a/include/linux/execmem.h b/include/linux/execmem.h > > index 519bdfdca595..09d45ac786e9 100644 > > --- a/include/linux/exe

Re: [PATCH v3 02/13] mm: introduce execmem_text_alloc() and execmem_free()

2023-09-23 Thread Mike Rapoport
On Thu, Sep 21, 2023 at 03:10:26PM -0700, Song Liu wrote: > On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport wrote: > > > [...] > > + > > +#include > > +#include > > +#include > > +#include > > + > > +static void *execmem_alloc(si

Re: [PATCH v3 02/13] mm: introduce execmem_text_alloc() and execmem_free()

2023-09-23 Thread Mike Rapoport
On Thu, Sep 21, 2023 at 03:14:54PM -0700, Song Liu wrote: > On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport wrote: > > > [...] > > + > > +/** > > + * enum execmem_type - types of executable memory ranges > > + * > > + * There are several

Re: [PATCH v3 02/13] mm: introduce execmem_text_alloc() and execmem_free()

2023-09-23 Thread Mike Rapoport
On Thu, Sep 21, 2023 at 03:34:18PM -0700, Song Liu wrote: > On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport wrote: > > > > [...] > > > diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c > > index 42215f9404af..db5561d0c233 100644 > > --- a/arch

[PATCH v3 03/13] mm/execmem, arch: convert simple overrides of module_alloc to execmem

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Several architectures override module_alloc() only to define address range for code allocations different than VMALLOC address space. Provide a generic implementation in execmem that uses the parameters for address space ranges, required alignmen

[PATCH v3 13/13] bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" BPF just-in-time compiler depended on CONFIG_MODULES because it used module_alloc() to allocate memory for the generated code. Since code allocations are now implemented with execmem, drop dependency of CONFIG_BPF_JIT on CONFIG_MODULES and make

[PATCH v3 12/13] kprobes: remove dependency on CONFIG_MODULES

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" kprobes depended on CONFIG_MODULES because it has to allocate memory for code. Since code allocations are now implemented with execmem, kprobes can be enabled in non-modular kernels. Add #ifdef CONFIG_MODULE guards for the code dealing with kprobes insi

[PATCH v3 04/13] mm/execmem, arch: convert remaining overrides of module_alloc to execmem

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Extend execmem parameters to accommodate more complex overrides of module_alloc() by architectures. This includes specification of a fallback range required by arm, arm64 and powerpc and support for allocation of KASAN shadow required by arm64, s3

[PATCH v3 08/13] riscv: extend execmem_params for generated code allocations

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" The memory allocations for kprobes and BPF on RISC-V are not placed in the modules area and these custom allocations are implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Slightly reorder execmem_params initialization to suppo

[PATCH v3 05/13] modules, execmem: drop module_alloc

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Define default parameters for address range for code allocations using the current values in module_alloc() and make execmem_text_alloc() use these defaults when an architecture does not supply its specific parameters. With this, execmem_text_alloc()

[PATCH v3 09/13] powerpc: extend execmem_params for kprobes allocations

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" powerpc overrides kprobes::alloc_insn_page() to remove writable permissions when STRICT_MODULE_RWX is on. Add definition of EXECMEM_KRPOBES to execmem_params to allow using the generic kprobes::alloc_insn_page() with the desired permissions. As po

[PATCH v3 02/13] mm: introduce execmem_text_alloc() and execmem_free()

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" module_alloc() is used everywhere as a mean to allocate memory for code. Beside being semantically wrong, this unnecessarily ties all subsystems that need to allocate code, such as ftrace, kprobes and BPF to modules and puts the burden of code

[PATCH v3 10/13] arch: make execmem setup available regardless of CONFIG_MODULES

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" execmem does not depend on modules, on the contrary modules use execmem. To make execmem available when CONFIG_MODULES=n, for instance for kprobes, split execmem_params initialization out from arch/kernel/module.c and compile it when CONFIG_EXECMEM=y

[PATCH v3 11/13] x86/ftrace: enable dynamic ftrace without CONFIG_MODULES

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Dynamic ftrace must allocate memory for code and this was impossible without CONFIG_MODULES. With execmem separated from the modules code, execmem_text_alloc() is available regardless of CONFIG_MODULES. Remove dependency of dynamic ftrace on CONFIG_MODULE

[PATCH v3 07/13] arm64, execmem: extend execmem_params for generated code allocations

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" The memory allocations for kprobes and BPF on arm64 can be placed anywhere in vmalloc address space and currently this is implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec() in arm64. Define EXECMEM_KPROBES and EXECMEM_BPF range

[PATCH v3 06/13] mm/execmem: introduce execmem_data_alloc()

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Data related to code allocations, such as module data section, need to comply with architecture constraints for its placement and its allocation right now was done using execmem_text_alloc(). Create a dedicated API for allocating data related to code a

[PATCH v3 00/13] mm: jit/text allocator

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" Hi, module_alloc() is used everywhere as a mean to allocate memory for code. Beside being semantically wrong, this unnecessarily ties all subsystmes that need to allocate code, such as ftrace, kprobes and BPF to modules and puts the burden of code

[PATCH v3 01/13] nios2: define virtual address space for modules

2023-09-18 Thread Mike Rapoport
From: "Mike Rapoport (IBM)" nios2 uses kmalloc() to implement module_alloc() because CALL26/PCREL26 cannot reach all of vmalloc address space. Define module space as 32MiB below the kernel base and switch nios2 to use vmalloc for module allocations. Suggested-by: Thomas Gleix

Re: [PATCH v1 2/4] memblock: update initialization of reserved pages

2021-04-20 Thread Mike Rapoport
On Tue, Apr 20, 2021 at 05:18:55PM +0200, David Hildenbrand wrote: > On 20.04.21 17:03, Mike Rapoport wrote: > > On Tue, Apr 20, 2021 at 03:56:28PM +0200, David Hildenbrand wrote: > > > On 20.04.21 11:09, Mike Rapoport wrote: > > > > From: Mike Rapoport >

[PATCH v3 2/2] secretmem: optimize page_is_secretmem()

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport Kernel test robot reported -4.2% regression of will-it-scale.per_thread_ops due to commit "mm: introduce memfd_secret system call to create "secret" memory areas". The perf profile of the test indicated that the regression is caused by page_is_sec

Re: [PATCH v1 2/4] memblock: update initialization of reserved pages

2021-04-20 Thread Mike Rapoport
On Tue, Apr 20, 2021 at 03:56:28PM +0200, David Hildenbrand wrote: > On 20.04.21 11:09, Mike Rapoport wrote: > > From: Mike Rapoport > > > > The struct pages representing a reserved memory region are initialized > > using reserve_bootmem_range() function. This

[PATCH v3 1/2] secretmem/gup: don't check if page is secretmem without reference

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport The check in gup_pte_range() whether a page belongs to a secretmem mapping is performed before grabbing the page reference. To avoid potential race move the check after try_grab_compound_head(). Signed-off-by: Mike Rapoport --- mm/gup.c | 8 +--- 1 file changed, 5

[PATCH v3 0/2] secretmem: optimize page_is_secretmem()

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport Hi, This is an updated version of page_is_secretmem() changes. This is based on v5.12-rc7-mmots-2021-04-15-16-28. @Andrew, please let me know if you'd like me to rebase it differently or resend the entire set. v3: * add missing put_compound_head() if we are to return NULL

Re: [PATCH v2] docs: proc.rst: meminfo: briefly describe gaps in memory accounting

2021-04-20 Thread Mike Rapoport
On Tue, Apr 20, 2021 at 02:24:30PM +0100, Matthew Wilcox wrote: > On Tue, Apr 20, 2021 at 03:13:54PM +0300, Mike Rapoport wrote: > > Add a paragraph that explains that it may happen that the counters in > > /proc/meminfo do not add up to the overall memory usage. > > ...

Re: [PATCH v2 0/2] secretmem: optimize page_is_secretmem()

2021-04-20 Thread Mike Rapoport
It seems I've messed this posting entirely :( Please ignore it, sorry for the noise. On Tue, Apr 20, 2021 at 04:16:07PM +0300, Mike Rapoport wrote: > From: Mike Rapoport > > Hi, > > This is an updated version of page_is_secretmem() changes. > This is based on v5.12-rc7-mmot

Re: [PATCH v2 1/2] secretmem/gup: don't check if page is secretmem without reference

2021-04-20 Thread Mike Rapoport
On Tue, Apr 20, 2021 at 03:19:56PM +0200, David Hildenbrand wrote: > On 20.04.21 15:16, Mike Rapoport wrote: > > From: Mike Rapoport > > > > The check in gup_pte_range() whether a page belongs to a secretmem mapping > > is performed before grabbing the page reference.

[PATCH v2 2/2] secretmem: optimize page_is_secretmem()

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport Kernel test robot reported -4.2% regression of will-it-scale.per_thread_ops due to commit "mm: introduce memfd_secret system call to create "secret" memory areas". The perf profile of the test indicated that the regression is caused by page_is_sec

[PATCH v2 1/2] secretmem: optimize page_is_secretmem()

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport Kernel test robot reported -4.2% regression of will-it-scale.per_thread_ops due to commit "mm: introduce memfd_secret system call to create "secret" memory areas". The perf profile of the test indicated that the regression is caused by page_is_sec

[PATCH v2 2/2] secretmem/gup: don't check if page is secretmem without reference

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport The check in gup_pte_range() whether a page belongs to a secretmem mapping is performed before grabbing the page reference. To avoid potential race move the check after try_grab_compound_head(). Signed-off-by: Mike Rapoport --- mm/gup.c | 6 +++--- 1 file changed, 3

[PATCH v2 1/2] secretmem/gup: don't check if page is secretmem without reference

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport The check in gup_pte_range() whether a page belongs to a secretmem mapping is performed before grabbing the page reference. To avoid potential race move the check after try_grab_compound_head(). Signed-off-by: Mike Rapoport --- mm/gup.c | 6 +++--- 1 file changed, 3

[PATCH v2 0/2] secretmem: optimize page_is_secretmem()

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport Hi, This is an updated version of page_is_secretmem() changes. This is based on v5.12-rc7-mmots-2021-04-15-16-28. @Andrew, please let me know if you'd like me to rebase it differently or resend the entire set. v2: * move the check for secretmem page in gup_pte_range after

Re: [PATCH v1 1/4] include/linux/mmzone.h: add documentation for pfn_valid()

2021-04-20 Thread Mike Rapoport
On Tue, Apr 20, 2021 at 11:22:53AM +0200, David Hildenbrand wrote: > On 20.04.21 11:09, Mike Rapoport wrote: > > From: Mike Rapoport > > > > Add comment describing the semantics of pfn_valid() that clarifies that > > pfn_valid() only checks for availability of a me

Re: [PATCH v2] docs: proc.rst: meminfo: briefly describe gaps in memory accounting

2021-04-20 Thread Mike Rapoport
On Tue, Apr 20, 2021 at 03:13:54PM +0300, Mike Rapoport wrote: > From: Mike Rapoport > > Add a paragraph that explains that it may happen that the counters in > /proc/meminfo do not add up to the overall memory usage. > > Signed-off-by: Mike Rapoport Ooops, forgot to add M

[PATCH v2] docs: proc.rst: meminfo: briefly describe gaps in memory accounting

2021-04-20 Thread Mike Rapoport
From: Mike Rapoport Add a paragraph that explains that it may happen that the counters in /proc/meminfo do not add up to the overall memory usage. Signed-off-by: Mike Rapoport --- v2: * Add brief changelog * Fix typo * Update example about network memory usage according to Eric's comment

<    1   2   3   4   5   6   7   8   9   10   >