kvm_e500.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) 2008-2011 Freescale Semiconductor, Inc. All rights reserved.
  3. *
  4. * Author: Yu Liu, <yu.liu@freescale.com>
  5. *
  6. * Description:
  7. * This file is derived from arch/powerpc/include/asm/kvm_44x.h,
  8. * by Hollis Blanchard <hollisb@us.ibm.com>.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License, version 2, as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __ASM_KVM_E500_H__
  15. #define __ASM_KVM_E500_H__
  16. #include <linux/kvm_host.h>
  17. #define BOOKE_INTERRUPT_SIZE 36
  18. #define E500_PID_NUM 3
  19. #define E500_TLB_NUM 2
  20. #define E500_TLB_VALID 1
  21. #define E500_TLB_DIRTY 2
  22. struct tlbe_ref {
  23. pfn_t pfn;
  24. unsigned int flags; /* E500_TLB_* */
  25. };
  26. struct tlbe_priv {
  27. struct tlbe_ref ref; /* TLB0 only -- TLB1 uses tlb_refs */
  28. };
  29. struct vcpu_id_table;
  30. struct kvmppc_e500_tlb_params {
  31. int entries, ways, sets;
  32. };
  33. struct kvmppc_vcpu_e500 {
  34. /* Unmodified copy of the guest's TLB -- shared with host userspace. */
  35. struct kvm_book3e_206_tlb_entry *gtlb_arch;
  36. /* Starting entry number in gtlb_arch[] */
  37. int gtlb_offset[E500_TLB_NUM];
  38. /* KVM internal information associated with each guest TLB entry */
  39. struct tlbe_priv *gtlb_priv[E500_TLB_NUM];
  40. struct kvmppc_e500_tlb_params gtlb_params[E500_TLB_NUM];
  41. unsigned int gtlb_nv[E500_TLB_NUM];
  42. /*
  43. * information associated with each host TLB entry --
  44. * TLB1 only for now. If/when guest TLB1 entries can be
  45. * mapped with host TLB0, this will be used for that too.
  46. *
  47. * We don't want to use this for guest TLB0 because then we'd
  48. * have the overhead of doing the translation again even if
  49. * the entry is still in the guest TLB (e.g. we swapped out
  50. * and back, and our host TLB entries got evicted).
  51. */
  52. struct tlbe_ref *tlb_refs[E500_TLB_NUM];
  53. unsigned int host_tlb1_nv;
  54. u32 host_pid[E500_PID_NUM];
  55. u32 pid[E500_PID_NUM];
  56. u32 svr;
  57. /* vcpu id table */
  58. struct vcpu_id_table *idt;
  59. u32 l1csr0;
  60. u32 l1csr1;
  61. u32 hid0;
  62. u32 hid1;
  63. u32 tlb0cfg;
  64. u32 tlb1cfg;
  65. u64 mcar;
  66. struct page **shared_tlb_pages;
  67. int num_shared_tlb_pages;
  68. struct kvm_vcpu vcpu;
  69. };
  70. static inline struct kvmppc_vcpu_e500 *to_e500(struct kvm_vcpu *vcpu)
  71. {
  72. return container_of(vcpu, struct kvmppc_vcpu_e500, vcpu);
  73. }
  74. #endif /* __ASM_KVM_E500_H__ */