kvm_book3s.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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_H__
  20. #define __ASM_KVM_BOOK3S_H__
  21. #include <linux/types.h>
  22. #include <linux/kvm_host.h>
  23. #include <asm/kvm_ppc.h>
  24. struct kvmppc_slb {
  25. u64 esid;
  26. u64 vsid;
  27. u64 orige;
  28. u64 origv;
  29. bool valid;
  30. bool Ks;
  31. bool Kp;
  32. bool nx;
  33. bool large;
  34. bool class;
  35. };
  36. struct kvmppc_sr {
  37. u32 raw;
  38. u32 vsid;
  39. bool Ks;
  40. bool Kp;
  41. bool nx;
  42. };
  43. struct kvmppc_bat {
  44. u64 raw;
  45. u32 bepi;
  46. u32 bepi_mask;
  47. bool vs;
  48. bool vp;
  49. u32 brpn;
  50. u8 wimg;
  51. u8 pp;
  52. };
  53. struct kvmppc_sid_map {
  54. u64 guest_vsid;
  55. u64 guest_esid;
  56. u64 host_vsid;
  57. bool valid;
  58. };
  59. #define SID_MAP_BITS 9
  60. #define SID_MAP_NUM (1 << SID_MAP_BITS)
  61. #define SID_MAP_MASK (SID_MAP_NUM - 1)
  62. struct kvmppc_vcpu_book3s {
  63. struct kvm_vcpu vcpu;
  64. struct kvmppc_sid_map sid_map[SID_MAP_NUM];
  65. struct kvmppc_slb slb[64];
  66. struct {
  67. u64 esid;
  68. u64 vsid;
  69. } slb_shadow[64];
  70. u8 slb_shadow_max;
  71. struct kvmppc_sr sr[16];
  72. struct kvmppc_bat ibat[8];
  73. struct kvmppc_bat dbat[8];
  74. u64 hid[6];
  75. int slb_nr;
  76. u64 sdr1;
  77. u64 dsisr;
  78. u64 hior;
  79. u64 msr_mask;
  80. u64 vsid_first;
  81. u64 vsid_next;
  82. u64 vsid_max;
  83. int context_id;
  84. };
  85. #define CONTEXT_HOST 0
  86. #define CONTEXT_GUEST 1
  87. #define CONTEXT_GUEST_END 2
  88. #define VSID_REAL 0xfffffffffff00000
  89. #define VSID_REAL_DR 0xffffffffffe00000
  90. #define VSID_REAL_IR 0xffffffffffd00000
  91. #define VSID_BAT 0xffffffffffc00000
  92. #define VSID_PR 0x8000000000000000
  93. extern void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, u64 ea, u64 ea_mask);
  94. extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 vp, u64 vp_mask);
  95. extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, u64 pa_start, u64 pa_end);
  96. extern void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 new_msr);
  97. extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu *vcpu);
  98. extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu);
  99. extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte);
  100. extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr);
  101. extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu);
  102. extern struct kvmppc_pte *kvmppc_mmu_find_pte(struct kvm_vcpu *vcpu, u64 ea, bool data);
  103. extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong eaddr, int size, void *ptr, bool data);
  104. extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong eaddr, int size, void *ptr);
  105. extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec);
  106. extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
  107. bool upper, u32 val);
  108. extern u32 kvmppc_trampoline_lowmem;
  109. extern u32 kvmppc_trampoline_enter;
  110. static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
  111. {
  112. return container_of(vcpu, struct kvmppc_vcpu_book3s, vcpu);
  113. }
  114. static inline ulong dsisr(void)
  115. {
  116. ulong r;
  117. asm ( "mfdsisr %0 " : "=r" (r) );
  118. return r;
  119. }
  120. extern void kvm_return_point(void);
  121. #define INS_DCBZ 0x7c0007ec
  122. #endif /* __ASM_KVM_BOOK3S_H__ */