/arch/powerpc/include/asm/kvm_book3s_asm.h

http://github.com/mirrors/linux · C Header · 174 lines · 126 code · 27 blank · 21 comment · 33 complexity · d6b0cd430d54740fc316add49de61a79 MD5 · raw file

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