^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __ASM_ALTERNATIVE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __ASM_ALTERNATIVE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm/alternative-macros.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct alt_instr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) s32 orig_offset; /* offset to original instruction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) s32 alt_offset; /* offset to replacement instruction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) u16 cpufeature; /* cpufeature bit set for replacement */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) u8 orig_len; /* size of original instruction(s) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) u8 alt_len; /* size of new instruction(s), <= orig_len */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) typedef void (*alternative_cb_t)(struct alt_instr *alt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) __le32 *origptr, __le32 *updptr, int nr_inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) void __init apply_boot_alternatives(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) void __init apply_alternatives_all(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) bool alternative_is_applied(u16 cpufeature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #ifdef CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void apply_alternatives_module(void *start, size_t length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static inline void apply_alternatives_module(void *start, size_t length) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #endif /* __ASM_ALTERNATIVE_H */