Skip to content

Commit 5d79c2b

Browse files
rpptakpm00
authored andcommitted
x86/ftrace: enable EXECMEM_ROX_CACHE for ftrace allocations
For the most part ftrace uses text poking and can handle ROX memory. The only place that requires writable memory is create_trampoline() that updates the allocated memory and in the end makes it ROX. Use execmem_alloc_rw() in x86::ftrace::alloc_tramp() and enable ROX cache for EXECMEM_FTRACE when configuration and CPU features allow that. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Cc: Daniel Gomez <[email protected]> Cc: Masami Hiramatsu (Google) <[email protected]> Cc: Petr Pavlu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 36de1e4 commit 5d79c2b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

arch/x86/kernel/ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void arch_ftrace_update_code(int command)
263263

264264
static inline void *alloc_tramp(unsigned long size)
265265
{
266-
return execmem_alloc(EXECMEM_FTRACE, size);
266+
return execmem_alloc_rw(EXECMEM_FTRACE, size);
267267
}
268268
static inline void tramp_free(void *tramp)
269269
{

arch/x86/mm/init.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,14 @@ struct execmem_info __init *execmem_arch_setup(void)
11051105
.pgprot = PAGE_KERNEL_ROX,
11061106
.alignment = MODULE_ALIGN,
11071107
},
1108-
[EXECMEM_FTRACE ... EXECMEM_BPF] = {
1108+
[EXECMEM_FTRACE] = {
1109+
.flags = flags,
1110+
.start = start,
1111+
.end = MODULES_END,
1112+
.pgprot = pgprot,
1113+
.alignment = MODULE_ALIGN,
1114+
},
1115+
[EXECMEM_BPF] = {
11091116
.flags = EXECMEM_KASAN_SHADOW,
11101117
.start = start,
11111118
.end = MODULES_END,

0 commit comments

Comments
 (0)