kvm_host.h 16 KB

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