alternative-asm.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_ALTERNATIVE_ASM_H
  3. #define _ASM_S390_ALTERNATIVE_ASM_H
  4. #ifdef __ASSEMBLY__
  5. /*
  6. * Issue one struct alt_instr descriptor entry (need to put it into
  7. * the section .altinstructions, see below). This entry contains
  8. * enough information for the alternatives patching code to patch an
  9. * instruction. See apply_alternatives().
  10. */
  11. .macro alt_entry orig_start, orig_end, alt_start, alt_end, feature
  12. .long \orig_start - .
  13. .long \alt_start - .
  14. .word \feature
  15. .byte \orig_end - \orig_start
  16. .org . - ( \orig_end - \orig_start ) + ( \alt_end - \alt_start )
  17. .org . - ( \alt_end - \alt_start ) + ( \orig_end - \orig_start )
  18. .endm
  19. /*
  20. * Define an alternative between two instructions. If @feature is
  21. * present, early code in apply_alternatives() replaces @oldinstr with
  22. * @newinstr.
  23. */
  24. .macro ALTERNATIVE oldinstr, newinstr, feature
  25. .pushsection .altinstr_replacement,"ax"
  26. 770: \newinstr
  27. 771: .popsection
  28. 772: \oldinstr
  29. 773: .pushsection .altinstructions,"a"
  30. alt_entry 772b, 773b, 770b, 771b, \feature
  31. .popsection
  32. .endm
  33. /*
  34. * Define an alternative between two instructions. If @feature is
  35. * present, early code in apply_alternatives() replaces @oldinstr with
  36. * @newinstr.
  37. */
  38. .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2
  39. .pushsection .altinstr_replacement,"ax"
  40. 770: \newinstr1
  41. 771: \newinstr2
  42. 772: .popsection
  43. 773: \oldinstr
  44. 774: .pushsection .altinstructions,"a"
  45. alt_entry 773b, 774b, 770b, 771b,\feature1
  46. alt_entry 773b, 774b, 771b, 772b,\feature2
  47. .popsection
  48. .endm
  49. #endif /* __ASSEMBLY__ */
  50. #endif /* _ASM_S390_ALTERNATIVE_ASM_H */