kvm_book3s_asm.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. #ifdef __ASSEMBLY__
  26. #ifdef CONFIG_KVM_BOOK3S_HANDLER
  27. #include <asm/kvm_asm.h>
  28. .macro DO_KVM intno
  29. .if (\intno == BOOK3S_INTERRUPT_SYSTEM_RESET) || \
  30. (\intno == BOOK3S_INTERRUPT_MACHINE_CHECK) || \
  31. (\intno == BOOK3S_INTERRUPT_DATA_STORAGE) || \
  32. (\intno == BOOK3S_INTERRUPT_INST_STORAGE) || \
  33. (\intno == BOOK3S_INTERRUPT_DATA_SEGMENT) || \
  34. (\intno == BOOK3S_INTERRUPT_INST_SEGMENT) || \
  35. (\intno == BOOK3S_INTERRUPT_EXTERNAL) || \
  36. (\intno == BOOK3S_INTERRUPT_EXTERNAL_HV) || \
  37. (\intno == BOOK3S_INTERRUPT_ALIGNMENT) || \
  38. (\intno == BOOK3S_INTERRUPT_PROGRAM) || \
  39. (\intno == BOOK3S_INTERRUPT_FP_UNAVAIL) || \
  40. (\intno == BOOK3S_INTERRUPT_DECREMENTER) || \
  41. (\intno == BOOK3S_INTERRUPT_SYSCALL) || \
  42. (\intno == BOOK3S_INTERRUPT_TRACE) || \
  43. (\intno == BOOK3S_INTERRUPT_PERFMON) || \
  44. (\intno == BOOK3S_INTERRUPT_ALTIVEC) || \
  45. (\intno == BOOK3S_INTERRUPT_VSX)
  46. b kvmppc_trampoline_\intno
  47. kvmppc_resume_\intno:
  48. .endif
  49. .endm
  50. #else
  51. .macro DO_KVM intno
  52. .endm
  53. #endif /* CONFIG_KVM_BOOK3S_HANDLER */
  54. #else /*__ASSEMBLY__ */
  55. /*
  56. * This struct goes in the PACA on 64-bit processors. It is used
  57. * to store host state that needs to be saved when we enter a guest
  58. * and restored when we exit, but isn't specific to any particular
  59. * guest or vcpu. It also has some scratch fields used by the guest
  60. * exit code.
  61. */
  62. struct kvmppc_host_state {
  63. ulong host_r1;
  64. ulong host_r2;
  65. ulong host_msr;
  66. ulong vmhandler;
  67. ulong scratch0;
  68. ulong scratch1;
  69. u8 in_guest;
  70. u8 restore_hid5;
  71. u8 napping;
  72. #ifdef CONFIG_KVM_BOOK3S_64_HV
  73. u8 hwthread_req;
  74. u8 hwthread_state;
  75. u8 host_ipi;
  76. struct kvm_vcpu *kvm_vcpu;
  77. struct kvmppc_vcore *kvm_vcore;
  78. unsigned long xics_phys;
  79. u32 saved_xirr;
  80. u64 dabr;
  81. u64 host_mmcr[3];
  82. u32 host_pmc[8];
  83. u64 host_purr;
  84. u64 host_spurr;
  85. u64 host_dscr;
  86. u64 dec_expires;
  87. #endif
  88. #ifdef CONFIG_PPC_BOOK3S_64
  89. u64 cfar;
  90. #endif
  91. };
  92. struct kvmppc_book3s_shadow_vcpu {
  93. ulong gpr[14];
  94. u32 cr;
  95. u32 xer;
  96. u32 fault_dsisr;
  97. u32 last_inst;
  98. ulong ctr;
  99. ulong lr;
  100. ulong pc;
  101. ulong shadow_srr1;
  102. ulong fault_dar;
  103. #ifdef CONFIG_PPC_BOOK3S_32
  104. u32 sr[16]; /* Guest SRs */
  105. struct kvmppc_host_state hstate;
  106. #endif
  107. #ifdef CONFIG_PPC_BOOK3S_64
  108. u8 slb_max; /* highest used guest slb entry */
  109. struct {
  110. u64 esid;
  111. u64 vsid;
  112. } slb[64]; /* guest SLB */
  113. #endif
  114. };
  115. #endif /*__ASSEMBLY__ */
  116. /* Values for kvm_state */
  117. #define KVM_HWTHREAD_IN_KERNEL 0
  118. #define KVM_HWTHREAD_IN_NAP 1
  119. #define KVM_HWTHREAD_IN_KVM 2
  120. #endif /* __ASM_KVM_BOOK3S_ASM_H__ */