From: Heiko Carstens <hca@linux.ibm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH v2 02/10] s390/ftrace: Serialize text patching with text_mutex
Date: Tue, 27 Oct 2026 15:30:22 +0100 [thread overview]
Message-ID: <20261027143030.3154657-3-hca@linux.ibm.com> (raw)
In-Reply-To: <20261027143030.3154657-1-hca@linux.ibm.com>
Add ftrace_arch_code_modify_prepare() and extend
ftrace_arch_code_modify_post_process() to acquire and release
text_mutex when ftrace code is modified.
Also add locking to ftrace_init_nop(). This way s390 uses text_mutex
like e.g. x86 and riscv.
This is part of larger series where at the end s390_kernel_write()
requires that callers hold text_mutex for serialization.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/kernel/ftrace.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index e94bb98f5231..2f0c4ef1b2d6 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -8,6 +8,7 @@
*/
#include <linux/hardirq.h>
+#include <linux/memory.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
#include <linux/kernel.h>
@@ -90,6 +91,8 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
BUILD_BUG_ON(sizeof(struct ftrace_hotpatch_trampoline) !=
SIZEOF_FTRACE_HOTPATCH_TRAMPOLINE);
+ guard(mutex)(&text_mutex);
+
next_trampoline = &next_vmlinux_trampoline;
trampolines_end = __ftrace_hotpatch_trampolines_end;
shared = ftrace_shared_hotpatch_trampoline(NULL);
@@ -247,13 +250,21 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return 0;
}
+void ftrace_arch_code_modify_prepare(void)
+ __acquires(&text_mutex)
+{
+ mutex_lock(&text_mutex);
+}
+
void arch_ftrace_update_code(int command)
{
ftrace_modify_all_code(command);
}
void ftrace_arch_code_modify_post_process(void)
+ __releases(&text_mutex)
{
+ mutex_unlock(&text_mutex);
/*
* Flush any pre-fetched instructions on all
* CPUs to make the new code visible.
--
2.53.0
next prev parent reply other threads:[~2026-10-27 14:30 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:30 [PATCH v2 00/10] s390: Consistent usage of text_mutex Heiko Carstens
2026-10-27 14:30 ` [PATCH v2 01/10] s390/jump_label: Serialize text patching with text_mutex Heiko Carstens
2026-10-27 14:35 ` sashiko-bot
2026-10-28 10:50 ` Ilya Leoshkevich
2026-10-27 14:30 ` Heiko Carstens [this message]
2026-10-27 14:37 ` [PATCH v2 02/10] s390/ftrace: " sashiko-bot
2026-10-28 10:54 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 03/10] s390/bpf: " Heiko Carstens
2026-10-27 14:35 ` sashiko-bot
2026-10-28 10:56 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 04/10] s390/runtime-const: " Heiko Carstens
2026-10-27 14:34 ` sashiko-bot
2026-10-28 10:58 ` Ilya Leoshkevich
2026-10-28 11:09 ` Heiko Carstens
2026-10-28 12:22 ` Ilya Leoshkevich
2026-10-28 13:43 ` Heiko Carstens
2026-10-27 14:30 ` [PATCH v2 05/10] s390/module: " Heiko Carstens
2026-10-27 14:36 ` sashiko-bot
2026-10-28 10:59 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 06/10] s390/stackprotector: " Heiko Carstens
2026-10-27 14:34 ` sashiko-bot
2026-10-28 12:23 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 07/10] s390/nospec-branch: " Heiko Carstens
2026-10-27 14:35 ` sashiko-bot
2026-10-28 12:24 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 08/10] s390/alternative: " Heiko Carstens
2026-10-27 14:36 ` sashiko-bot
2026-10-28 12:25 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 09/10] s390/uaccess: Move s390_kernel_write() to asm/text-patching.h Heiko Carstens
2026-10-27 14:35 ` sashiko-bot
2026-10-28 12:26 ` Ilya Leoshkevich
2026-10-27 14:30 ` [PATCH v2 10/10] s390/maccess: Remove spinlock from __s390_kernel_write() Heiko Carstens
2026-10-27 14:41 ` sashiko-bot
2026-10-28 20:59 ` Ilya Leoshkevich
2026-10-29 10:57 ` Heiko Carstens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261027143030.3154657-3-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox