Skip to contentSkip to conversation

riscv: disable runtime constant support for XIP kernels

PATCH New Charles Mirabile 1 participant 1 message Mar 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: disable runtime constant support for XIP kernels

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")
---
 arch/riscv/include/asm/runtime-const.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/riscv/include/asm/runtime-const.h +4 -0
index d766e2b9e6df1..05110bb7554e9 100644
@@ -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

Signature · 1 line
2.53.0