[PATCH 1/4] s390/jump_label: Serialize text patching with text_mutex
From: Heiko Carstens
Date: Mon Oct 26 2026 - 08:11:57 EST
Acquire text_mutex around the verify-then-patch sequence in
jump_label_transform(). This way s390 uses text_mutex like other
architectures and does not need to rely on other implicit semantics
(e.g. no kprobe can be set on a jump label).
This is a prereq for removing the spinlock in __s390_kernel_write().
Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
arch/s390/kernel/jump_label.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
index e808bb8bc0da..682069673f48 100644
--- a/arch/s390/kernel/jump_label.c
+++ b/arch/s390/kernel/jump_label.c
@@ -5,6 +5,7 @@
* Copyright IBM Corp. 2011
* Author(s): Jan Glauber <jang@xxxxxxxxxxxxxxxxxx>
*/
+#include <linux/memory.h>
#include <linux/uaccess.h>
#include <linux/jump_label.h>
#include <linux/module.h>
@@ -57,9 +58,11 @@ static void jump_label_transform(struct jump_entry *entry,
jump_label_make_branch(entry, &old);
jump_label_make_nop(entry, &new);
}
+ mutex_lock(&text_mutex);
if (memcmp(code, &old, sizeof(old)))
jump_label_bug(entry, &old, &new);
s390_kernel_write(code, &new, sizeof(new));
+ mutex_unlock(&text_mutex);
}
void arch_jump_label_transform(struct jump_entry *entry,
--
2.53.0