kvm_booke.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 2010
  16. *
  17. * Authors: Alexander Graf <agraf@suse.de>
  18. */
  19. #ifndef __ASM_KVM_BOOKE_H__
  20. #define __ASM_KVM_BOOKE_H__
  21. #include <linux/types.h>
  22. #include <linux/kvm_host.h>
  23. /*
  24. * Number of available lpids. Only the low-order 6 bits of LPID rgister are
  25. * implemented on e500mc+ cores.
  26. */
  27. #define KVMPPC_NR_LPIDS 64
  28. #define KVMPPC_INST_EHPRIV 0x7c00021c
  29. #define EHPRIV_OC_SHIFT 11
  30. /* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */
  31. #define EHPRIV_OC_DEBUG 1
  32. static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
  33. {
  34. vcpu->arch.gpr[num] = val;
  35. }
  36. static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
  37. {
  38. return vcpu->arch.gpr[num];
  39. }
  40. static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
  41. {
  42. vcpu->arch.cr = val;
  43. }
  44. static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
  45. {
  46. return vcpu->arch.cr;
  47. }
  48. static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
  49. {
  50. vcpu->arch.xer = val;
  51. }
  52. static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
  53. {
  54. return vcpu->arch.xer;
  55. }
  56. static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
  57. {
  58. /* XXX Would need to check TLB entry */
  59. return false;
  60. }
  61. static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
  62. {
  63. vcpu->arch.ctr = val;
  64. }
  65. static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
  66. {
  67. return vcpu->arch.ctr;
  68. }
  69. static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
  70. {
  71. vcpu->arch.lr = val;
  72. }
  73. static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
  74. {
  75. return vcpu->arch.lr;
  76. }
  77. static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
  78. {
  79. vcpu->arch.pc = val;
  80. }
  81. static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
  82. {
  83. return vcpu->arch.pc;
  84. }
  85. static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
  86. {
  87. return vcpu->arch.fault_dear;
  88. }
  89. static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu)
  90. {
  91. /* Magic page is only supported on e500v2 */
  92. #ifdef CONFIG_KVM_E500V2
  93. return true;
  94. #else
  95. return false;
  96. #endif
  97. }
  98. #endif /* __ASM_KVM_BOOKE_H__ */