[PATCH 11/13] arch, mm: streamline HIGHMEM freeing

2025-03-15 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" All architectures that support HIGHMEM have their code that frees high memory pages to the buddy allocator while __free_memory_core() is limited to freeing only low memory. There is no actual reason for that. The memory map is completely ready b

[PATCH v2 01/13] arm: mem_init: use memblock_phys_free() to free DMA memory on SA1111

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help to pull out memblock_free_all() to generic code. Signed-off-by: Mike Rapoport (Microsoft) --- arch/arm/mm/init.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/in

[PATCH v2 03/13] hexagon: move initialization of init_mm.context init to paging_init()

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/hexagon/mm/init.c | 14 ++ 1 file changed, 6 insertions(+), 8

[PATCH v2 09/13] arch, mm: set max_mapnr when allocating memory map for FLATMEM

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" max_mapnr is essentially the size of the memory map for systems that use FLATMEM. There is no reason to calculate it in each and every architecture when it's anyway calculated in alloc_node_mem_map(). Drop setting of max_mapnr from architecture

[PATCH v2 08/13] xtensa: split out printing of virtual memory layout to a function

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/xtensa/mm/init.c | 97 ++- 1 file c

[PATCH v2 07/13] s390: make setup_zero_pages() use memblock

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Allocating the zero pages from memblock is simpler because the memory is already reserved. This will also help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Acked-by: Heiko Carstens Sig

[PATCH v2 00/13] arch, mm: reduce code duplication in mem_init()

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Hi, Every architecture has implementation of mem_init() function and some even more than one. All these release free memory to the buddy allocator, most of them set high_memory to the end of directly addressable memory and many of them set max_mapnr f

[PATCH v2 12/13] arch, mm: introduce arch_mm_preinit

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Currently, implementation of mem_init() in every architecture consists of one or more of the following: * initializations that must run before page allocator is active, for instance swiotlb_init() * a call to memblock_free_all() to release all the

[PATCH v2 02/13] csky: move setup_initrd() to setup.c

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Memory used by initrd should be reserved as soon as possible before there any memblock allocations that might overwrite that memory. This will also help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch

[PATCH v2 04/13] MIPS: consolidate mem_init() for NUMA machines

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Both MIPS systems that support numa (loongsoon3 and sgi-ip27) have identical mem_init() for NUMA case. Move that into arch/mips/mm/init.c and drop duplicate per-machine definitions. Signed-off-by: Mike Rapoport (Microsoft) --- arch/mips/loongso

[PATCH v2 11/13] arch, mm: streamline HIGHMEM freeing

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" All architectures that support HIGHMEM have their code that frees high memory pages to the buddy allocator while __free_memory_core() is limited to freeing only low memory. There is no actual reason for that. The memory map is completely ready b

[PATCH v2 10/13] arch, mm: set high_memory in free_area_init()

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" high_memory defines upper bound on the directly mapped memory. This bound is defined by the beginning of ZONE_HIGHMEM when a system has high memory and by the end of memory otherwise. All this is known to generic memory management initialization cod

[PATCH v2 13/13] arch, mm: make releasing of memory to page allocator more explicit

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" The point where the memory is released from memblock to the buddy allocator is hidden inside arch-specific mem_init()s and the call to memblock_free_all() is needlessly duplicated in every artiste cure and after introduction of arch_mm_preinit() hook

[PATCH v2 06/13] nios2: move pr_debug() about memory start and end to setup_arch()

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/nios2/kernel/setup.c | 2 ++ arch/nios2/mm/init.c | 2 -- 2 files

[PATCH v2 05/13] MIPS: make setup_zero_pages() use memblock

2025-03-13 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Allocating the zero pages from memblock is simpler because the memory is already reserved. This will also help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport

Re: [PATCH 07/13] s390: make setup_zero_pages() use memblock

2025-03-12 Thread Mike Rapoport
On Wed, Mar 12, 2025 at 04:56:59PM +0100, Ard Biesheuvel wrote: > On Tue, 11 Mar 2025 at 06:56, Mike Rapoport wrote: > > > > On Fri, Mar 07, 2025 at 04:28:15PM +0100, Heiko Carstens wrote: > > > On Thu, Mar 06, 2025 at 08:51:17PM +0200, Mike Rapoport wrote: > > >

Re: [PATCH 10/13] arch, mm: set high_memory in free_area_init()

2025-03-11 Thread Mike Rapoport
On Tue, Mar 11, 2025 at 09:59:32PM +, Russell King (Oracle) wrote: > On Tue, Mar 11, 2025 at 05:51:06PM +, Mark Brown wrote: > > On Thu, Mar 06, 2025 at 08:51:20PM +0200, Mike Rapoport wrote: > > > From: "Mike Rapoport (Microsoft)" > > > > &g

Re: [PATCH 10/13] arch, mm: set high_memory in free_area_init()

2025-03-11 Thread Mike Rapoport
Hi Mark, On Tue, Mar 11, 2025 at 05:51:06PM +, Mark Brown wrote: > On Thu, Mar 06, 2025 at 08:51:20PM +0200, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > high_memory defines upper bound on the directly mapped memory. > > This

[PATCH 02/13] csky: move setup_initrd() to setup.c

2025-03-11 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Memory used by initrd should be reserved as soon as possible before there any memblock allocations that might overwrite that memory. This will also help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch

[PATCH 13/13] arch, mm: make releasing of memory to page allocator more explicit

2025-03-11 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" The point where the memory is released from memblock to the buddy allocator is hidden inside arch-specific mem_init()s and the call to memblock_free_all() is needlessly duplicated in every artiste cure and after introduction of arch_mm_preinit() hook

Re: [PATCH 05/13] MIPS: make setup_zero_pages() use memblock

2025-03-10 Thread Mike Rapoport
On Thu, Mar 06, 2025 at 08:51:15PM +0200, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > Allocating the zero pages from memblock is simpler because the memory is > already reserved. > > This will also help with pulling out memblock_free_all() to the

Re: [PATCH 07/13] s390: make setup_zero_pages() use memblock

2025-03-10 Thread Mike Rapoport
On Fri, Mar 07, 2025 at 04:28:15PM +0100, Heiko Carstens wrote: > On Thu, Mar 06, 2025 at 08:51:17PM +0200, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > Allocating the zero pages from memblock is simpler because the memory is > > alre

[PATCH 05/13] MIPS: make setup_zero_pages() use memblock

2025-03-07 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Allocating the zero pages from memblock is simpler because the memory is already reserved. This will also help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport

[PATCH 03/13] hexagon: move initialization of init_mm.context init to paging_init()

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/hexagon/mm/init.c | 14 ++ 1 file changed, 6 insertions(+), 8

[PATCH 10/13] arch, mm: set high_memory in free_area_init()

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" high_memory defines upper bound on the directly mapped memory. This bound is defined by the beginning of ZONE_HIGHMEM when a system has high memory and by the end of memory otherwise. All this is known to generic memory management initialization cod

[PATCH 12/13] arch, mm: introduce arch_mm_preinit

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Currently, implementation of mem_init() in every architecture consists of one or more of the following: * initializations that must run before page allocator is active, for instance swiotlb_init() * a call to memblock_free_all() to release all the

[PATCH 06/13] nios2: move pr_debug() about memory start and end to setup_arch()

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/nios2/kernel/setup.c | 2 ++ arch/nios2/mm/init.c | 2 -- 2 files

[PATCH 07/13] s390: make setup_zero_pages() use memblock

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Allocating the zero pages from memblock is simpler because the memory is already reserved. This will also help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport

[PATCH 00/13] arch, mm: reduce code duplication in mem_init()

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Hi, Every architecture has implementation of mem_init() function and some even more than one. All these release free memory to the buddy allocator, most of them set high_memory to the end of directly addressable memory and many of them set max_mapnr f

