2018-10-17 04:38:22 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __ASM_PARISC_ALTERNATIVE_H
|
|
|
|
#define __ASM_PARISC_ALTERNATIVE_H
|
|
|
|
|
2018-11-10 23:14:59 +08:00
|
|
|
#define ALT_COND_ALWAYS 0x80 /* always replace instruction */
|
2018-10-17 04:38:22 +08:00
|
|
|
#define ALT_COND_NO_SMP 0x01 /* when running UP instead of SMP */
|
|
|
|
#define ALT_COND_NO_DCACHE 0x02 /* if system has no d-cache */
|
|
|
|
#define ALT_COND_NO_ICACHE 0x04 /* if system has no i-cache */
|
|
|
|
#define ALT_COND_NO_SPLIT_TLB 0x08 /* if split_tlb == 0 */
|
|
|
|
#define ALT_COND_NO_IOC_FDC 0x10 /* if I/O cache does not need flushes */
|
2019-08-13 01:11:06 +08:00
|
|
|
#define ALT_COND_RUN_ON_QEMU 0x20 /* if running on QEMU */
|
2018-10-17 04:38:22 +08:00
|
|
|
|
|
|
|
#define INSN_PxTLB 0x02 /* modify pdtlb, pitlb */
|
|
|
|
#define INSN_NOP 0x08000240 /* nop */
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/stringify.h>
|
|
|
|
|
|
|
|
struct alt_instr {
|
|
|
|
s32 orig_offset; /* offset to original instructions */
|
2022-09-29 05:31:20 +08:00
|
|
|
s16 len; /* end of original instructions */
|
|
|
|
u16 cond; /* see ALT_COND_XXX */
|
2018-10-17 04:38:22 +08:00
|
|
|
u32 replacement; /* replacement instruction or code */
|
2022-09-29 05:31:20 +08:00
|
|
|
} __packed;
|
2018-10-17 04:38:22 +08:00
|
|
|
|
|
|
|
void set_kernel_text_rw(int enable_read_write);
|
2018-11-10 23:14:59 +08:00
|
|
|
void apply_alternatives_all(void);
|
|
|
|
void apply_alternatives(struct alt_instr *start, struct alt_instr *end,
|
|
|
|
const char *module_name);
|
2018-10-17 04:38:22 +08:00
|
|
|
|
|
|
|
/* Alternative SMP implementation. */
|
|
|
|
#define ALTERNATIVE(cond, replacement) "!0:" \
|
2023-11-21 06:10:20 +08:00
|
|
|
".section .altinstructions, \"a\" !" \
|
|
|
|
".align 4 !" \
|
2022-09-29 05:31:20 +08:00
|
|
|
".word (0b-4-.) !" \
|
|
|
|
".hword 1, " __stringify(cond) " !" \
|
|
|
|
".word " __stringify(replacement) " !" \
|
2018-10-17 04:38:22 +08:00
|
|
|
".previous"
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2019-08-13 01:11:06 +08:00
|
|
|
/* to replace one single instructions by a new instruction */
|
2018-10-17 04:38:22 +08:00
|
|
|
#define ALTERNATIVE(from, to, cond, replacement)\
|
2023-11-21 06:10:20 +08:00
|
|
|
.section .altinstructions, "a" ! \
|
|
|
|
.align 4 ! \
|
2022-09-29 05:31:20 +08:00
|
|
|
.word (from - .) ! \
|
|
|
|
.hword (to - from)/4, cond ! \
|
|
|
|
.word replacement ! \
|
2018-10-17 04:38:22 +08:00
|
|
|
.previous
|
|
|
|
|
2019-08-13 01:11:06 +08:00
|
|
|
/* to replace multiple instructions by new code */
|
|
|
|
#define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\
|
2023-11-21 06:10:20 +08:00
|
|
|
.section .altinstructions, "a" ! \
|
|
|
|
.align 4 ! \
|
2022-09-29 05:31:20 +08:00
|
|
|
.word (from - .) ! \
|
|
|
|
.hword -num_instructions, cond ! \
|
|
|
|
.word (new_instr_ptr - .) ! \
|
2019-08-13 01:11:06 +08:00
|
|
|
.previous
|
|
|
|
|
2018-10-17 04:38:22 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif /* __ASM_PARISC_ALTERNATIVE_H */
|