alternative.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_PARISC_ALTERNATIVE_H
  3. #define __ASM_PARISC_ALTERNATIVE_H
  4. #define ALT_COND_ALWAYS 0x80 /* always replace instruction */
  5. #define ALT_COND_NO_SMP 0x01 /* when running UP instead of SMP */
  6. #define ALT_COND_NO_DCACHE 0x02 /* if system has no d-cache */
  7. #define ALT_COND_NO_ICACHE 0x04 /* if system has no i-cache */
  8. #define ALT_COND_NO_SPLIT_TLB 0x08 /* if split_tlb == 0 */
  9. #define ALT_COND_NO_IOC_FDC 0x10 /* if I/O cache does not need flushes */
  10. #define ALT_COND_RUN_ON_QEMU 0x20 /* if running on QEMU */
  11. #define INSN_PxTLB 0x02 /* modify pdtlb, pitlb */
  12. #define INSN_NOP 0x08000240 /* nop */
  13. #ifndef __ASSEMBLY__
  14. #include <linux/init.h>
  15. #include <linux/types.h>
  16. #include <linux/stddef.h>
  17. #include <linux/stringify.h>
  18. struct alt_instr {
  19. s32 orig_offset; /* offset to original instructions */
  20. s16 len; /* end of original instructions */
  21. u16 cond; /* see ALT_COND_XXX */
  22. u32 replacement; /* replacement instruction or code */
  23. } __packed;
  24. void set_kernel_text_rw(int enable_read_write);
  25. void apply_alternatives_all(void);
  26. void apply_alternatives(struct alt_instr *start, struct alt_instr *end,
  27. const char *module_name);
  28. /* Alternative SMP implementation. */
  29. #define ALTERNATIVE(cond, replacement) "!0:" \
  30. ".section .altinstructions, \"a\" !" \
  31. ".align 4 !" \
  32. ".word (0b-4-.) !" \
  33. ".hword 1, " __stringify(cond) " !" \
  34. ".word " __stringify(replacement) " !" \
  35. ".previous"
  36. #else
  37. /* to replace one single instructions by a new instruction */
  38. #define ALTERNATIVE(from, to, cond, replacement)\
  39. .section .altinstructions, "a" ! \
  40. .align 4 ! \
  41. .word (from - .) ! \
  42. .hword (to - from)/4, cond ! \
  43. .word replacement ! \
  44. .previous
  45. /* to replace multiple instructions by new code */
  46. #define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\
  47. .section .altinstructions, "a" ! \
  48. .align 4 ! \
  49. .word (from - .) ! \
  50. .hword -num_instructions, cond ! \
  51. .word (new_instr_ptr - .) ! \
  52. .previous
  53. #endif /* __ASSEMBLY__ */
  54. #endif /* __ASM_PARISC_ALTERNATIVE_H */