kvm_book3s_asm.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 SUSE Linux Products GmbH 2009
  16. *
  17. * Authors: Alexander Graf <agraf@suse.de>
  18. */
  19. #ifndef __ASM_KVM_BOOK3S_ASM_H__
  20. #define __ASM_KVM_BOOK3S_ASM_H__
  21. /* XICS ICP register offsets */
  22. #define XICS_XIRR 4
  23. #define XICS_MFRR 0xc
  24. #define XICS_IPI 2 /* interrupt source # for IPIs */
  25. /* Maximum number of threads per physical core */
  26. #define MAX_SMT_THREADS 8
  27. /* Maximum number of subcores per physical core */
  28. #define MAX_SUBCORES 4
  29. #ifdef __ASSEMBLY__
  30. #ifdef CONFIG_KVM_BOOK3S_HANDLER
  31. #include <asm/kvm_asm.h>
  32. .macro DO_KVM intno
  33. .if (\intno == BOOK3S_INTERRUPT_SYSTEM_RESET) || \
  34. (\intno == BOOK3S_INTERRUPT_MACHINE_CHECK) || \
  35. (\intno == BOOK3S_INTERRUPT_DATA_STORAGE) || \
  36. (\intno == BOOK3S_INTERRUPT_INST_STORAGE) || \
  37. (\intno == BOOK3S_INTERRUPT_DATA_SEGMENT) || \
  38. (\intno == BOOK3S_INTERRUPT_INST_SEGMENT) || \
  39. (\intno == BOOK3S_INTERRUPT_EXTERNAL) || \
  40. (\intno == BOOK3S_INTERRUPT_EXTERNAL_HV) || \
  41. (\intno == BOOK3S_INTERRUPT_ALIGNMENT) || \
  42. (\intno == BOOK3S_INTERRUPT_PROGRAM) || \
  43. (\intno == BOOK3S_INTERRUPT_FP_UNAVAIL) || \
  44. (\intno == BOOK3S_INTERRUPT_DECREMENTER) || \
  45. (\intno == BOOK3S_INTERRUPT_SYSCALL) || \
  46. (\intno == BOOK3S_INTERRUPT_TRACE) || \
  47. (\intno == BOOK3S_INTERRUPT_PERFMON) || \
  48. (\intno == BOOK3S_INTERRUPT_ALTIVEC) || \
  49. (\intno == BOOK3S_INTERRUPT_VSX)
  50. b kvmppc_trampoline_\intno
  51. kvmppc_resume_\intno:
  52. .endif
  53. .endm
  54. #else
  55. .macro DO_KVM intno
  56. .endm
  57. #endif /* CONFIG_KVM_BOOK3S_HANDLER */
  58. #else /*__ASSEMBLY__ */
  59. struct kvmppc_vcore;
  60. /* Struct used for coordinating micro-threading (split-core) mode changes */
  61. struct kvm_split_mode {
  62. unsigned long rpr;
  63. unsigned long pmmar;
  64. unsigned long ldbar;
  65. u8 subcore_size;
  66. u8 do_nap;
  67. u8 napped[MAX_SMT_THREADS];
  68. struct kvmppc_vcore *vc[MAX_SUBCORES];
  69. };
  70. /*
  71. * This struct goes in the PACA on 64-bit processors. It is used
  72. * to store host state that needs to be saved when we enter a guest
  73. * and restored when we exit, but isn't specific to any particular
  74. * guest or vcpu. It also has some scratch fields used by the guest
  75. * exit code.
  76. */
  77. struct kvmppc_host_state {
  78. ulong host_r1;
  79. ulong host_r2;
  80. ulong host_msr;
  81. ulong vmhandler;
  82. ulong scratch0;
  83. ulong scratch1;
  84. ulong scratch2;
  85. u8 in_guest;
  86. u8 restore_hid5;
  87. u8 napping;
  88. #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
  89. u8 hwthread_req;
  90. u8 hwthread_state;
  91. u8 host_ipi;
  92. u8 ptid;
  93. struct kvm_vcpu *kvm_vcpu;
  94. struct kvmppc_vcore *kvm_vcore;
  95. void __iomem *xics_phys;
  96. void __iomem *xive_tima_phys;
  97. void __iomem *xive_tima_virt;
  98. u32 saved_xirr;
  99. u64 dabr;
  100. u64 host_mmcr[7]; /* MMCR 0,1,A, SIAR, SDAR, MMCR2, SIER */
  101. u32 host_pmc[8];
  102. u64 host_purr;
  103. u64 host_spurr;
  104. u64 host_dscr;
  105. u64 dec_expires;
  106. struct kvm_split_mode *kvm_split_mode;
  107. #endif
  108. #ifdef CONFIG_PPC_BOOK3S_64
  109. u64 cfar;
  110. u64 ppr;
  111. u64 host_fscr;
  112. #endif
  113. };
  114. struct kvmppc_book3s_shadow_vcpu {
  115. bool in_use;
  116. ulong gpr[14];
  117. u32 cr;
  118. ulong xer;
  119. ulong ctr;
  120. ulong lr;
  121. ulong pc;
  122. ulong shadow_srr1;
  123. ulong fault_dar;
  124. u32 fault_dsisr;
  125. u32 last_inst;
  126. #ifdef CONFIG_PPC_BOOK3S_32
  127. u32 sr[16]; /* Guest SRs */
  128. struct kvmppc_host_state hstate;
  129. #endif
  130. #ifdef CONFIG_PPC_BOOK3S_64
  131. u8 slb_max; /* highest used guest slb entry */
  132. struct {
  133. u64 esid;
  134. u64 vsid;
  135. } slb[64]; /* guest SLB */
  136. u64 shadow_fscr;
  137. #endif
  138. };
  139. #endif /*__ASSEMBLY__ */
  140. /* Values for kvm_state */
  141. #define KVM_HWTHREAD_IN_KERNEL 0
  142. #define KVM_HWTHREAD_IN_IDLE 1
  143. #define KVM_HWTHREAD_IN_KVM 2
  144. #endif /* __ASM_KVM_BOOK3S_ASM_H__ */