[PATCH v2 07/10] s390/nospec-branch: Serialize text patching with text_mutex
From: Heiko Carstens
Date: Tue Oct 27 2026 - 10:31:44 EST
Acquire text_mutex inside __nospec_revert() around the patching loop.
Serialization is not required for __nospec_revert(), however this is
part of larger series where at the end s390_kernel_write() requires
that callers hold text_mutex.
Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
arch/s390/kernel/nospec-branch.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/s390/kernel/nospec-branch.c b/arch/s390/kernel/nospec-branch.c
index e11ec15960a1..26cd5b278e8a 100644
--- a/arch/s390/kernel/nospec-branch.c
+++ b/arch/s390/kernel/nospec-branch.c
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/memory.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/cpu.h>
@@ -108,6 +109,7 @@ static void __init_or_module __nospec_revert(s32 *start, s32 *end)
/* Second part of the instruction replace is always a nop */
memcpy(insnbuf + 2, branch, sizeof(branch));
+ guard(mutex)(&text_mutex);
for (epo = start; epo < end; epo++) {
instr = (u8 *) epo + *epo;
if (instr[0] == 0xc0 && (instr[1] & 0x0f) == 0x04)
--
2.53.0