26 #define E500_PID_NUM 3
27 #define E500_TLB_NUM 2
29 #define E500_TLB_VALID 1
30 #define E500_TLB_DIRTY 2
31 #define E500_TLB_BITMAP 4
42 #ifdef CONFIG_KVM_E500V2
96 #ifdef CONFIG_KVM_E500V2
111 #define KVM_E500_TLB0_WAY_SIZE 128
112 #define KVM_E500_TLB0_WAY_NUM 2
114 #define KVM_E500_TLB0_SIZE (KVM_E500_TLB0_WAY_SIZE * KVM_E500_TLB0_WAY_NUM)
115 #define KVM_E500_TLB1_SIZE 16
117 #define index_of(tlbsel, esel) (((tlbsel) << 16) | ((esel) & 0xFFFF))
118 #define tlbsel_of(index) ((index) >> 16)
119 #define esel_of(index) ((index) & 0xFFFF)
121 #define E500_TLB_USER_PERM_MASK (MAS3_UX|MAS3_UR|MAS3_UW)
122 #define E500_TLB_SUPER_PERM_MASK (MAS3_SX|MAS3_SR|MAS3_SW)
123 #define MAS2_ATTRIB_MASK \
125 #define MAS3_ATTRIB_MASK \
126 (MAS3_U0 | MAS3_U1 | MAS3_U2 | MAS3_U3 \
127 | E500_TLB_USER_PERM_MASK | E500_TLB_SUPER_PERM_MASK)
143 #ifdef CONFIG_KVM_E500V2
145 unsigned int as,
unsigned int gid,
146 unsigned int pr,
int avoid_recursion);
150 static inline unsigned int
153 return (tlbe->
mas1 >> 7) & 0x1f;
158 return tlbe->
mas2 & 0xfffff000;
163 unsigned int pgsize = get_tlb_size(tlbe);
164 return 1ULL << 10 << pgsize;
170 return get_tlb_eaddr(tlbe) + bytes - 1;
175 return tlbe->
mas7_3 & ~0xfffULL;
178 static inline unsigned int
181 return (tlbe->
mas1 >> 16) & 0xff;
184 static inline unsigned int
187 return (tlbe->
mas1 >> 12) & 0x1;
190 static inline unsigned int
193 return (tlbe->
mas1 >> 31) & 0x1;
196 static inline unsigned int
199 return (tlbe->
mas1 >> 30) & 0x1;
202 static inline unsigned int
208 static inline unsigned int get_cur_pid(
struct kvm_vcpu *
vcpu)
210 return vcpu->
arch.pid & 0xff;
213 static inline unsigned int get_cur_as(
struct kvm_vcpu *
vcpu)
215 return !!(vcpu->
arch.shared->msr & (MSR_IS | MSR_DS));
218 static inline unsigned int get_cur_pr(
struct kvm_vcpu *
vcpu)
220 return !!(vcpu->
arch.shared->msr & MSR_PR);
223 static inline unsigned int get_cur_spid(
const struct kvm_vcpu *
vcpu)
225 return (vcpu->
arch.shared->mas6 >> 16) & 0xff;
228 static inline unsigned int get_cur_sas(
const struct kvm_vcpu *vcpu)
230 return vcpu->
arch.shared->mas6 & 0x1;
233 static inline unsigned int get_tlb_tlbsel(
const struct kvm_vcpu *vcpu)
239 return (vcpu->
arch.shared->mas0 >> 28) & 0x1;
242 static inline unsigned int get_tlb_nv_bit(
const struct kvm_vcpu *vcpu)
244 return vcpu->
arch.shared->mas0 & 0xfff;
247 static inline unsigned int get_tlb_esel_bit(
const struct kvm_vcpu *vcpu)
249 return (vcpu->
arch.shared->mas0 >> 16) & 0xfff;
252 static inline int tlbe_is_host_safe(
const struct kvm_vcpu *vcpu,
257 if (!get_tlb_v(tlbe))
260 #ifndef CONFIG_KVM_BOOKE_HV
263 if (get_tlb_ts(tlbe) != !!(vcpu->
arch.shared->msr & MSR_IS))
267 gpa = get_tlb_raddr(tlbe);
286 #ifdef CONFIG_KVM_BOOKE_HV
287 #define kvmppc_e500_get_tlb_stid(vcpu, gtlbe) get_tlb_tid(gtlbe)
288 #define get_tlbmiss_tid(vcpu) get_cur_pid(vcpu)
289 #define get_tlb_sts(gtlbe) (gtlbe->mas1 & MAS1_TS)
294 static inline unsigned int get_tlbmiss_tid(
struct kvm_vcpu *vcpu)
297 unsigned int tidseld = (vcpu->
arch.shared->mas4 >> 16) & 0xf;
299 return vcpu_e500->pid[tidseld];
303 #define get_tlb_sts(gtlbe) (MAS1_TS)