[PATCH v1] riscv: disable runtime constant support for XIP kernels
From: Charles Mirabile
Date: Fri Mar 20 2026 - 11:59:14 EST
Runtime constant support is predicated on patching the kernel binary at
runtime, which is fundamentally impossible for an XIP kernel whose text
section is backed not by RAM but by memory mapped read-only storage.
If CONFIG_XIP_KERNEL is enabled, do not define riscv implementations of
the relevant runtime constant macros so that the fallbacks which do not
perform runtime constant optimization are used.
Fixes: a44fb5722199 ("riscv: Add runtime constant support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Charles Mirabile <cmirabil@xxxxxxxxxx>
---
arch/riscv/include/asm/runtime-const.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/riscv/include/asm/runtime-const.h b/arch/riscv/include/asm/runtime-const.h
index d766e2b9e6df1..05110bb7554e9 100644
--- a/arch/riscv/include/asm/runtime-const.h
+++ b/arch/riscv/include/asm/runtime-const.h
@@ -11,6 +11,9 @@
#include <linux/uaccess.h>
+/* patching of the kernel text is fundamentally impossible on XIP kernels */
+#ifndef CONFIG_XIP_KERNEL
+
#ifdef CONFIG_32BIT
#define runtime_const_ptr(sym) \
({ \
@@ -265,4 +268,5 @@ static inline void runtime_const_fixup(void (*fn)(void *, unsigned long),
}
}
+#endif /* !CONFIG_XIP_KERNEL */
#endif /* _ASM_RISCV_RUNTIME_CONST_H */
base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c
--
2.53.0