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

2024-12-26 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 e9fc9d1fa476..22209

[PATCH 4/8] execmem: add API for temporal remapping as RW and restoring ROX afterwards

2024-12-26 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 7/8] Revert "x86/module: prepare module loading for ROX allocations of text"

2024-12-26 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 6/8] modules: switch to execmem API for remapping as RW and restoring ROX

2024-12-26 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 5/8] module: introduce MODULE_STATE_GONE

2024-12-26 Thread Mike Rapoport
From: "Mike Rapoport (Microsoft)" In order to use execmem's API for temporal remapping of the memory allocated from ROX cache as writable, there is a need to distinguish between the state when the module is being formed and the state when it is deconstructed and freed so that when module_memory_f

[PATCH 3/8] x86/mm/pat: Restore large pages after fragmentation

2024-12-26 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 as result. With current code it's one way road: kernel tries to avoid splitting large pages, but it doesn't restore them back even if page attributes got

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

2024-12-26 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 2/8] x86/mm/pat: drop duplicate variable in cpa_flush()

2024-12-26 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 0/8] x86/module: rework ROX cache to avoid writable copy

2024-12-26 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