aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm
diff options
context:
space:
mode:
authorHollis Blanchard <hollisb@us.ibm.com>2009-01-03 17:23:02 -0500
committerAvi Kivity <avi@redhat.com>2009-03-24 05:02:56 -0400
commitbe8d1cae07d5acf4a61046d7def5eda40f0981e1 (patch)
tree32560487e3fd05bb6c64c394016e9461c70b2227 /arch/powerpc/kvm
parent58a96214a306fc7fc66105097eea9c4f3bfa35bc (diff)
KVM: ppc: turn tlb_xlate() into a per-core hook (and give it a better name)
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm')
-rw-r--r--arch/powerpc/kvm/44x.c6
-rw-r--r--arch/powerpc/kvm/44x_tlb.c10
-rw-r--r--arch/powerpc/kvm/44x_tlb.h7
-rw-r--r--arch/powerpc/kvm/booke.c10
4 files changed, 13 insertions, 20 deletions
diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c
index a66bec57265a..8383603dd8a4 100644
--- a/arch/powerpc/kvm/44x.c
+++ b/arch/powerpc/kvm/44x.c
@@ -149,8 +149,6 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
149int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu, 149int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
150 struct kvm_translation *tr) 150 struct kvm_translation *tr)
151{ 151{
152 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
153 struct kvmppc_44x_tlbe *gtlbe;
154 int index; 152 int index;
155 gva_t eaddr; 153 gva_t eaddr;
156 u8 pid; 154 u8 pid;
@@ -166,9 +164,7 @@ int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
166 return 0; 164 return 0;
167 } 165 }
168 166
169 gtlbe = &vcpu_44x->guest_tlb[index]; 167 tr->physical_address = kvmppc_mmu_xlate(vcpu, index, eaddr);
170
171 tr->physical_address = tlb_xlate(gtlbe, eaddr);
172 /* XXX what does "writeable" and "usermode" even mean? */ 168 /* XXX what does "writeable" and "usermode" even mean? */
173 tr->valid = 1; 169 tr->valid = 1;
174 170
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index e8ed22f28eae..2f14671e8a15 100644
--- a/arch/powerpc/kvm/44x_tlb.c
+++ b/arch/powerpc/kvm/44x_tlb.c
@@ -208,6 +208,16 @@ int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr, unsigned int pid,
208 return -1; 208 return -1;
209} 209}
210 210
211gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
212 gva_t eaddr)
213{
214 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
215 struct kvmppc_44x_tlbe *gtlbe = &vcpu_44x->guest_tlb[gtlb_index];
216 unsigned int pgmask = get_tlb_bytes(gtlbe) - 1;
217
218 return get_tlb_raddr(gtlbe) | (eaddr & pgmask);
219}
220
211int kvmppc_44x_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr) 221int kvmppc_44x_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
212{ 222{
213 unsigned int as = !!(vcpu->arch.msr & MSR_IS); 223 unsigned int as = !!(vcpu->arch.msr & MSR_IS);
diff --git a/arch/powerpc/kvm/44x_tlb.h b/arch/powerpc/kvm/44x_tlb.h
index 772191f29e62..05b6f7eef5b6 100644
--- a/arch/powerpc/kvm/44x_tlb.h
+++ b/arch/powerpc/kvm/44x_tlb.h
@@ -85,11 +85,4 @@ static inline unsigned int get_mmucr_sts(const struct kvm_vcpu *vcpu)
85 return (vcpu->arch.mmucr >> 16) & 0x1; 85 return (vcpu->arch.mmucr >> 16) & 0x1;
86} 86}
87 87
88static inline gpa_t tlb_xlate(struct kvmppc_44x_tlbe *tlbe, gva_t eaddr)
89{
90 unsigned int pgmask = get_tlb_bytes(tlbe) - 1;
91
92 return get_tlb_raddr(tlbe) | (eaddr & pgmask);
93}
94
95#endif /* __KVM_POWERPC_TLB_H__ */ 88#endif /* __KVM_POWERPC_TLB_H__ */
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 85b9e2fc6c6b..56d6ed69ed60 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -286,8 +286,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
286 286
287 /* XXX move to a 440-specific file. */ 287 /* XXX move to a 440-specific file. */
288 case BOOKE_INTERRUPT_DTLB_MISS: { 288 case BOOKE_INTERRUPT_DTLB_MISS: {
289 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
290 struct kvmppc_44x_tlbe *gtlbe;
291 unsigned long eaddr = vcpu->arch.fault_dear; 289 unsigned long eaddr = vcpu->arch.fault_dear;
292 int gtlb_index; 290 int gtlb_index;
293 gpa_t gpaddr; 291 gpa_t gpaddr;
@@ -305,8 +303,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
305 break; 303 break;
306 } 304 }
307 305
308 gtlbe = &vcpu_44x->guest_tlb[gtlb_index]; 306 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr);
309 gpaddr = tlb_xlate(gtlbe, eaddr);
310 gfn = gpaddr >> PAGE_SHIFT; 307 gfn = gpaddr >> PAGE_SHIFT;
311 308
312 if (kvm_is_visible_gfn(vcpu->kvm, gfn)) { 309 if (kvm_is_visible_gfn(vcpu->kvm, gfn)) {
@@ -332,8 +329,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
332 329
333 /* XXX move to a 440-specific file. */ 330 /* XXX move to a 440-specific file. */
334 case BOOKE_INTERRUPT_ITLB_MISS: { 331 case BOOKE_INTERRUPT_ITLB_MISS: {
335 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
336 struct kvmppc_44x_tlbe *gtlbe;
337 unsigned long eaddr = vcpu->arch.pc; 332 unsigned long eaddr = vcpu->arch.pc;
338 gpa_t gpaddr; 333 gpa_t gpaddr;
339 gfn_t gfn; 334 gfn_t gfn;
@@ -352,8 +347,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
352 347
353 kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS); 348 kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS);
354 349
355 gtlbe = &vcpu_44x->guest_tlb[gtlb_index]; 350 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr);
356 gpaddr = tlb_xlate(gtlbe, eaddr);
357 gfn = gpaddr >> PAGE_SHIFT; 351 gfn = gpaddr >> PAGE_SHIFT;
358 352
359 if (kvm_is_visible_gfn(vcpu->kvm, gfn)) { 353 if (kvm_is_visible_gfn(vcpu->kvm, gfn)) {