kvm_book3s_asm.h 3.3 KB

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