nops.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_NOPS_H
  3. #define _ASM_X86_NOPS_H
  4. #include <asm/asm.h>
  5. /*
  6. * Define nops for use with alternative() and for tracing.
  7. */
  8. #ifndef CONFIG_64BIT
  9. /*
  10. * Generic 32bit nops from GAS:
  11. *
  12. * 1: nop
  13. * 2: movl %esi,%esi
  14. * 3: leal 0x0(%esi),%esi
  15. * 4: leal 0x0(%esi,%eiz,1),%esi
  16. * 5: leal %ds:0x0(%esi,%eiz,1),%esi
  17. * 6: leal 0x0(%esi),%esi
  18. * 7: leal 0x0(%esi,%eiz,1),%esi
  19. * 8: leal %ds:0x0(%esi,%eiz,1),%esi
  20. *
  21. * Except 5 and 8, which are DS prefixed 4 and 7 resp, where GAS would emit 2
  22. * nop instructions.
  23. */
  24. #define BYTES_NOP1 0x90
  25. #define BYTES_NOP2 0x89,0xf6
  26. #define BYTES_NOP3 0x8d,0x76,0x00
  27. #define BYTES_NOP4 0x8d,0x74,0x26,0x00
  28. #define BYTES_NOP5 0x3e,BYTES_NOP4
  29. #define BYTES_NOP6 0x8d,0xb6,0x00,0x00,0x00,0x00
  30. #define BYTES_NOP7 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00
  31. #define BYTES_NOP8 0x3e,BYTES_NOP7
  32. #define ASM_NOP_MAX 8
  33. #else
  34. /*
  35. * Generic 64bit nops from GAS:
  36. *
  37. * 1: nop
  38. * 2: osp nop
  39. * 3: nopl (%eax)
  40. * 4: nopl 0x00(%eax)
  41. * 5: nopl 0x00(%eax,%eax,1)
  42. * 6: osp nopl 0x00(%eax,%eax,1)
  43. * 7: nopl 0x00000000(%eax)
  44. * 8: nopl 0x00000000(%eax,%eax,1)
  45. * 9: cs nopl 0x00000000(%eax,%eax,1)
  46. * 10: osp cs nopl 0x00000000(%eax,%eax,1)
  47. * 11: osp osp cs nopl 0x00000000(%eax,%eax,1)
  48. */
  49. #define BYTES_NOP1 0x90
  50. #define BYTES_NOP2 0x66,BYTES_NOP1
  51. #define BYTES_NOP3 0x0f,0x1f,0x00
  52. #define BYTES_NOP4 0x0f,0x1f,0x40,0x00
  53. #define BYTES_NOP5 0x0f,0x1f,0x44,0x00,0x00
  54. #define BYTES_NOP6 0x66,BYTES_NOP5
  55. #define BYTES_NOP7 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00
  56. #define BYTES_NOP8 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00
  57. #define BYTES_NOP9 0x2e,BYTES_NOP8
  58. #define BYTES_NOP10 0x66,BYTES_NOP9
  59. #define BYTES_NOP11 0x66,BYTES_NOP10
  60. #define ASM_NOP9 _ASM_BYTES(BYTES_NOP9)
  61. #define ASM_NOP10 _ASM_BYTES(BYTES_NOP10)
  62. #define ASM_NOP11 _ASM_BYTES(BYTES_NOP11)
  63. #define ASM_NOP_MAX 11
  64. #endif /* CONFIG_64BIT */
  65. #define ASM_NOP1 _ASM_BYTES(BYTES_NOP1)
  66. #define ASM_NOP2 _ASM_BYTES(BYTES_NOP2)
  67. #define ASM_NOP3 _ASM_BYTES(BYTES_NOP3)
  68. #define ASM_NOP4 _ASM_BYTES(BYTES_NOP4)
  69. #define ASM_NOP5 _ASM_BYTES(BYTES_NOP5)
  70. #define ASM_NOP6 _ASM_BYTES(BYTES_NOP6)
  71. #define ASM_NOP7 _ASM_BYTES(BYTES_NOP7)
  72. #define ASM_NOP8 _ASM_BYTES(BYTES_NOP8)
  73. #ifndef __ASSEMBLY__
  74. extern const unsigned char * const x86_nops[];
  75. #endif
  76. #endif /* _ASM_X86_NOPS_H */