kvm_asm.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * Copyright IBM Corp. 2008
  5. *
  6. * Authors: Hollis Blanchard <[email protected]>
  7. */
  8. #ifndef __POWERPC_KVM_ASM_H__
  9. #define __POWERPC_KVM_ASM_H__
  10. #ifdef __ASSEMBLY__
  11. #ifdef CONFIG_64BIT
  12. #define PPC_STD(sreg, offset, areg) std sreg, (offset)(areg)
  13. #define PPC_LD(treg, offset, areg) ld treg, (offset)(areg)
  14. #else
  15. #define PPC_STD(sreg, offset, areg) stw sreg, (offset+4)(areg)
  16. #define PPC_LD(treg, offset, areg) lwz treg, (offset+4)(areg)
  17. #endif
  18. #endif
  19. /* IVPR must be 64KiB-aligned. */
  20. #define VCPU_SIZE_ORDER 4
  21. #define VCPU_SIZE_LOG (VCPU_SIZE_ORDER + 12)
  22. #define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG)
  23. #define BOOKE_INTERRUPT_CRITICAL 0
  24. #define BOOKE_INTERRUPT_MACHINE_CHECK 1
  25. #define BOOKE_INTERRUPT_DATA_STORAGE 2
  26. #define BOOKE_INTERRUPT_INST_STORAGE 3
  27. #define BOOKE_INTERRUPT_EXTERNAL 4
  28. #define BOOKE_INTERRUPT_ALIGNMENT 5
  29. #define BOOKE_INTERRUPT_PROGRAM 6
  30. #define BOOKE_INTERRUPT_FP_UNAVAIL 7
  31. #define BOOKE_INTERRUPT_SYSCALL 8
  32. #define BOOKE_INTERRUPT_AP_UNAVAIL 9
  33. #define BOOKE_INTERRUPT_DECREMENTER 10
  34. #define BOOKE_INTERRUPT_FIT 11
  35. #define BOOKE_INTERRUPT_WATCHDOG 12
  36. #define BOOKE_INTERRUPT_DTLB_MISS 13
  37. #define BOOKE_INTERRUPT_ITLB_MISS 14
  38. #define BOOKE_INTERRUPT_DEBUG 15
  39. /* E500 */
  40. #ifdef CONFIG_SPE_POSSIBLE
  41. #define BOOKE_INTERRUPT_SPE_UNAVAIL 32
  42. #define BOOKE_INTERRUPT_SPE_FP_DATA 33
  43. #define BOOKE_INTERRUPT_SPE_FP_ROUND 34
  44. #endif
  45. #ifdef CONFIG_PPC_E500MC
  46. #define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 32
  47. #define BOOKE_INTERRUPT_ALTIVEC_ASSIST 33
  48. #endif
  49. #define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35
  50. #define BOOKE_INTERRUPT_DOORBELL 36
  51. #define BOOKE_INTERRUPT_DOORBELL_CRITICAL 37
  52. /* booke_hv */
  53. #define BOOKE_INTERRUPT_GUEST_DBELL 38
  54. #define BOOKE_INTERRUPT_GUEST_DBELL_CRIT 39
  55. #define BOOKE_INTERRUPT_HV_SYSCALL 40
  56. #define BOOKE_INTERRUPT_HV_PRIV 41
  57. #define BOOKE_INTERRUPT_LRAT_ERROR 42
  58. /* book3s */
  59. #define BOOK3S_INTERRUPT_SYSTEM_RESET 0x100
  60. #define BOOK3S_INTERRUPT_MACHINE_CHECK 0x200
  61. #define BOOK3S_INTERRUPT_DATA_STORAGE 0x300
  62. #define BOOK3S_INTERRUPT_DATA_SEGMENT 0x380
  63. #define BOOK3S_INTERRUPT_INST_STORAGE 0x400
  64. #define BOOK3S_INTERRUPT_INST_SEGMENT 0x480
  65. #define BOOK3S_INTERRUPT_EXTERNAL 0x500
  66. #define BOOK3S_INTERRUPT_EXTERNAL_HV 0x502
  67. #define BOOK3S_INTERRUPT_ALIGNMENT 0x600
  68. #define BOOK3S_INTERRUPT_PROGRAM 0x700
  69. #define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800
  70. #define BOOK3S_INTERRUPT_DECREMENTER 0x900
  71. #define BOOK3S_INTERRUPT_HV_DECREMENTER 0x980
  72. #define BOOK3S_INTERRUPT_NESTED_HV_DECREMENTER 0x1980
  73. #define BOOK3S_INTERRUPT_DOORBELL 0xa00
  74. #define BOOK3S_INTERRUPT_SYSCALL 0xc00
  75. #define BOOK3S_INTERRUPT_TRACE 0xd00
  76. #define BOOK3S_INTERRUPT_H_DATA_STORAGE 0xe00
  77. #define BOOK3S_INTERRUPT_H_INST_STORAGE 0xe20
  78. #define BOOK3S_INTERRUPT_H_EMUL_ASSIST 0xe40
  79. #define BOOK3S_INTERRUPT_HMI 0xe60
  80. #define BOOK3S_INTERRUPT_H_DOORBELL 0xe80
  81. #define BOOK3S_INTERRUPT_H_VIRT 0xea0
  82. #define BOOK3S_INTERRUPT_PERFMON 0xf00
  83. #define BOOK3S_INTERRUPT_ALTIVEC 0xf20
  84. #define BOOK3S_INTERRUPT_VSX 0xf40
  85. #define BOOK3S_INTERRUPT_FAC_UNAVAIL 0xf60
  86. #define BOOK3S_INTERRUPT_H_FAC_UNAVAIL 0xf80
  87. /* book3s_hv */
  88. #define BOOK3S_INTERRUPT_HV_SOFTPATCH 0x1500
  89. /*
  90. * Special trap used to indicate to host that this is a
  91. * passthrough interrupt that could not be handled
  92. * completely in the guest.
  93. */
  94. #define BOOK3S_INTERRUPT_HV_RM_HARD 0x5555
  95. #define BOOK3S_IRQPRIO_SYSTEM_RESET 0
  96. #define BOOK3S_IRQPRIO_DATA_SEGMENT 1
  97. #define BOOK3S_IRQPRIO_INST_SEGMENT 2
  98. #define BOOK3S_IRQPRIO_DATA_STORAGE 3
  99. #define BOOK3S_IRQPRIO_INST_STORAGE 4
  100. #define BOOK3S_IRQPRIO_ALIGNMENT 5
  101. #define BOOK3S_IRQPRIO_PROGRAM 6
  102. #define BOOK3S_IRQPRIO_FP_UNAVAIL 7
  103. #define BOOK3S_IRQPRIO_ALTIVEC 8
  104. #define BOOK3S_IRQPRIO_VSX 9
  105. #define BOOK3S_IRQPRIO_FAC_UNAVAIL 10
  106. #define BOOK3S_IRQPRIO_SYSCALL 11
  107. #define BOOK3S_IRQPRIO_MACHINE_CHECK 12
  108. #define BOOK3S_IRQPRIO_DEBUG 13
  109. #define BOOK3S_IRQPRIO_EXTERNAL 14
  110. #define BOOK3S_IRQPRIO_DECREMENTER 15
  111. #define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 16
  112. #define BOOK3S_IRQPRIO_MAX 17
  113. #define BOOK3S_HFLAG_DCBZ32 0x1
  114. #define BOOK3S_HFLAG_SLB 0x2
  115. #define BOOK3S_HFLAG_PAIRED_SINGLE 0x4
  116. #define BOOK3S_HFLAG_NATIVE_PS 0x8
  117. #define BOOK3S_HFLAG_MULTI_PGSIZE 0x10
  118. #define BOOK3S_HFLAG_NEW_TLBIE 0x20
  119. #define BOOK3S_HFLAG_SPLIT_HACK 0x40
  120. #define RESUME_FLAG_NV (1<<0) /* Reload guest nonvolatile state? */
  121. #define RESUME_FLAG_HOST (1<<1) /* Resume host? */
  122. #define RESUME_FLAG_ARCH1 (1<<2)
  123. #define RESUME_FLAG_ARCH2 (1<<3)
  124. #define RESUME_GUEST 0
  125. #define RESUME_GUEST_NV RESUME_FLAG_NV
  126. #define RESUME_HOST RESUME_FLAG_HOST
  127. #define RESUME_HOST_NV (RESUME_FLAG_HOST|RESUME_FLAG_NV)
  128. #define KVM_GUEST_MODE_NONE 0
  129. #define KVM_GUEST_MODE_GUEST 1
  130. #define KVM_GUEST_MODE_SKIP 2
  131. #define KVM_GUEST_MODE_GUEST_HV 3
  132. #define KVM_GUEST_MODE_HOST_HV 4
  133. #define KVM_GUEST_MODE_HV_P9 5 /* ISA >= v3.0 path */
  134. #define KVM_INST_FETCH_FAILED -1
  135. /* Extract PO and XOP opcode fields */
  136. #define PO_XOP_OPCODE_MASK 0xfc0007fe
  137. #endif /* __POWERPC_KVM_ASM_H__ */