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 3/4] s390/bpf: Serialize text patching with text_mutex
Date: Mon, 26 Oct 2026 13:03:28 +0100 [thread overview]
Message-ID: <20261026120329.1792436-4-hca@linux.ibm.com> (raw)
In-Reply-To: <20261026120329.1792436-1-hca@linux.ibm.com>
Acquire text_mutex in bpf_arch_text_poke(). This way s390 uses text_mutex
like most other architectures.
This is a prereq for removing the spinlock in __s390_kernel_write().
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/net/bpf_jit_comp.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 51db92c3329d..b8ff1ca2f598 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -22,6 +22,7 @@
#include <linux/init.h>
#include <linux/bpf.h>
#include <linux/cfi.h>
+#include <linux/memory.h>
#include <linux/mm.h>
#include <linux/kernel.h>
#include <asm/cacheflush.h>
@@ -2446,9 +2447,9 @@ bool bpf_jit_supports_far_kfunc_call(void)
return true;
}
-int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t,
- enum bpf_text_poke_type new_t, void *old_addr,
- void *new_addr)
+static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t,
+ enum bpf_text_poke_type new_t, void *old_addr,
+ void *new_addr)
{
struct bpf_plt expected_plt, current_plt, new_plt, *plt;
struct {
@@ -2458,6 +2459,8 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t,
char *ret;
int err;
+ guard(mutex)(&text_mutex);
+
/* Verify the branch to be patched. */
err = copy_from_kernel_nofault(&insn, ip, sizeof(insn));
if (err < 0)
@@ -2491,10 +2494,20 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t,
/* Adjust the mask of the branch. */
insn.opc = 0xc004 | (new_addr ? 0xf0 : 0);
s390_kernel_write((char *)ip + 1, (char *)&insn.opc + 1, 1);
+ return 0;
+}
+int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t,
+ enum bpf_text_poke_type new_t, void *old_addr,
+ void *new_addr)
+{
+ int err;
+
+ err = __bpf_arch_text_poke(ip, old_t, new_t, old_addr, new_addr);
+ if (err)
+ return err;
/* Make the new code visible to the other CPUs. */
text_poke_sync_lock();
-
return 0;
}
--
2.53.0
next prev parent reply other threads:[~2026-10-26 12:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 12:03 [PATCH 0/4] s390: Consistent usage of text_mutex Heiko Carstens
2026-10-26 12:03 ` [PATCH 1/4] s390/jump_label: Serialize text patching with text_mutex Heiko Carstens
2026-10-26 12:03 ` [PATCH 2/4] s390/ftrace: " Heiko Carstens
2026-10-26 12:03 ` Heiko Carstens [this message]
2026-10-26 12:03 ` [PATCH 4/4] s390/maccess: Remove spinlock from __s390_kernel_write() Heiko Carstens
2026-10-26 13:04 ` Ilya Leoshkevich
2026-10-26 14:19 ` Heiko Carstens
2026-10-27 10:09 ` kernel test robot
2026-10-27 10:09 ` kernel test robot
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=20261026120329.1792436-4-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
all inboxes | Powered by JetHome®