[PATCH 09/13] arch, mm: set max_mapnr when allocating memory map for FLATMEM

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" max_mapnr is essentially the size of the memory map for systems that use FLATMEM. There is no reason to calculate it in each and every architecture when it's anyway calculated in alloc_node_mem_map(). Drop setting of max_mapnr from architecture

[PATCH 08/13] xtensa: split out printing of virtual memory layout to a function

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/xtensa/mm/init.c | 97 ++- 1 file c

[PATCH 04/13] MIPS: consolidate mem_init() for NUMA machines

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Both MIPS systems that support numa (loongsoon3 and sgi-ip27) have identical mem_init() for NUMA case. Move that into arch/mips/mm/init.c and drop duplicate per-machine definitions. Signed-off-by: Mike Rapoport (Microsoft) --- arch/mips/loongso

[PATCH 01/13] arm: mem_init: use memblock_phys_free() to free DMA memory on SA1111

2025-03-06 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" This will help to pull out memblock_free_all() to generic code. Signed-off-by: Mike Rapoport (Microsoft) --- arch/arm/mm/init.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/in

Re: [PATCH RFC v2 02/29] x86: Create CONFIG_MITIGATION_ADDRESS_SPACE_ISOLATION

2025-02-28 Thread Mike Rapoport
Hi Brendan, On Fri, Jan 10, 2025 at 06:40:28PM +, Brendan Jackman wrote: > Currently a nop config. Keeping as a separate commit for easy review of > the boring bits. Later commits will use and enable this new config. > > This config is only added for non-UML x86_64 as other architectures do >

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

2025-02-28 Thread Mike Rapoport
Hi Ryan, On Thu, Feb 27, 2025 at 11:13:29AM +, Ryan Roberts wrote: > Hi Mike, > > Drive by review comments below... > > > On 23/10/2024 17:27, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > Using large pages to map

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

2024-11-18 Thread Mike Rapoport
On Mon, Nov 18, 2024 at 01:25:01PM -0500, Steven Rostedt wrote: > On Wed, 23 Oct 2024 19:27:03 +0300 > Mike Rapoport wrote: > > > From: "Mike Rapoport (Microsoft)" > > > > Hi, > > > > This is an updated version of execmem ROX caches. > >

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

2024-11-04 Thread Mike Rapoport
Hi Nathan, On Mon, Nov 04, 2024 at 04:27:41PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 23, 2024 at 07:27:09PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > When module text memory will be allocated with ROX perm

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

2024-10-24 Thread Mike Rapoport
Hi Nathan, On Mon, Oct 21, 2024 at 03:15:19PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 16, 2024 at 03:24:22PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > When module text memory will be allocated with ROX perm

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

2024-10-23 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) Reviewed-by: Luis Chamberlain Tested-by: kdevops --- arch/x86/Kconfig | 1 + arc

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

2024-10-23 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 modu

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

2024-10-23 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Hi, This is an updated version of execmem ROX caches. v6: https://lore.kernel.org/all/20241016122424.1655560-1-r...@kernel.org * Fixed handling of alternatives for fineibt (kbuild bot) * Restored usage of text_poke_early for ftrace boot time init

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

2024-10-23 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 allo

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

2024-10-23 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 reloc

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

2024-10-23 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 Reviewed-by: Luis Chamberlain

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

2024-10-23 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 su

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

2024-10-23 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 suc

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

2024-10-23 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:

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

