kvm_book3s_64.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_BOOK3S_64_H__
  20. #define __ASM_KVM_BOOK3S_64_H__
  21. #ifdef CONFIG_KVM_BOOK3S_PR
  22. static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu)
  23. {
  24. preempt_disable();
  25. return &get_paca()->shadow_vcpu;
  26. }
  27. static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
  28. {
  29. preempt_enable();
  30. }
  31. #endif
  32. #define SPAPR_TCE_SHIFT 12
  33. static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
  34. unsigned long pte_index)
  35. {
  36. unsigned long rb, va_low;
  37. rb = (v & ~0x7fUL) << 16; /* AVA field */
  38. va_low = pte_index >> 3;
  39. if (v & HPTE_V_SECONDARY)
  40. va_low = ~va_low;
  41. /* xor vsid from AVA */
  42. if (!(v & HPTE_V_1TB_SEG))
  43. va_low ^= v >> 12;
  44. else
  45. va_low ^= v >> 24;
  46. va_low &= 0x7ff;
  47. if (v & HPTE_V_LARGE) {
  48. rb |= 1; /* L field */
  49. if (cpu_has_feature(CPU_FTR_ARCH_206) &&
  50. (r & 0xff000)) {
  51. /* non-16MB large page, must be 64k */
  52. /* (masks depend on page size) */
  53. rb |= 0x1000; /* page encoding in LP field */
  54. rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */
  55. rb |= (va_low & 0xfe); /* AVAL field (P7 doesn't seem to care) */
  56. }
  57. } else {
  58. /* 4kB page */
  59. rb |= (va_low & 0x7ff) << 12; /* remaining 11b of VA */
  60. }
  61. rb |= (v >> 54) & 0x300; /* B field */
  62. return rb;
  63. }
  64. #endif /* __ASM_KVM_BOOK3S_64_H__ */