kvm_host.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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 __POWERPC_KVM_HOST_H__
  20. #define __POWERPC_KVM_HOST_H__
  21. #include <linux/mutex.h>
  22. #include <linux/hrtimer.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/types.h>
  25. #include <linux/kvm_types.h>
  26. #include <linux/threads.h>
  27. #include <linux/spinlock.h>
  28. #include <linux/kvm_para.h>
  29. #include <linux/list.h>
  30. #include <linux/atomic.h>
  31. #include <asm/kvm_asm.h>
  32. #include <asm/processor.h>
  33. #include <asm/page.h>
  34. #include <asm/cacheflush.h>
  35. #include <asm/hvcall.h>
  36. #define KVM_MAX_VCPUS NR_CPUS
  37. #define KVM_MAX_VCORES NR_CPUS
  38. #define KVM_USER_MEM_SLOTS 32
  39. #define KVM_MEM_SLOTS_NUM KVM_USER_MEM_SLOTS
  40. #ifdef CONFIG_KVM_MMIO
  41. #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
  42. #endif
  43. /* These values are internal and can be increased later */
  44. #define KVM_NR_IRQCHIPS 1
  45. #define KVM_IRQCHIP_NUM_PINS 256
  46. #include <linux/mmu_notifier.h>
  47. #define KVM_ARCH_WANT_MMU_NOTIFIER
  48. struct kvm;
  49. extern int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
  50. extern int kvm_unmap_hva_range(struct kvm *kvm,
  51. unsigned long start, unsigned long end);
  52. extern int kvm_age_hva(struct kvm *kvm, unsigned long hva);
  53. extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
  54. extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
  55. #define HPTEG_CACHE_NUM (1 << 15)
  56. #define HPTEG_HASH_BITS_PTE 13
  57. #define HPTEG_HASH_BITS_PTE_LONG 12
  58. #define HPTEG_HASH_BITS_VPTE 13
  59. #define HPTEG_HASH_BITS_VPTE_LONG 5
  60. #define HPTEG_HASH_BITS_VPTE_64K 11
  61. #define HPTEG_HASH_NUM_PTE (1 << HPTEG_HASH_BITS_PTE)
  62. #define HPTEG_HASH_NUM_PTE_LONG (1 << HPTEG_HASH_BITS_PTE_LONG)
  63. #define HPTEG_HASH_NUM_VPTE (1 << HPTEG_HASH_BITS_VPTE)
  64. #define HPTEG_HASH_NUM_VPTE_LONG (1 << HPTEG_HASH_BITS_VPTE_LONG)
  65. #define HPTEG_HASH_NUM_VPTE_64K (1 << HPTEG_HASH_BITS_VPTE_64K)
  66. /* Physical Address Mask - allowed range of real mode RAM access */
  67. #define KVM_PAM 0x0fffffffffffffffULL
  68. struct kvm;
  69. struct kvm_run;
  70. struct kvm_vcpu;
  71. struct lppaca;
  72. struct slb_shadow;
  73. struct dtl_entry;
  74. struct kvmppc_vcpu_book3s;
  75. struct kvmppc_book3s_shadow_vcpu;
  76. struct kvm_vm_stat {
  77. u32 remote_tlb_flush;
  78. };
  79. struct kvm_vcpu_stat {
  80. u32 sum_exits;
  81. u32 mmio_exits;
  82. u32 signal_exits;
  83. u32 light_exits;
  84. /* Account for special types of light exits: */
  85. u32 itlb_real_miss_exits;
  86. u32 itlb_virt_miss_exits;
  87. u32 dtlb_real_miss_exits;
  88. u32 dtlb_virt_miss_exits;
  89. u32 syscall_exits;
  90. u32 isi_exits;
  91. u32 dsi_exits;
  92. u32 emulated_inst_exits;
  93. u32 dec_exits;
  94. u32 ext_intr_exits;
  95. u32 halt_wakeup;
  96. u32 dbell_exits;
  97. u32 gdbell_exits;
  98. u32 ld;
  99. u32 st;
  100. #ifdef CONFIG_PPC_BOOK3S
  101. u32 pf_storage;
  102. u32 pf_instruc;
  103. u32 sp_storage;
  104. u32 sp_instruc;
  105. u32 queue_intr;
  106. u32 ld_slow;
  107. u32 st_slow;
  108. #endif
  109. };
  110. enum kvm_exit_types {
  111. MMIO_EXITS,
  112. SIGNAL_EXITS,
  113. ITLB_REAL_MISS_EXITS,
  114. ITLB_VIRT_MISS_EXITS,
  115. DTLB_REAL_MISS_EXITS,
  116. DTLB_VIRT_MISS_EXITS,
  117. SYSCALL_EXITS,
  118. ISI_EXITS,
  119. DSI_EXITS,
  120. EMULATED_INST_EXITS,
  121. EMULATED_MTMSRWE_EXITS,
  122. EMULATED_WRTEE_EXITS,
  123. EMULATED_MTSPR_EXITS,
  124. EMULATED_MFSPR_EXITS,
  125. EMULATED_MTMSR_EXITS,
  126. EMULATED_MFMSR_EXITS,
  127. EMULATED_TLBSX_EXITS,
  128. EMULATED_TLBWE_EXITS,
  129. EMULATED_RFI_EXITS,
  130. EMULATED_RFCI_EXITS,
  131. DEC_EXITS,
  132. EXT_INTR_EXITS,
  133. HALT_WAKEUP,
  134. USR_PR_INST,
  135. FP_UNAVAIL,
  136. DEBUG_EXITS,
  137. TIMEINGUEST,
  138. DBELL_EXITS,
  139. GDBELL_EXITS,
  140. __NUMBER_OF_KVM_EXIT_TYPES
  141. };
  142. /* allow access to big endian 32bit upper/lower parts and 64bit var */
  143. struct kvmppc_exit_timing {
  144. union {
  145. u64 tv64;
  146. struct {
  147. u32 tbu, tbl;
  148. } tv32;
  149. };
  150. };
  151. struct kvmppc_pginfo {
  152. unsigned long pfn;
  153. atomic_t refcnt;
  154. };
  155. struct kvmppc_spapr_tce_table {
  156. struct list_head list;
  157. struct kvm *kvm;
  158. u64 liobn;
  159. u32 window_size;
  160. struct page *pages[0];
  161. };
  162. struct kvm_rma_info {
  163. atomic_t use_count;
  164. unsigned long base_pfn;
  165. };
  166. /* XICS components, defined in book3s_xics.c */
  167. struct kvmppc_xics;
  168. struct kvmppc_icp;
  169. /*
  170. * The reverse mapping array has one entry for each HPTE,
  171. * which stores the guest's view of the second word of the HPTE
  172. * (including the guest physical address of the mapping),
  173. * plus forward and backward pointers in a doubly-linked ring
  174. * of HPTEs that map the same host page. The pointers in this
  175. * ring are 32-bit HPTE indexes, to save space.
  176. */
  177. struct revmap_entry {
  178. unsigned long guest_rpte;
  179. unsigned int forw, back;
  180. };
  181. /*
  182. * We use the top bit of each memslot->arch.rmap entry as a lock bit,
  183. * and bit 32 as a present flag. The bottom 32 bits are the
  184. * index in the guest HPT of a HPTE that points to the page.
  185. */
  186. #define KVMPPC_RMAP_LOCK_BIT 63
  187. #define KVMPPC_RMAP_RC_SHIFT 32
  188. #define KVMPPC_RMAP_REFERENCED (HPTE_R_R << KVMPPC_RMAP_RC_SHIFT)
  189. #define KVMPPC_RMAP_CHANGED (HPTE_R_C << KVMPPC_RMAP_RC_SHIFT)
  190. #define KVMPPC_RMAP_PRESENT 0x100000000ul
  191. #define KVMPPC_RMAP_INDEX 0xfffffffful
  192. /* Low-order bits in memslot->arch.slot_phys[] */
  193. #define KVMPPC_PAGE_ORDER_MASK 0x1f
  194. #define KVMPPC_PAGE_NO_CACHE HPTE_R_I /* 0x20 */
  195. #define KVMPPC_PAGE_WRITETHRU HPTE_R_W /* 0x40 */
  196. #define KVMPPC_GOT_PAGE 0x80
  197. struct kvm_arch_memory_slot {
  198. #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
  199. unsigned long *rmap;
  200. unsigned long *slot_phys;
  201. #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
  202. };
  203. struct kvm_arch {
  204. unsigned int lpid;
  205. #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
  206. unsigned long hpt_virt;
  207. struct revmap_entry *revmap;
  208. unsigned int host_lpid;
  209. unsigned long host_lpcr;
  210. unsigned long sdr1;
  211. unsigned long host_sdr1;
  212. int tlbie_lock;
  213. unsigned long lpcr;
  214. unsigned long rmor;
  215. struct kvm_rma_info *rma;
  216. unsigned long vrma_slb_v;
  217. int rma_setup_done;
  218. int using_mmu_notifiers;
  219. u32 hpt_order;
  220. atomic_t vcpus_running;
  221. u32 online_vcores;
  222. unsigned long hpt_npte;
  223. unsigned long hpt_mask;
  224. atomic_t hpte_mod_interest;
  225. spinlock_t slot_phys_lock;
  226. cpumask_t need_tlb_flush;
  227. int hpt_cma_alloc;
  228. #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
  229. #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
  230. struct mutex hpt_mutex;
  231. #endif
  232. #ifdef CONFIG_PPC_BOOK3S_64
  233. struct list_head spapr_tce_tables;
  234. struct list_head rtas_tokens;
  235. DECLARE_BITMAP(enabled_hcalls, MAX_HCALL_OPCODE/4 + 1);
  236. #endif
  237. #ifdef CONFIG_KVM_MPIC
  238. struct openpic *mpic;
  239. #endif
  240. #ifdef CONFIG_KVM_XICS
  241. struct kvmppc_xics *xics;
  242. #endif
  243. struct kvmppc_ops *kvm_ops;
  244. #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
  245. /* This array can grow quite large, keep it at the end */
  246. struct kvmppc_vcore *vcores[KVM_MAX_VCORES];
  247. #endif
  248. };
  249. /*
  250. * Struct for a virtual core.
  251. * Note: entry_exit_count combines an entry count in the bottom 8 bits
  252. * and an exit count in the next 8 bits. This is so that we can
  253. * atomically increment the entry count iff the exit count is 0
  254. * without taking the lock.
  255. */
  256. struct kvmppc_vcore {
  257. int n_runnable;
  258. int n_busy;
  259. int num_threads;
  260. int entry_exit_count;
  261. int n_woken;
  262. int nap_count;
  263. int napping_threads;
  264. int first_vcpuid;
  265. u16 pcpu;
  266. u16 last_cpu;
  267. u8 vcore_state;
  268. u8 in_guest;
  269. struct list_head runnable_threads;
  270. spinlock_t lock;
  271. wait_queue_head_t wq;
  272. u64 stolen_tb;
  273. u64 preempt_tb;
  274. struct kvm_vcpu *runner;
  275. struct kvm *kvm;
  276. u64 tb_offset; /* guest timebase - host timebase */
  277. ulong lpcr;
  278. u32 arch_compat;
  279. ulong pcr;
  280. ulong dpdes; /* doorbell state (POWER8) */
  281. void *mpp_buffer; /* Micro Partition Prefetch buffer */
  282. bool mpp_buffer_is_valid;
  283. };
  284. #define VCORE_ENTRY_COUNT(vc) ((vc)->entry_exit_count & 0xff)
  285. #define VCORE_EXIT_COUNT(vc) ((vc)->entry_exit_count >> 8)
  286. /* Values for vcore_state */
  287. #define VCORE_INACTIVE 0
  288. #define VCORE_SLEEPING 1
  289. #define VCORE_STARTING 2
  290. #define VCORE_RUNNING 3
  291. #define VCORE_EXITING 4
  292. /*
  293. * Struct used to manage memory for a virtual processor area
  294. * registered by a PAPR guest. There are three types of area
  295. * that a guest can register.
  296. */
  297. struct kvmppc_vpa {
  298. unsigned long gpa; /* Current guest phys addr */
  299. void *pinned_addr; /* Address in kernel linear mapping */
  300. void *pinned_end; /* End of region */
  301. unsigned long next_gpa; /* Guest phys addr for update */
  302. unsigned long len; /* Number of bytes required */
  303. u8 update_pending; /* 1 => update pinned_addr from next_gpa */
  304. bool dirty; /* true => area has been modified by kernel */
  305. };
  306. struct kvmppc_pte {
  307. ulong eaddr;
  308. u64 vpage;
  309. ulong raddr;
  310. bool may_read : 1;
  311. bool may_write : 1;
  312. bool may_execute : 1;
  313. u8 page_size; /* MMU_PAGE_xxx */
  314. };
  315. struct kvmppc_mmu {
  316. /* book3s_64 only */
  317. void (*slbmte)(struct kvm_vcpu *vcpu, u64 rb, u64 rs);
  318. u64 (*slbmfee)(struct kvm_vcpu *vcpu, u64 slb_nr);
  319. u64 (*slbmfev)(struct kvm_vcpu *vcpu, u64 slb_nr);
  320. void (*slbie)(struct kvm_vcpu *vcpu, u64 slb_nr);
  321. void (*slbia)(struct kvm_vcpu *vcpu);
  322. /* book3s */
  323. void (*mtsrin)(struct kvm_vcpu *vcpu, u32 srnum, ulong value);
  324. u32 (*mfsrin)(struct kvm_vcpu *vcpu, u32 srnum);
  325. int (*xlate)(struct kvm_vcpu *vcpu, gva_t eaddr,
  326. struct kvmppc_pte *pte, bool data, bool iswrite);
  327. void (*reset_msr)(struct kvm_vcpu *vcpu);
  328. void (*tlbie)(struct kvm_vcpu *vcpu, ulong addr, bool large);
  329. int (*esid_to_vsid)(struct kvm_vcpu *vcpu, ulong esid, u64 *vsid);
  330. u64 (*ea_to_vp)(struct kvm_vcpu *vcpu, gva_t eaddr, bool data);
  331. bool (*is_dcbz32)(struct kvm_vcpu *vcpu);
  332. };
  333. struct kvmppc_slb {
  334. u64 esid;
  335. u64 vsid;
  336. u64 orige;
  337. u64 origv;
  338. bool valid : 1;
  339. bool Ks : 1;
  340. bool Kp : 1;
  341. bool nx : 1;
  342. bool large : 1; /* PTEs are 16MB */
  343. bool tb : 1; /* 1TB segment */
  344. bool class : 1;
  345. u8 base_page_size; /* MMU_PAGE_xxx */
  346. };
  347. # ifdef CONFIG_PPC_FSL_BOOK3E
  348. #define KVMPPC_BOOKE_IAC_NUM 2
  349. #define KVMPPC_BOOKE_DAC_NUM 2
  350. # else
  351. #define KVMPPC_BOOKE_IAC_NUM 4
  352. #define KVMPPC_BOOKE_DAC_NUM 2
  353. # endif
  354. #define KVMPPC_BOOKE_MAX_IAC 4
  355. #define KVMPPC_BOOKE_MAX_DAC 2
  356. /* KVMPPC_EPR_USER takes precedence over KVMPPC_EPR_KERNEL */
  357. #define KVMPPC_EPR_NONE 0 /* EPR not supported */
  358. #define KVMPPC_EPR_USER 1 /* exit to userspace to fill EPR */
  359. #define KVMPPC_EPR_KERNEL 2 /* in-kernel irqchip */
  360. #define KVMPPC_IRQ_DEFAULT 0
  361. #define KVMPPC_IRQ_MPIC 1
  362. #define KVMPPC_IRQ_XICS 2
  363. struct openpic;
  364. struct kvm_vcpu_arch {
  365. ulong host_stack;
  366. u32 host_pid;
  367. #ifdef CONFIG_PPC_BOOK3S
  368. struct kvmppc_slb slb[64];
  369. int slb_max; /* 1 + index of last valid entry in slb[] */
  370. int slb_nr; /* total number of entries in SLB */
  371. struct kvmppc_mmu mmu;
  372. struct kvmppc_vcpu_book3s *book3s;
  373. #endif
  374. #ifdef CONFIG_PPC_BOOK3S_32
  375. struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
  376. #endif
  377. ulong gpr[32];
  378. struct thread_fp_state fp;
  379. #ifdef CONFIG_SPE
  380. ulong evr[32];
  381. ulong spefscr;
  382. ulong host_spefscr;
  383. u64 acc;
  384. #endif
  385. #ifdef CONFIG_ALTIVEC
  386. struct thread_vr_state vr;
  387. #endif
  388. #ifdef CONFIG_KVM_BOOKE_HV
  389. u32 host_mas4;
  390. u32 host_mas6;
  391. u32 shadow_epcr;
  392. u32 shadow_msrp;
  393. u32 eplc;
  394. u32 epsc;
  395. u32 oldpir;
  396. #endif
  397. #if defined(CONFIG_BOOKE)
  398. #if defined(CONFIG_KVM_BOOKE_HV) || defined(CONFIG_64BIT)
  399. u32 epcr;
  400. #endif
  401. #endif
  402. #ifdef CONFIG_PPC_BOOK3S
  403. /* For Gekko paired singles */
  404. u32 qpr[32];
  405. #endif
  406. ulong pc;
  407. ulong ctr;
  408. ulong lr;
  409. #ifdef CONFIG_PPC_BOOK3S
  410. ulong tar;
  411. #endif
  412. ulong xer;
  413. u32 cr;
  414. #ifdef CONFIG_PPC_BOOK3S
  415. ulong hflags;
  416. ulong guest_owned_ext;
  417. ulong purr;
  418. ulong spurr;
  419. ulong ic;
  420. ulong vtb;
  421. ulong dscr;
  422. ulong amr;
  423. ulong uamor;
  424. ulong iamr;
  425. u32 ctrl;
  426. u32 dabrx;
  427. ulong dabr;
  428. ulong dawr;
  429. ulong dawrx;
  430. ulong ciabr;
  431. ulong cfar;
  432. ulong ppr;
  433. ulong pspb;
  434. ulong fscr;
  435. ulong shadow_fscr;
  436. ulong ebbhr;
  437. ulong ebbrr;
  438. ulong bescr;
  439. ulong csigr;
  440. ulong tacr;
  441. ulong tcscr;
  442. ulong acop;
  443. ulong wort;
  444. ulong shadow_srr1;
  445. #endif
  446. u32 vrsave; /* also USPRG0 */
  447. u32 mmucr;
  448. /* shadow_msr is unused for BookE HV */
  449. ulong shadow_msr;
  450. ulong csrr0;
  451. ulong csrr1;
  452. ulong dsrr0;
  453. ulong dsrr1;
  454. ulong mcsrr0;
  455. ulong mcsrr1;
  456. ulong mcsr;
  457. u32 dec;
  458. #ifdef CONFIG_BOOKE
  459. u32 decar;
  460. #endif
  461. /* Time base value when we entered the guest */
  462. u64 entry_tb;
  463. u64 entry_vtb;
  464. u64 entry_ic;
  465. u32 tcr;
  466. ulong tsr; /* we need to perform set/clr_bits() which requires ulong */
  467. u32 ivor[64];
  468. ulong ivpr;
  469. u32 pvr;
  470. u32 shadow_pid;
  471. u32 shadow_pid1;
  472. u32 pid;
  473. u32 swap_pid;
  474. u32 ccr0;
  475. u32 ccr1;
  476. u32 dbsr;
  477. u64 mmcr[5];
  478. u32 pmc[8];
  479. u32 spmc[2];
  480. u64 siar;
  481. u64 sdar;
  482. u64 sier;
  483. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  484. u64 tfhar;
  485. u64 texasr;
  486. u64 tfiar;
  487. u32 cr_tm;
  488. u64 lr_tm;
  489. u64 ctr_tm;
  490. u64 amr_tm;
  491. u64 ppr_tm;
  492. u64 dscr_tm;
  493. u64 tar_tm;
  494. ulong gpr_tm[32];
  495. struct thread_fp_state fp_tm;
  496. struct thread_vr_state vr_tm;
  497. u32 vrsave_tm; /* also USPRG0 */
  498. #endif
  499. #ifdef CONFIG_KVM_EXIT_TIMING
  500. struct mutex exit_timing_lock;
  501. struct kvmppc_exit_timing timing_exit;
  502. struct kvmppc_exit_timing timing_last_enter;
  503. u32 last_exit_type;
  504. u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES];
  505. u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  506. u64 timing_sum_quad_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  507. u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  508. u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  509. u64 timing_last_exit;
  510. struct dentry *debugfs_exit_timing;
  511. #endif
  512. #ifdef CONFIG_PPC_BOOK3S
  513. ulong fault_dar;
  514. u32 fault_dsisr;
  515. unsigned long intr_msr;
  516. #endif
  517. #ifdef CONFIG_BOOKE
  518. ulong fault_dear;
  519. ulong fault_esr;
  520. ulong queued_dear;
  521. ulong queued_esr;
  522. spinlock_t wdt_lock;
  523. struct timer_list wdt_timer;
  524. u32 tlbcfg[4];
  525. u32 tlbps[4];
  526. u32 mmucfg;
  527. u32 eptcfg;
  528. u32 epr;
  529. u64 sprg9;
  530. u32 pwrmgtcr0;
  531. u32 crit_save;
  532. /* guest debug registers*/
  533. struct debug_reg dbg_reg;
  534. /* hardware visible debug registers when in guest state */
  535. struct debug_reg shadow_dbg_reg;
  536. #endif
  537. gpa_t paddr_accessed;
  538. gva_t vaddr_accessed;
  539. pgd_t *pgdir;
  540. u8 io_gpr; /* GPR used as IO source/target */
  541. u8 mmio_is_bigendian;
  542. u8 mmio_sign_extend;
  543. u8 osi_needed;
  544. u8 osi_enabled;
  545. u8 papr_enabled;
  546. u8 watchdog_enabled;
  547. u8 sane;
  548. u8 cpu_type;
  549. u8 hcall_needed;
  550. u8 epr_flags; /* KVMPPC_EPR_xxx */
  551. u8 epr_needed;
  552. u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
  553. struct hrtimer dec_timer;
  554. struct tasklet_struct tasklet;
  555. u64 dec_jiffies;
  556. u64 dec_expires;
  557. unsigned long pending_exceptions;
  558. u8 ceded;
  559. u8 prodded;
  560. u32 last_inst;
  561. wait_queue_head_t *wqp;
  562. struct kvmppc_vcore *vcore;
  563. int ret;
  564. int trap;
  565. int state;
  566. int ptid;
  567. bool timer_running;
  568. wait_queue_head_t cpu_run;
  569. struct kvm_vcpu_arch_shared *shared;
  570. #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE)
  571. bool shared_big_endian;
  572. #endif
  573. unsigned long magic_page_pa; /* phys addr to map the magic page to */
  574. unsigned long magic_page_ea; /* effect. addr to map the magic page to */
  575. bool disable_kernel_nx;
  576. int irq_type; /* one of KVM_IRQ_* */
  577. int irq_cpu_id;
  578. struct openpic *mpic; /* KVM_IRQ_MPIC */
  579. #ifdef CONFIG_KVM_XICS
  580. struct kvmppc_icp *icp; /* XICS presentation controller */
  581. #endif
  582. #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
  583. struct kvm_vcpu_arch_shared shregs;
  584. unsigned long pgfault_addr;
  585. long pgfault_index;
  586. unsigned long pgfault_hpte[2];
  587. struct list_head run_list;
  588. struct task_struct *run_task;
  589. struct kvm_run *kvm_run;
  590. spinlock_t vpa_update_lock;
  591. struct kvmppc_vpa vpa;
  592. struct kvmppc_vpa dtl;
  593. struct dtl_entry *dtl_ptr;
  594. unsigned long dtl_index;
  595. u64 stolen_logged;
  596. struct kvmppc_vpa slb_shadow;
  597. spinlock_t tbacct_lock;
  598. u64 busy_stolen;
  599. u64 busy_preempt;
  600. #endif
  601. };
  602. #define VCPU_FPR(vcpu, i) (vcpu)->arch.fp.fpr[i][TS_FPROFFSET]
  603. /* Values for vcpu->arch.state */
  604. #define KVMPPC_VCPU_NOTREADY 0
  605. #define KVMPPC_VCPU_RUNNABLE 1
  606. #define KVMPPC_VCPU_BUSY_IN_HOST 2
  607. /* Values for vcpu->arch.io_gpr */
  608. #define KVM_MMIO_REG_MASK 0x001f
  609. #define KVM_MMIO_REG_EXT_MASK 0xffe0
  610. #define KVM_MMIO_REG_GPR 0x0000
  611. #define KVM_MMIO_REG_FPR 0x0020
  612. #define KVM_MMIO_REG_QPR 0x0040
  613. #define KVM_MMIO_REG_FQPR 0x0060
  614. #define __KVM_HAVE_ARCH_WQP
  615. #define __KVM_HAVE_CREATE_DEVICE
  616. #endif /* __POWERPC_KVM_HOST_H__ */