[PATCH v3 4/9] execmem: don't remove ROX cache from the direct map

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" The memory allocated for the ROX cache was removed from the direct map to reduce amount of direct map updates, however this cannot be tolerated by /proc/kcore that accesses module memory using vread_iter() and the latter does vmalloc_to_page() and copy_page_to_it

[PATCH v3 9/9] x86: re-enable EXECMEM_ROX support

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" after rework of execmem ROX caches Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ef6cfea9df73..9d7bd0ae48c4 100644 --- a/arch/x86/Kconfig +++ b/arch/x

[PATCH v3 8/9] module: drop unused module_writable_address()

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" module_writable_address() is unused and can be removed. Signed-off-by: Mike Rapoport (Microsoft) --- include/linux/module.h | 10 -- 1 file changed, 10 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 6a24e9395cb2..d2cf3

[PATCH v3 7/9] Revert "x86/module: prepare module loading for ROX allocations of text"

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" The module code does not create a writable copy of the executable memory anymore so there is no need to handle it in module relocation and alternatives patching. This reverts commit 9bfc4824fd4836c16bb44f922bfaffba5da3e4f3. Signed-off-by: Mike Rapoport (Microso

[PATCH v3 6/9] module: switch to execmem API for remapping as RW and restoring ROX

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Instead of using writable copy for module text sections, temporarily remap the memory allocated from execmem's ROX cache as writable and restore its ROX permissions after the module is formed. This will allow removing nasty games with writable copy in alternativ

[PATCH v3 5/9] execmem: add API for temporal remapping as RW and restoring ROX afterwards

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Using a writable copy for ROX memory is cumbersome and error prone. Add API that allow temporarily remapping of ranges in the ROX cache as writable and then restoring their read-only-execute permissions. This API will be later used in modules code and will all

[PATCH v3 3/9] x86/mm/pat: restore large ROX pages after fragmentation

2025-01-25 Thread Mike Rapoport
From: "Kirill A. Shutemov" Change of attributes of the pages may lead to fragmentation of direct mapping over time and performance degradation when these pages contain executable code. With current code it's one way road: kernel tries to avoid splitting large pages, but it doesn't restore them b

[PATCH v3 2/9] x86/mm/pat: drop duplicate variable in cpa_flush()

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" There is a 'struct cpa_data *data' parameter in cpa_flush() that is assigned to a local 'struct cpa_data *cpa' variable. Rename the parameter from 'data' to 'cpa' and drop declaration of the local 'cpa' variable. Signed-off-by: Mike Rapoport (Microsoft) --- a

[PATCH v3 1/9] x86/mm/pat: cpa-test: fix length for CPA_ARRAY test

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" The CPA_ARRAY test always uses len[1] as numpages argument to change_page_attr_set() although the addresses array is different each iteration of the test loop. Replace len[1] with len[i] to have numpages matching the addresses array. Fixes: ecc729f1f471 ("x86/m

[PATCH v3 0/9] x86/module: rework ROX cache to avoid writable copy

2025-01-25 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" Hi, Following Peter's comments [1] these patches rework handling of ROX caches for module text allocations. Instead of using a writable copy that really complicates alternatives patching, temporarily remap parts of a large ROX page as RW for the time of module