kvm_host.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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/timer.h>
  23. #include <linux/types.h>
  24. #include <linux/kvm_types.h>
  25. #include <asm/kvm_asm.h>
  26. #define KVM_MAX_VCPUS 1
  27. #define KVM_MEMORY_SLOTS 32
  28. /* memory slots that does not exposed to userspace */
  29. #define KVM_PRIVATE_MEM_SLOTS 4
  30. #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
  31. /* We don't currently support large pages. */
  32. #define KVM_NR_PAGE_SIZES 1
  33. #define KVM_PAGES_PER_HPAGE(x) (1UL<<31)
  34. struct kvm;
  35. struct kvm_run;
  36. struct kvm_vcpu;
  37. struct kvm_vm_stat {
  38. u32 remote_tlb_flush;
  39. };
  40. struct kvm_vcpu_stat {
  41. u32 sum_exits;
  42. u32 mmio_exits;
  43. u32 dcr_exits;
  44. u32 signal_exits;
  45. u32 light_exits;
  46. /* Account for special types of light exits: */
  47. u32 itlb_real_miss_exits;
  48. u32 itlb_virt_miss_exits;
  49. u32 dtlb_real_miss_exits;
  50. u32 dtlb_virt_miss_exits;
  51. u32 syscall_exits;
  52. u32 isi_exits;
  53. u32 dsi_exits;
  54. u32 emulated_inst_exits;
  55. u32 dec_exits;
  56. u32 ext_intr_exits;
  57. u32 halt_wakeup;
  58. };
  59. enum kvm_exit_types {
  60. MMIO_EXITS,
  61. DCR_EXITS,
  62. SIGNAL_EXITS,
  63. ITLB_REAL_MISS_EXITS,
  64. ITLB_VIRT_MISS_EXITS,
  65. DTLB_REAL_MISS_EXITS,
  66. DTLB_VIRT_MISS_EXITS,
  67. SYSCALL_EXITS,
  68. ISI_EXITS,
  69. DSI_EXITS,
  70. EMULATED_INST_EXITS,
  71. EMULATED_MTMSRWE_EXITS,
  72. EMULATED_WRTEE_EXITS,
  73. EMULATED_MTSPR_EXITS,
  74. EMULATED_MFSPR_EXITS,
  75. EMULATED_MTMSR_EXITS,
  76. EMULATED_MFMSR_EXITS,
  77. EMULATED_TLBSX_EXITS,
  78. EMULATED_TLBWE_EXITS,
  79. EMULATED_RFI_EXITS,
  80. DEC_EXITS,
  81. EXT_INTR_EXITS,
  82. HALT_WAKEUP,
  83. USR_PR_INST,
  84. FP_UNAVAIL,
  85. DEBUG_EXITS,
  86. TIMEINGUEST,
  87. __NUMBER_OF_KVM_EXIT_TYPES
  88. };
  89. /* allow access to big endian 32bit upper/lower parts and 64bit var */
  90. struct kvmppc_exit_timing {
  91. union {
  92. u64 tv64;
  93. struct {
  94. u32 tbu, tbl;
  95. } tv32;
  96. };
  97. };
  98. struct kvm_arch {
  99. };
  100. struct kvm_vcpu_arch {
  101. u32 host_stack;
  102. u32 host_pid;
  103. u64 fpr[32];
  104. ulong gpr[32];
  105. ulong pc;
  106. u32 cr;
  107. ulong ctr;
  108. ulong lr;
  109. ulong xer;
  110. ulong msr;
  111. u32 mmucr;
  112. ulong sprg0;
  113. ulong sprg1;
  114. ulong sprg2;
  115. ulong sprg3;
  116. ulong sprg4;
  117. ulong sprg5;
  118. ulong sprg6;
  119. ulong sprg7;
  120. ulong srr0;
  121. ulong srr1;
  122. ulong csrr0;
  123. ulong csrr1;
  124. ulong dsrr0;
  125. ulong dsrr1;
  126. ulong dear;
  127. ulong esr;
  128. u32 dec;
  129. u32 decar;
  130. u32 tbl;
  131. u32 tbu;
  132. u32 tcr;
  133. u32 tsr;
  134. u32 ivor[64];
  135. ulong ivpr;
  136. u32 pir;
  137. u32 shadow_pid;
  138. u32 pid;
  139. u32 swap_pid;
  140. u32 ccr0;
  141. u32 ccr1;
  142. u32 dbcr0;
  143. u32 dbcr1;
  144. u32 dbsr;
  145. #ifdef CONFIG_KVM_EXIT_TIMING
  146. struct kvmppc_exit_timing timing_exit;
  147. struct kvmppc_exit_timing timing_last_enter;
  148. u32 last_exit_type;
  149. u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES];
  150. u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  151. u64 timing_sum_quad_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  152. u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  153. u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES];
  154. u64 timing_last_exit;
  155. struct dentry *debugfs_exit_timing;
  156. #endif
  157. u32 last_inst;
  158. ulong fault_dear;
  159. ulong fault_esr;
  160. gpa_t paddr_accessed;
  161. u8 io_gpr; /* GPR used as IO source/target */
  162. u8 mmio_is_bigendian;
  163. u8 dcr_needed;
  164. u8 dcr_is_write;
  165. u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
  166. struct timer_list dec_timer;
  167. unsigned long pending_exceptions;
  168. };
  169. #endif /* __POWERPC_KVM_HOST_H__ */