Skip to content

x86: enable EXECMEM_ROX_CACHE for ftrace and kprobes

Mike Rapoport linux-mm linux-modules linux-trace-kernel lkml 3 versions – Applied

Status from this message: [merged mm-stable] x86-ftrace-enable-execmem_rox_cache-for-ftrace-allocations.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 5 repliesApplied 8/8
  2. v28 patches 4 repliesSuperseded
  3. v18 patches 13 repliesSuperseded

Changes in v3 from the cover letter

* Fix spelling (Petr)
* Add ack and review tags, thanks all!

Patches in v3 All 8 applied

#Subject and filesSizeRepliesApplied
1/8execmem: drop unused execmem_update_copy()include/linux/execmem.h mm/execmem.c+0 -180 repliesApplied
2/8execmem: introduce execmem_alloc_rw()arch/x86/kernel/alternative.c include/linux/execmem.h kernel/module/main.c +1 more+51 -300 repliesApplied
3/8execmem: rework execmem_cache_free()mm/execmem.c+102 -230 repliesApplied
4/8execmem: move execmem_force_rw() and execmem_restore_rox() before usemm/execmem.c+21 -230 repliesApplied
5/8execmem: add fallback for failures in vmalloc(VM_ALLOW_HUGE_VMAP)mm/execmem.c+6 -10 repliesApplied
6/8execmem: drop writable parameter from execmem_fill_trapping_insns()arch/x86/mm/init.c include/linux/execmem.h mm/execmem.c+5 -100 repliesApplied
7/8x86/kprobes: enable EXECMEM_ROX_CACHE for kprobes allocationsarch/x86/kernel/kprobes/core.c arch/x86/mm/init.c+8 -191 replyApplied
8/8x86/ftrace: enable EXECMEM_ROX_CACHE for ftrace allocationsarch/x86/kernel/ftrace.c arch/x86/mm/init.c+9 -24 repliesApplied

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchPeter Zijlstra (Intel)Daniel GomezPetr PavluSteven Rostedt (Google)Masami Hiramatsu (Google)
1/8A-b
2/8A-b R-b R-b
3/8A-b
4/8A-b
5/8A-b
6/8A-b
7/8A-b A-b
8/8A-b A-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v3 thread

Cover letter [PATCH v3 0/8] x86: enable EXECMEM_ROX_CACHE for ftrace and kprobes

From: "Mike Rapoport (Microsoft)" <[email protected]>

Hi,

These patches enable use of EXECMEM_ROX_CACHE for ftrace and kprobes allocations on x86.

They also include some ground work in execmem.

Since the execmem model for caching large ROX pages changed from the initial assumption that the memory that is allocated from ROX cache is always ROX to the current state where memory can be temporarily made RW and then restored to ROX, we can stop using text poking to update it. This also saves the hassle of trying lock text_mutex in execmem_cache_free() when kprobes already hold that mutex.

The patches 1-6 update and cleanup execmem ROX cache management, patch 7 enables EXECMEM_ROX_CACHE for kprobes and patch 8 enables EXECMEM_ROX_CACHE for frace.

The patches are also available at git:

https://git.kernel.org/rppt/h/execmem/x86-rox/ftrace%2bkprobes/v3

v3:
* Fix spelling (Petr)
* Add ack and review tags, thanks all!

v2: https://lore.kernel.org/all/[email protected]
* Fix setting and clearing pending_free for an area (Yann)
* Reorder execmem_cache_free() to avoid error goto (Peter)
* Add comment why mas_store_gfp() cannot fail in execmem_cache_free() (Peter)

Mike Rapoport (Microsoft) (8):
execmem: drop unused execmem_update_copy()
execmem: introduce execmem_alloc_rw()
execmem: rework execmem_cache_free()
execmem: move execmem_force_rw() and execmem_restore_rox() before use
execmem: add fallback for failures in vmalloc(VM_ALLOW_HUGE_VMAP)
execmem: drop writable parameter from execmem_fill_trapping_insns() x86/kprobes: enable EXECMEM_ROX_CACHE for kprobes allocations x86/ftrace: enable EXECMEM_ROX_CACHE for ftrace allocations

 arch/x86/kernel/alternative.c  |   3 +-
 arch/x86/kernel/ftrace.c       |   2 +-
 arch/x86/kernel/kprobes/core.c |  18 ---
 arch/x86/mm/init.c             |  24 ++--
 include/linux/execmem.h        |  54 ++++-----
 kernel/module/main.c           |  13 +--
 mm/execmem.c                   | 198 +++++++++++++++++++++++++--------
 7 files changed, 194 insertions(+), 118 deletions(-)

base-commit: 86731a2a651e58953fc949573895f2fa6d456841 --
2.47.2