1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_RUNTIME_CONST_H
3 #define _ASM_S390_RUNTIME_CONST_H
5 #include <linux/uaccess.h>
7 #define runtime_const_ptr(sym) \
12 "0: iihf %[__ret],%[c1]\n" \
13 " iilf %[__ret],%[c2]\n" \
14 ".pushsection runtime_ptr_" #sym ",\"a\"\n" \
17 : [__ret] "=d" (__ret) \
18 : [c1] "i" (0x01234567UL), \
19 [c2] "i" (0x89abcdefUL)); \
23 #define runtime_const_shift_right_32(val, sym) \
25 unsigned int __ret = (val); \
28 "0: srl %[__ret],12\n" \
29 ".pushsection runtime_shift_" #sym ",\"a\"\n" \
32 : [__ret] "+d" (__ret)); \
36 #define runtime_const_init(type, sym) do { \
37 extern s32 __start_runtime_##type##_##sym[]; \
38 extern s32 __stop_runtime_##type##_##sym[]; \
40 runtime_const_fixup(__runtime_fixup_##type, \
41 (unsigned long)(sym), \
42 __start_runtime_##type##_##sym, \
43 __stop_runtime_##type##_##sym); \
46 /* 32-bit immediate for iihf and iilf in bits in I2 field */
47 static inline void __runtime_fixup_32(u32 *p, unsigned int val)
49 s390_kernel_write(p, &val, sizeof(val));
52 static inline void __runtime_fixup_ptr(void *where, unsigned long val)
54 __runtime_fixup_32(where + 2, val >> 32);
55 __runtime_fixup_32(where + 8, val);
58 /* Immediate value is lower 12 bits of D2 field of srl */
59 static inline void __runtime_fixup_shift(void *where, unsigned long val)
61 u32 insn = *(u32 *)where;
65 s390_kernel_write(where, &insn, sizeof(insn));
68 static inline void runtime_const_fixup(void (*fn)(void *, unsigned long),
69 unsigned long val, s32 *start, s32 *end)
72 fn(*start + (void *)start, val);
77 #endif /* _ASM_S390_RUNTIME_CONST_H */