kvm.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  7. * Copyright (C) 2013 Cavium, Inc.
  8. * Authors: Sanjay Lal <sanjayl@kymasys.com>
  9. */
  10. #ifndef __LINUX_KVM_MIPS_H
  11. #define __LINUX_KVM_MIPS_H
  12. #include <linux/types.h>
  13. /*
  14. * KVM MIPS specific structures and definitions.
  15. *
  16. * Some parts derived from the x86 version of this file.
  17. */
  18. /*
  19. * for KVM_GET_REGS and KVM_SET_REGS
  20. *
  21. * If Config[AT] is zero (32-bit CPU), the register contents are
  22. * stored in the lower 32-bits of the struct kvm_regs fields and sign
  23. * extended to 64-bits.
  24. */
  25. struct kvm_regs {
  26. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  27. __u64 gpr[32];
  28. __u64 hi;
  29. __u64 lo;
  30. __u64 pc;
  31. };
  32. /*
  33. * for KVM_GET_FPU and KVM_SET_FPU
  34. */
  35. struct kvm_fpu {
  36. };
  37. /*
  38. * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various
  39. * registers. The id field is broken down as follows:
  40. *
  41. * bits[63..52] - As per linux/kvm.h
  42. * bits[51..32] - Must be zero.
  43. * bits[31..16] - Register set.
  44. *
  45. * Register set = 0: GP registers from kvm_regs (see definitions below).
  46. *
  47. * Register set = 1: CP0 registers.
  48. * bits[15..8] - Must be zero.
  49. * bits[7..3] - Register 'rd' index.
  50. * bits[2..0] - Register 'sel' index.
  51. *
  52. * Register set = 2: KVM specific registers (see definitions below).
  53. *
  54. * Register set = 3: FPU / MSA registers (see definitions below).
  55. *
  56. * Other sets registers may be added in the future. Each set would
  57. * have its own identifier in bits[31..16].
  58. */
  59. #define KVM_REG_MIPS_GP (KVM_REG_MIPS | 0x0000000000000000ULL)
  60. #define KVM_REG_MIPS_CP0 (KVM_REG_MIPS | 0x0000000000010000ULL)
  61. #define KVM_REG_MIPS_KVM (KVM_REG_MIPS | 0x0000000000020000ULL)
  62. #define KVM_REG_MIPS_FPU (KVM_REG_MIPS | 0x0000000000030000ULL)
  63. /*
  64. * KVM_REG_MIPS_GP - General purpose registers from kvm_regs.
  65. */
  66. #define KVM_REG_MIPS_R0 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 0)
  67. #define KVM_REG_MIPS_R1 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 1)
  68. #define KVM_REG_MIPS_R2 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 2)
  69. #define KVM_REG_MIPS_R3 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 3)
  70. #define KVM_REG_MIPS_R4 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 4)
  71. #define KVM_REG_MIPS_R5 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 5)
  72. #define KVM_REG_MIPS_R6 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 6)
  73. #define KVM_REG_MIPS_R7 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 7)
  74. #define KVM_REG_MIPS_R8 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 8)
  75. #define KVM_REG_MIPS_R9 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 9)
  76. #define KVM_REG_MIPS_R10 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10)
  77. #define KVM_REG_MIPS_R11 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11)
  78. #define KVM_REG_MIPS_R12 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12)
  79. #define KVM_REG_MIPS_R13 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13)
  80. #define KVM_REG_MIPS_R14 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14)
  81. #define KVM_REG_MIPS_R15 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15)
  82. #define KVM_REG_MIPS_R16 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16)
  83. #define KVM_REG_MIPS_R17 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17)
  84. #define KVM_REG_MIPS_R18 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18)
  85. #define KVM_REG_MIPS_R19 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19)
  86. #define KVM_REG_MIPS_R20 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20)
  87. #define KVM_REG_MIPS_R21 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21)
  88. #define KVM_REG_MIPS_R22 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22)
  89. #define KVM_REG_MIPS_R23 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23)
  90. #define KVM_REG_MIPS_R24 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24)
  91. #define KVM_REG_MIPS_R25 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25)
  92. #define KVM_REG_MIPS_R26 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26)
  93. #define KVM_REG_MIPS_R27 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27)
  94. #define KVM_REG_MIPS_R28 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28)
  95. #define KVM_REG_MIPS_R29 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29)
  96. #define KVM_REG_MIPS_R30 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30)
  97. #define KVM_REG_MIPS_R31 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31)
  98. #define KVM_REG_MIPS_HI (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32)
  99. #define KVM_REG_MIPS_LO (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33)
  100. #define KVM_REG_MIPS_PC (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34)
  101. /*
  102. * KVM_REG_MIPS_KVM - KVM specific control registers.
  103. */
  104. /*
  105. * CP0_Count control
  106. * DC: Set 0: Master disable CP0_Count and set COUNT_RESUME to now
  107. * Set 1: Master re-enable CP0_Count with unchanged bias, handling timer
  108. * interrupts since COUNT_RESUME
  109. * This can be used to freeze the timer to get a consistent snapshot of
  110. * the CP0_Count and timer interrupt pending state, while also resuming
  111. * safely without losing time or guest timer interrupts.
  112. * Other: Reserved, do not change.
  113. */
  114. #define KVM_REG_MIPS_COUNT_CTL (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0)
  115. #define KVM_REG_MIPS_COUNT_CTL_DC 0x00000001
  116. /*
  117. * CP0_Count resume monotonic nanoseconds
  118. * The monotonic nanosecond time of the last set of COUNT_CTL.DC (master
  119. * disable). Any reads and writes of Count related registers while
  120. * COUNT_CTL.DC=1 will appear to occur at this time. When COUNT_CTL.DC is
  121. * cleared again (master enable) any timer interrupts since this time will be
  122. * emulated.
  123. * Modifications to times in the future are rejected.
  124. */
  125. #define KVM_REG_MIPS_COUNT_RESUME (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1)
  126. /*
  127. * CP0_Count rate in Hz
  128. * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without
  129. * discontinuities in CP0_Count.
  130. */
  131. #define KVM_REG_MIPS_COUNT_HZ (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2)
  132. /*
  133. * KVM_REG_MIPS_FPU - Floating Point and MIPS SIMD Architecture (MSA) registers.
  134. *
  135. * bits[15..8] - Register subset (see definitions below).
  136. * bits[7..5] - Must be zero.
  137. * bits[4..0] - Register number within register subset.
  138. */
  139. #define KVM_REG_MIPS_FPR (KVM_REG_MIPS_FPU | 0x0000000000000000ULL)
  140. #define KVM_REG_MIPS_FCR (KVM_REG_MIPS_FPU | 0x0000000000000100ULL)
  141. #define KVM_REG_MIPS_MSACR (KVM_REG_MIPS_FPU | 0x0000000000000200ULL)
  142. /*
  143. * KVM_REG_MIPS_FPR - Floating point / Vector registers.
  144. */
  145. #define KVM_REG_MIPS_FPR_32(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U32 | (n))
  146. #define KVM_REG_MIPS_FPR_64(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U64 | (n))
  147. #define KVM_REG_MIPS_VEC_128(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U128 | (n))
  148. /*
  149. * KVM_REG_MIPS_FCR - Floating point control registers.
  150. */
  151. #define KVM_REG_MIPS_FCR_IR (KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 0)
  152. #define KVM_REG_MIPS_FCR_CSR (KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 31)
  153. /*
  154. * KVM_REG_MIPS_MSACR - MIPS SIMD Architecture (MSA) control registers.
  155. */
  156. #define KVM_REG_MIPS_MSA_IR (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 | 0)
  157. #define KVM_REG_MIPS_MSA_CSR (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 | 1)
  158. /*
  159. * KVM MIPS specific structures and definitions
  160. *
  161. */
  162. struct kvm_debug_exit_arch {
  163. __u64 epc;
  164. };
  165. /* for KVM_SET_GUEST_DEBUG */
  166. struct kvm_guest_debug_arch {
  167. };
  168. /* definition of registers in kvm_run */
  169. struct kvm_sync_regs {
  170. };
  171. /* dummy definition */
  172. struct kvm_sregs {
  173. };
  174. struct kvm_mips_interrupt {
  175. /* in */
  176. __u32 cpu;
  177. __u32 irq;
  178. };
  179. #endif /* __LINUX_KVM_MIPS_H */