2024-10-19 Thread Mike Rapoport
On Thu, Oct 17, 2024 at 10:17:12AM -0400, Steven Rostedt wrote: > On Wed, 16 Oct 2024 17:01:28 -0400 > Steven Rostedt wrote: > > > If this is only needed for module load, can we at least still use the > > text_poke_early() at boot up? > > > > if (ftrace_poke_late) { > > text_poke

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

2024-10-17 Thread Mike Rapoport
On Thu, Oct 17, 2024 at 11:35:15AM +0200, Peter Zijlstra wrote: > On Wed, Oct 16, 2024 at 05:01:28PM -0400, Steven Rostedt wrote: > > On Wed, 16 Oct 2024 15:24:22 +0300 > > Mike Rapoport wrote: > > > > > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftr

[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 reloc

[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 modu

[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/se

[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 su

[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 suc

[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 -

[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 allo

[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:

[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 takin

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

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

2024-10-14 Thread Mike Rapoport
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 > tools/testing/selftests/kmod/kmod.sh to pass. There was an issue with kmemleak, I fixed it here: https://lore.kernel.org/linux-mm/20241009180816.83591

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

2024-10-14 Thread Mike Rapoport
On Sun, Oct 13, 2024 at 10:55:25PM -0700, Christoph Hellwig wrote: > On Sun, Oct 13, 2024 at 11:43:41AM +0300, Mike Rapoport wrote: > > > But why? That's pretty different from our normal style of arch hooks, > > > and introduces an indirect call in a security sensitive

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

2024-10-13 Thread Mike Rapoport
On Fri, Oct 11, 2024 at 12:46:23AM -0700, Christoph Hellwig wrote: > On Thu, Oct 10, 2024 at 03:57:33PM +0300, Mike Rapoport wrote: > > On Wed, Oct 09, 2024 at 11:58:33PM -0700, Christoph Hellwig wrote: > > > On Wed, Oct 09, 2024 at 09:08:15PM +0300, M

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

2024-10-11 Thread Mike Rapoport
On Thu, Oct 10, 2024 at 03:54:11PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 09, 2024 at 09:08:14PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > When module text memory will be allocated with ROX permissions,

Re: Bisected: [PATCH v5 8/8] x86/module: enable ROX caches for module text

2024-10-10 Thread Mike Rapoport
On Thu, Oct 10, 2024 at 05:30:33PM +0900, Sergey Senozhatsky wrote: > On (24/10/09 21:08), Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > Enable execmem's cache of PMD_SIZE'ed pages mapped as ROX for module > > text alloca

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

2024-10-10 Thread Mike Rapoport
On Wed, Oct 09, 2024 at 11:58:33PM -0700, Christoph Hellwig wrote: > On Wed, Oct 09, 2024 at 09:08:15PM +0300, Mike Rapoport wrote: > > /** > > * struct execmem_info - architecture parameters for code allocations > > + * @fill_trapping_insns: set memory to contain instru

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

2024-10-10 Thread Mike Rapoport
On Wed, Oct 09, 2024 at 01:24:27PM -0700, Andrew Morton wrote: > On Wed, 9 Oct 2024 21:08:15 +0300 Mike Rapoport wrote: > > > Using large pages to map text areas reduces iTLB pressure and improves > > performance. > > Are there any measurable performance improvements?

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

2024-10-09 Thread Mike Rapoport
On Wed, Oct 09, 2024 at 03:23:40PM -0700, Song Liu wrote: > On Wed, Oct 9, 2024 at 11:10 AM Mike Rapoport wrote: > [...] > > diff --git a/include/linux/module.h b/include/linux/module.h > > index 88ecc5e9f523..7039f609c6ef 100644 > > --- a/include/linux/module.h > >

[PATCH v5 8/8] x86/module: enable ROX caches for module text

2024-10-09 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Enable execmem's cache of PMD_SIZE'ed pages mapped as ROX for module text allocations. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/init.c | 26 +- 1 file changed, 25 insertions(+), 1 deletion(-) diff

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

2024-10-09 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 allo

[PATCH v5 6/8] x86/module: perpare module loading for ROX allocations of text

2024-10-09 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 reloc

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

2024-10-09 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) --- arch/arm64/include/asm/set_memory.h | 1 + arc

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

2024-10-09 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 modu

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

2024-10-09 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 suc

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

2024-10-09 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) --- inc

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

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

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

2024-10-09 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 su

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

2024-10-07 Thread Mike Rapoport
Hi Huacai, On Tue, Oct 08, 2024 at 10:11:25AM +0800, Huacai Chen wrote: > Hi, Mike, > > On Mon, Oct 7, 2024 at 2:30 PM Mike Rapoport wrote: > > > > From: "Mike Rapoport (Microsoft)" > > > > Add an API that will allow updates of the direct/linear map f

[PATCH v4 8/8] x86/module: enable ROX caches for module text

2024-10-07 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Enable execmem's cache of PMD_SIZE'ed pages mapped as ROX for module text allocations. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/init.c | 26 +- 1 file changed, 25 insertions(+), 1 deletion(-) diff

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

2024-10-07 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 allo

[PATCH v4 6/8] x86/module: perpare module loading for ROX allocations of text

2024-10-06 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 reloc

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

2024-10-06 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) --- arch/arm64/include/asm/set_memory.h | 1 + arc

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

2024-10-06 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 modu

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

2024-10-06 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 su

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

2024-10-06 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 suc

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

2024-10-06 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) --- inc

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

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

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

2024-09-15 Thread Mike Rapoport
Hi Ard, On Fri, Sep 13, 2024 at 05:00:42PM +0200, Ard Biesheuvel wrote: > Hi Mike, > > On Mon, 9 Sept 2024 at 08:51, Mike Rapoport wrote: ... > > +static void execmem_fill_trapping_insns(void *ptr, size_t size, bool > > writable) > > +{ > > + if (

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

2024-09-11 Thread Mike Rapoport
On Mon, Sep 09, 2024 at 10:49:40AM -0400, Steven Rostedt wrote: > On Mon, 9 Sep 2024 17:34:48 +0300 > Mike Rapoport wrote: > > > > This is insane, just force BUILDTIME_MCOUNT_SORT > > > > The comment in ftrace.c says "... while mcount loc in modules

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

2024-09-09 Thread Mike Rapoport
On Mon, Sep 09, 2024 at 11:29:23AM +0200, Peter Zijlstra wrote: > On Mon, Sep 09, 2024 at 09:47:28AM +0300, Mike Rapoport wrote: > > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c > > index 8da0e66ca22d..563d9a890ce2 100644 > > --- a/arch/x86/kernel/ftrace

[PATCH v3 8/8] x86/module: enable ROX caches for module text

2024-09-08 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Enable execmem's cache of PMD_SIZE'ed pages mapped as ROX for module text allocations. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/init.c | 26 +- 1 file changed, 25 insertions(+), 1 deletion(-) diff

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

2024-09-08 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 allo

[PATCH v3 5/8] ftrace: Add swap_func to ftrace_process_locs()

2024-09-08 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 (Microsoft) --- include/linux/ftrace.h | 2 ++ kernel/trace

[PATCH v3 6/8] x86/module: perpare module loading for ROX allocations of text

2024-09-08 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 reloc

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

2024-09-08 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 modu

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

2024-09-08 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 su

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

2024-09-08 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 suc

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

2024-09-08 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) --- inc

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

2024-09-08 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" 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 R

Re: [PATCH v2 5/8] ftrace: Add swap_func to ftrace_process_locs()

2024-08-27 Thread Mike Rapoport
On Mon, Aug 26, 2024 at 01:29:09PM -0400, Steven Rostedt wrote: > On Mon, 26 Aug 2024 09:55:29 +0300 > Mike Rapoport wrote: > > > From: Song Liu > > > > ftrace_process_locs sorts module mcount, which is inside RO memory. Add a > > ftrace_swap_func so that arch

[PATCH v2 6/8] x86/module: perpare module loading for ROX allocations of text

2024-08-26 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 reloc

  1   2   3   4   5   >