kvm.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License, version 2, as
  4. * published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License
  12. * along with this program; if not, write to the Free Software
  13. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. *
  15. * Copyright IBM Corp. 2007
  16. *
  17. * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  18. */
  19. #ifndef __LINUX_KVM_POWERPC_H
  20. #define __LINUX_KVM_POWERPC_H
  21. #include <linux/types.h>
  22. /* Select powerpc specific features in <linux/kvm.h> */
  23. #define __KVM_HAVE_SPAPR_TCE
  24. #define __KVM_HAVE_PPC_SMT
  25. #define __KVM_HAVE_IRQCHIP
  26. #define __KVM_HAVE_IRQ_LINE
  27. #define __KVM_HAVE_GUEST_DEBUG
  28. struct kvm_regs {
  29. __u64 pc;
  30. __u64 cr;
  31. __u64 ctr;
  32. __u64 lr;
  33. __u64 xer;
  34. __u64 msr;
  35. __u64 srr0;
  36. __u64 srr1;
  37. __u64 pid;
  38. __u64 sprg0;
  39. __u64 sprg1;
  40. __u64 sprg2;
  41. __u64 sprg3;
  42. __u64 sprg4;
  43. __u64 sprg5;
  44. __u64 sprg6;
  45. __u64 sprg7;
  46. __u64 gpr[32];
  47. };
  48. #define KVM_SREGS_E_IMPL_NONE 0
  49. #define KVM_SREGS_E_IMPL_FSL 1
  50. #define KVM_SREGS_E_FSL_PIDn (1 << 0) /* PID1/PID2 */
  51. /*
  52. * Feature bits indicate which sections of the sregs struct are valid,
  53. * both in KVM_GET_SREGS and KVM_SET_SREGS. On KVM_SET_SREGS, registers
  54. * corresponding to unset feature bits will not be modified. This allows
  55. * restoring a checkpoint made without that feature, while keeping the
  56. * default values of the new registers.
  57. *
  58. * KVM_SREGS_E_BASE contains:
  59. * CSRR0/1 (refers to SRR2/3 on 40x)
  60. * ESR
  61. * DEAR
  62. * MCSR
  63. * TSR
  64. * TCR
  65. * DEC
  66. * TB
  67. * VRSAVE (USPRG0)
  68. */
  69. #define KVM_SREGS_E_BASE (1 << 0)
  70. /*
  71. * KVM_SREGS_E_ARCH206 contains:
  72. *
  73. * PIR
  74. * MCSRR0/1
  75. * DECAR
  76. * IVPR
  77. */
  78. #define KVM_SREGS_E_ARCH206 (1 << 1)
  79. /*
  80. * Contains EPCR, plus the upper half of 64-bit registers
  81. * that are 32-bit on 32-bit implementations.
  82. */
  83. #define KVM_SREGS_E_64 (1 << 2)
  84. #define KVM_SREGS_E_SPRG8 (1 << 3)
  85. #define KVM_SREGS_E_MCIVPR (1 << 4)
  86. /*
  87. * IVORs are used -- contains IVOR0-15, plus additional IVORs
  88. * in combination with an appropriate feature bit.
  89. */
  90. #define KVM_SREGS_E_IVOR (1 << 5)
  91. /*
  92. * Contains MAS0-4, MAS6-7, TLBnCFG, MMUCFG.
  93. * Also TLBnPS if MMUCFG[MAVN] = 1.
  94. */
  95. #define KVM_SREGS_E_ARCH206_MMU (1 << 6)
  96. /* DBSR, DBCR, IAC, DAC, DVC */
  97. #define KVM_SREGS_E_DEBUG (1 << 7)
  98. /* Enhanced debug -- DSRR0/1, SPRG9 */
  99. #define KVM_SREGS_E_ED (1 << 8)
  100. /* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */
  101. #define KVM_SREGS_E_SPE (1 << 9)
  102. /*
  103. * DEPRECATED! USE ONE_REG FOR THIS ONE!
  104. * External Proxy (EXP) -- EPR
  105. */
  106. #define KVM_SREGS_EXP (1 << 10)
  107. /* External PID (E.PD) -- EPSC/EPLC */
  108. #define KVM_SREGS_E_PD (1 << 11)
  109. /* Processor Control (E.PC) -- IVOR36-37 if KVM_SREGS_E_IVOR */
  110. #define KVM_SREGS_E_PC (1 << 12)
  111. /* Page table (E.PT) -- EPTCFG */
  112. #define KVM_SREGS_E_PT (1 << 13)
  113. /* Embedded Performance Monitor (E.PM) -- IVOR35 if KVM_SREGS_E_IVOR */
  114. #define KVM_SREGS_E_PM (1 << 14)
  115. /*
  116. * Special updates:
  117. *
  118. * Some registers may change even while a vcpu is not running.
  119. * To avoid losing these changes, by default these registers are
  120. * not updated by KVM_SET_SREGS. To force an update, set the bit
  121. * in u.e.update_special corresponding to the register to be updated.
  122. *
  123. * The update_special field is zero on return from KVM_GET_SREGS.
  124. *
  125. * When restoring a checkpoint, the caller can set update_special
  126. * to 0xffffffff to ensure that everything is restored, even new features
  127. * that the caller doesn't know about.
  128. */
  129. #define KVM_SREGS_E_UPDATE_MCSR (1 << 0)
  130. #define KVM_SREGS_E_UPDATE_TSR (1 << 1)
  131. #define KVM_SREGS_E_UPDATE_DEC (1 << 2)
  132. #define KVM_SREGS_E_UPDATE_DBSR (1 << 3)
  133. /*
  134. * In KVM_SET_SREGS, reserved/pad fields must be left untouched from a
  135. * previous KVM_GET_REGS.
  136. *
  137. * Unless otherwise indicated, setting any register with KVM_SET_SREGS
  138. * directly sets its value. It does not trigger any special semantics such
  139. * as write-one-to-clear. Calling KVM_SET_SREGS on an unmodified struct
  140. * just received from KVM_GET_SREGS is always a no-op.
  141. */
  142. struct kvm_sregs {
  143. __u32 pvr;
  144. union {
  145. struct {
  146. __u64 sdr1;
  147. struct {
  148. struct {
  149. __u64 slbe;
  150. __u64 slbv;
  151. } slb[64];
  152. } ppc64;
  153. struct {
  154. __u32 sr[16];
  155. __u64 ibat[8];
  156. __u64 dbat[8];
  157. } ppc32;
  158. } s;
  159. struct {
  160. union {
  161. struct { /* KVM_SREGS_E_IMPL_FSL */
  162. __u32 features; /* KVM_SREGS_E_FSL_ */
  163. __u32 svr;
  164. __u64 mcar;
  165. __u32 hid0;
  166. /* KVM_SREGS_E_FSL_PIDn */
  167. __u32 pid1, pid2;
  168. } fsl;
  169. __u8 pad[256];
  170. } impl;
  171. __u32 features; /* KVM_SREGS_E_ */
  172. __u32 impl_id; /* KVM_SREGS_E_IMPL_ */
  173. __u32 update_special; /* KVM_SREGS_E_UPDATE_ */
  174. __u32 pir; /* read-only */
  175. __u64 sprg8;
  176. __u64 sprg9; /* E.ED */
  177. __u64 csrr0;
  178. __u64 dsrr0; /* E.ED */
  179. __u64 mcsrr0;
  180. __u32 csrr1;
  181. __u32 dsrr1; /* E.ED */
  182. __u32 mcsrr1;
  183. __u32 esr;
  184. __u64 dear;
  185. __u64 ivpr;
  186. __u64 mcivpr;
  187. __u64 mcsr; /* KVM_SREGS_E_UPDATE_MCSR */
  188. __u32 tsr; /* KVM_SREGS_E_UPDATE_TSR */
  189. __u32 tcr;
  190. __u32 decar;
  191. __u32 dec; /* KVM_SREGS_E_UPDATE_DEC */
  192. /*
  193. * Userspace can read TB directly, but the
  194. * value reported here is consistent with "dec".
  195. *
  196. * Read-only.
  197. */
  198. __u64 tb;
  199. __u32 dbsr; /* KVM_SREGS_E_UPDATE_DBSR */
  200. __u32 dbcr[3];
  201. /*
  202. * iac/dac registers are 64bit wide, while this API
  203. * interface provides only lower 32 bits on 64 bit
  204. * processors. ONE_REG interface is added for 64bit
  205. * iac/dac registers.
  206. */
  207. __u32 iac[4];
  208. __u32 dac[2];
  209. __u32 dvc[2];
  210. __u8 num_iac; /* read-only */
  211. __u8 num_dac; /* read-only */
  212. __u8 num_dvc; /* read-only */
  213. __u8 pad;
  214. __u32 epr; /* EXP */
  215. __u32 vrsave; /* a.k.a. USPRG0 */
  216. __u32 epcr; /* KVM_SREGS_E_64 */
  217. __u32 mas0;
  218. __u32 mas1;
  219. __u64 mas2;
  220. __u64 mas7_3;
  221. __u32 mas4;
  222. __u32 mas6;
  223. __u32 ivor_low[16]; /* IVOR0-15 */
  224. __u32 ivor_high[18]; /* IVOR32+, plus room to expand */
  225. __u32 mmucfg; /* read-only */
  226. __u32 eptcfg; /* E.PT, read-only */
  227. __u32 tlbcfg[4];/* read-only */
  228. __u32 tlbps[4]; /* read-only */
  229. __u32 eplc, epsc; /* E.PD */
  230. } e;
  231. __u8 pad[1020];
  232. } u;
  233. };
  234. struct kvm_fpu {
  235. __u64 fpr[32];
  236. };
  237. /*
  238. * Defines for h/w breakpoint, watchpoint (read, write or both) and
  239. * software breakpoint.
  240. * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
  241. * for KVM_DEBUG_EXIT.
  242. */
  243. #define KVMPPC_DEBUG_NONE 0x0
  244. #define KVMPPC_DEBUG_BREAKPOINT (1UL << 1)
  245. #define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
  246. #define KVMPPC_DEBUG_WATCH_READ (1UL << 3)
  247. struct kvm_debug_exit_arch {
  248. __u64 address;
  249. /*
  250. * exiting to userspace because of h/w breakpoint, watchpoint
  251. * (read, write or both) and software breakpoint.
  252. */
  253. __u32 status;
  254. __u32 reserved;
  255. };
  256. /* for KVM_SET_GUEST_DEBUG */
  257. struct kvm_guest_debug_arch {
  258. struct {
  259. /* H/W breakpoint/watchpoint address */
  260. __u64 addr;
  261. /*
  262. * Type denotes h/w breakpoint, read watchpoint, write
  263. * watchpoint or watchpoint (both read and write).
  264. */
  265. __u32 type;
  266. __u32 reserved;
  267. } bp[16];
  268. };
  269. /* Debug related defines */
  270. /*
  271. * kvm_guest_debug->control is a 32 bit field. The lower 16 bits are generic
  272. * and upper 16 bits are architecture specific. Architecture specific defines
  273. * that ioctl is for setting hardware breakpoint or software breakpoint.
  274. */
  275. #define KVM_GUESTDBG_USE_SW_BP 0x00010000
  276. #define KVM_GUESTDBG_USE_HW_BP 0x00020000
  277. /* definition of registers in kvm_run */
  278. struct kvm_sync_regs {
  279. };
  280. #define KVM_INTERRUPT_SET -1U
  281. #define KVM_INTERRUPT_UNSET -2U
  282. #define KVM_INTERRUPT_SET_LEVEL -3U
  283. #define KVM_CPU_440 1
  284. #define KVM_CPU_E500V2 2
  285. #define KVM_CPU_3S_32 3
  286. #define KVM_CPU_3S_64 4
  287. #define KVM_CPU_E500MC 5
  288. /* for KVM_CAP_SPAPR_TCE */
  289. struct kvm_create_spapr_tce {
  290. __u64 liobn;
  291. __u32 window_size;
  292. };
  293. /* for KVM_CAP_SPAPR_TCE_64 */
  294. struct kvm_create_spapr_tce_64 {
  295. __u64 liobn;
  296. __u32 page_shift;
  297. __u32 flags;
  298. __u64 offset; /* in pages */
  299. __u64 size; /* in pages */
  300. };
  301. /* for KVM_ALLOCATE_RMA */
  302. struct kvm_allocate_rma {
  303. __u64 rma_size;
  304. };
  305. /* for KVM_CAP_PPC_RTAS */
  306. struct kvm_rtas_token_args {
  307. char name[120];
  308. __u64 token; /* Use a token of 0 to undefine a mapping */
  309. };
  310. struct kvm_book3e_206_tlb_entry {
  311. __u32 mas8;
  312. __u32 mas1;
  313. __u64 mas2;
  314. __u64 mas7_3;
  315. };
  316. struct kvm_book3e_206_tlb_params {
  317. /*
  318. * For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
  319. *
  320. * - The number of ways of TLB0 must be a power of two between 2 and
  321. * 16.
  322. * - TLB1 must be fully associative.
  323. * - The size of TLB0 must be a multiple of the number of ways, and
  324. * the number of sets must be a power of two.
  325. * - The size of TLB1 may not exceed 64 entries.
  326. * - TLB0 supports 4 KiB pages.
  327. * - The page sizes supported by TLB1 are as indicated by
  328. * TLB1CFG (if MMUCFG[MAVN] = 0) or TLB1PS (if MMUCFG[MAVN] = 1)
  329. * as returned by KVM_GET_SREGS.
  330. * - TLB2 and TLB3 are reserved, and their entries in tlb_sizes[]
  331. * and tlb_ways[] must be zero.
  332. *
  333. * tlb_ways[n] = tlb_sizes[n] means the array is fully associative.
  334. *
  335. * KVM will adjust TLBnCFG based on the sizes configured here,
  336. * though arrays greater than 2048 entries will have TLBnCFG[NENTRY]
  337. * set to zero.
  338. */
  339. __u32 tlb_sizes[4];
  340. __u32 tlb_ways[4];
  341. __u32 reserved[8];
  342. };
  343. /* For KVM_PPC_GET_HTAB_FD */
  344. struct kvm_get_htab_fd {
  345. __u64 flags;
  346. __u64 start_index;
  347. __u64 reserved[2];
  348. };
  349. /* Values for kvm_get_htab_fd.flags */
  350. #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1)
  351. #define KVM_GET_HTAB_WRITE ((__u64)0x2)
  352. /*
  353. * Data read on the file descriptor is formatted as a series of
  354. * records, each consisting of a header followed by a series of
  355. * `n_valid' HPTEs (16 bytes each), which are all valid. Following
  356. * those valid HPTEs there are `n_invalid' invalid HPTEs, which
  357. * are not represented explicitly in the stream. The same format
  358. * is used for writing.
  359. */
  360. struct kvm_get_htab_header {
  361. __u32 index;
  362. __u16 n_valid;
  363. __u16 n_invalid;
  364. };
  365. /* Per-vcpu XICS interrupt controller state */
  366. #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
  367. #define KVM_REG_PPC_ICP_CPPR_SHIFT 56 /* current proc priority */
  368. #define KVM_REG_PPC_ICP_CPPR_MASK 0xff
  369. #define KVM_REG_PPC_ICP_XISR_SHIFT 32 /* interrupt status field */
  370. #define KVM_REG_PPC_ICP_XISR_MASK 0xffffff
  371. #define KVM_REG_PPC_ICP_MFRR_SHIFT 24 /* pending IPI priority */
  372. #define KVM_REG_PPC_ICP_MFRR_MASK 0xff
  373. #define KVM_REG_PPC_ICP_PPRI_SHIFT 16 /* pending irq priority */
  374. #define KVM_REG_PPC_ICP_PPRI_MASK 0xff
  375. /* Device control API: PPC-specific devices */
  376. #define KVM_DEV_MPIC_GRP_MISC 1
  377. #define KVM_DEV_MPIC_BASE_ADDR 0 /* 64-bit */
  378. #define KVM_DEV_MPIC_GRP_REGISTER 2 /* 32-bit */
  379. #define KVM_DEV_MPIC_GRP_IRQ_ACTIVE 3 /* 32-bit */
  380. /* One-Reg API: PPC-specific registers */
  381. #define KVM_REG_PPC_HIOR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1)
  382. #define KVM_REG_PPC_IAC1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x2)
  383. #define KVM_REG_PPC_IAC2 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x3)
  384. #define KVM_REG_PPC_IAC3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x4)
  385. #define KVM_REG_PPC_IAC4 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x5)
  386. #define KVM_REG_PPC_DAC1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x6)
  387. #define KVM_REG_PPC_DAC2 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x7)
  388. #define KVM_REG_PPC_DABR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8)
  389. #define KVM_REG_PPC_DSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x9)
  390. #define KVM_REG_PPC_PURR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa)
  391. #define KVM_REG_PPC_SPURR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb)
  392. #define KVM_REG_PPC_DAR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc)
  393. #define KVM_REG_PPC_DSISR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xd)
  394. #define KVM_REG_PPC_AMR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xe)
  395. #define KVM_REG_PPC_UAMOR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xf)
  396. #define KVM_REG_PPC_MMCR0 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x10)
  397. #define KVM_REG_PPC_MMCR1 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x11)
  398. #define KVM_REG_PPC_MMCRA (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x12)
  399. #define KVM_REG_PPC_MMCR2 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x13)
  400. #define KVM_REG_PPC_MMCRS (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x14)
  401. #define KVM_REG_PPC_SIAR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x15)
  402. #define KVM_REG_PPC_SDAR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x16)
  403. #define KVM_REG_PPC_SIER (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x17)
  404. #define KVM_REG_PPC_PMC1 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x18)
  405. #define KVM_REG_PPC_PMC2 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x19)
  406. #define KVM_REG_PPC_PMC3 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x1a)
  407. #define KVM_REG_PPC_PMC4 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x1b)
  408. #define KVM_REG_PPC_PMC5 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x1c)
  409. #define KVM_REG_PPC_PMC6 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x1d)
  410. #define KVM_REG_PPC_PMC7 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x1e)
  411. #define KVM_REG_PPC_PMC8 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x1f)
  412. /* 32 floating-point registers */
  413. #define KVM_REG_PPC_FPR0 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x20)
  414. #define KVM_REG_PPC_FPR(n) (KVM_REG_PPC_FPR0 + (n))
  415. #define KVM_REG_PPC_FPR31 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x3f)
  416. /* 32 VMX/Altivec vector registers */
  417. #define KVM_REG_PPC_VR0 (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x40)
  418. #define KVM_REG_PPC_VR(n) (KVM_REG_PPC_VR0 + (n))
  419. #define KVM_REG_PPC_VR31 (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x5f)
  420. /* 32 double-width FP registers for VSX */
  421. /* High-order halves overlap with FP regs */
  422. #define KVM_REG_PPC_VSR0 (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x60)
  423. #define KVM_REG_PPC_VSR(n) (KVM_REG_PPC_VSR0 + (n))
  424. #define KVM_REG_PPC_VSR31 (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x7f)
  425. /* FP and vector status/control registers */
  426. #define KVM_REG_PPC_FPSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x80)
  427. /*
  428. * VSCR register is documented as a 32-bit register in the ISA, but it can
  429. * only be accesses via a vector register. Expose VSCR as a 32-bit register
  430. * even though the kernel represents it as a 128-bit vector.
  431. */
  432. #define KVM_REG_PPC_VSCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x81)
  433. /* Virtual processor areas */
  434. /* For SLB & DTL, address in high (first) half, length in low half */
  435. #define KVM_REG_PPC_VPA_ADDR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x82)
  436. #define KVM_REG_PPC_VPA_SLB (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83)
  437. #define KVM_REG_PPC_VPA_DTL (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84)
  438. #define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85)
  439. #define KVM_REG_PPC_EPR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x86)
  440. /* Timer Status Register OR/CLEAR interface */
  441. #define KVM_REG_PPC_OR_TSR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x87)
  442. #define KVM_REG_PPC_CLEAR_TSR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x88)
  443. #define KVM_REG_PPC_TCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x89)
  444. #define KVM_REG_PPC_TSR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x8a)
  445. /* Debugging: Special instruction for software breakpoint */
  446. #define KVM_REG_PPC_DEBUG_INST (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x8b)
  447. /* MMU registers */
  448. #define KVM_REG_PPC_MAS0 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x8c)
  449. #define KVM_REG_PPC_MAS1 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x8d)
  450. #define KVM_REG_PPC_MAS2 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8e)
  451. #define KVM_REG_PPC_MAS7_3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8f)
  452. #define KVM_REG_PPC_MAS4 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x90)
  453. #define KVM_REG_PPC_MAS6 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x91)
  454. #define KVM_REG_PPC_MMUCFG (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x92)
  455. /*
  456. * TLBnCFG fields TLBnCFG_N_ENTRY and TLBnCFG_ASSOC can be changed only using
  457. * KVM_CAP_SW_TLB ioctl
  458. */
  459. #define KVM_REG_PPC_TLB0CFG (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x93)
  460. #define KVM_REG_PPC_TLB1CFG (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x94)
  461. #define KVM_REG_PPC_TLB2CFG (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x95)
  462. #define KVM_REG_PPC_TLB3CFG (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x96)
  463. #define KVM_REG_PPC_TLB0PS (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x97)
  464. #define KVM_REG_PPC_TLB1PS (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x98)
  465. #define KVM_REG_PPC_TLB2PS (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x99)
  466. #define KVM_REG_PPC_TLB3PS (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x9a)
  467. #define KVM_REG_PPC_EPTCFG (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x9b)
  468. /* Timebase offset */
  469. #define KVM_REG_PPC_TB_OFFSET (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x9c)
  470. /* POWER8 registers */
  471. #define KVM_REG_PPC_SPMC1 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x9d)
  472. #define KVM_REG_PPC_SPMC2 (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x9e)
  473. #define KVM_REG_PPC_IAMR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x9f)
  474. #define KVM_REG_PPC_TFHAR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa0)
  475. #define KVM_REG_PPC_TFIAR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa1)
  476. #define KVM_REG_PPC_TEXASR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa2)
  477. #define KVM_REG_PPC_FSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa3)
  478. #define KVM_REG_PPC_PSPB (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xa4)
  479. #define KVM_REG_PPC_EBBHR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa5)
  480. #define KVM_REG_PPC_EBBRR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa6)
  481. #define KVM_REG_PPC_BESCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa7)
  482. #define KVM_REG_PPC_TAR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa8)
  483. #define KVM_REG_PPC_DPDES (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xa9)
  484. #define KVM_REG_PPC_DAWR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xaa)
  485. #define KVM_REG_PPC_DAWRX (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xab)
  486. #define KVM_REG_PPC_CIABR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xac)
  487. #define KVM_REG_PPC_IC (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xad)
  488. #define KVM_REG_PPC_VTB (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xae)
  489. #define KVM_REG_PPC_CSIGR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xaf)
  490. #define KVM_REG_PPC_TACR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb0)
  491. #define KVM_REG_PPC_TCSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb1)
  492. #define KVM_REG_PPC_PID (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb2)
  493. #define KVM_REG_PPC_ACOP (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb3)
  494. #define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)
  495. #define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)
  496. #define KVM_REG_PPC_LPCR_64 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb5)
  497. #define KVM_REG_PPC_PPR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb6)
  498. /* Architecture compatibility level */
  499. #define KVM_REG_PPC_ARCH_COMPAT (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb7)
  500. #define KVM_REG_PPC_DABRX (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb8)
  501. #define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb9)
  502. #define KVM_REG_PPC_SPRG9 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xba)
  503. #define KVM_REG_PPC_DBSR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbb)
  504. /* Transactional Memory checkpointed state:
  505. * This is all GPRs, all VSX regs and a subset of SPRs
  506. */
  507. #define KVM_REG_PPC_TM (KVM_REG_PPC | 0x80000000)
  508. /* TM GPRs */
  509. #define KVM_REG_PPC_TM_GPR0 (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0)
  510. #define KVM_REG_PPC_TM_GPR(n) (KVM_REG_PPC_TM_GPR0 + (n))
  511. #define KVM_REG_PPC_TM_GPR31 (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x1f)
  512. /* TM VSX */
  513. #define KVM_REG_PPC_TM_VSR0 (KVM_REG_PPC_TM | KVM_REG_SIZE_U128 | 0x20)
  514. #define KVM_REG_PPC_TM_VSR(n) (KVM_REG_PPC_TM_VSR0 + (n))
  515. #define KVM_REG_PPC_TM_VSR63 (KVM_REG_PPC_TM | KVM_REG_SIZE_U128 | 0x5f)
  516. /* TM SPRS */
  517. #define KVM_REG_PPC_TM_CR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x60)
  518. #define KVM_REG_PPC_TM_LR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x61)
  519. #define KVM_REG_PPC_TM_CTR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x62)
  520. #define KVM_REG_PPC_TM_FPSCR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x63)
  521. #define KVM_REG_PPC_TM_AMR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x64)
  522. #define KVM_REG_PPC_TM_PPR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x65)
  523. #define KVM_REG_PPC_TM_VRSAVE (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x66)
  524. #define KVM_REG_PPC_TM_VSCR (KVM_REG_PPC_TM | KVM_REG_SIZE_U32 | 0x67)
  525. #define KVM_REG_PPC_TM_DSCR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x68)
  526. #define KVM_REG_PPC_TM_TAR (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x69)
  527. #define KVM_REG_PPC_TM_XER (KVM_REG_PPC_TM | KVM_REG_SIZE_U64 | 0x6a)
  528. /* PPC64 eXternal Interrupt Controller Specification */
  529. #define KVM_DEV_XICS_GRP_SOURCES 1 /* 64-bit source attributes */
  530. /* Layout of 64-bit source attribute values */
  531. #define KVM_XICS_DESTINATION_SHIFT 0
  532. #define KVM_XICS_DESTINATION_MASK 0xffffffffULL
  533. #define KVM_XICS_PRIORITY_SHIFT 32
  534. #define KVM_XICS_PRIORITY_MASK 0xff
  535. #define KVM_XICS_LEVEL_SENSITIVE (1ULL << 40)
  536. #define KVM_XICS_MASKED (1ULL << 41)
  537. #define KVM_XICS_PENDING (1ULL << 42)
  538. #endif /* __LINUX_KVM_POWERPC_H */