Skip to contentSkip to conversation

Add kvmppc_mmu_dtlb/itlb_miss for booke

PATCH In review Liu Yu 2 participants 4 messages Dec 18, 2008 – Dec 19, 2008

Subsystems (2)
lore
Share & tools
lore

Liu Yu

author
#0 lore raw

PATCH 7/10 Add kvmppc_mmu_dtlb/itlb_miss for booke

When itlb or dtlb miss happens, E500 needs to update some mmu registers. So that the auto-load mechanism can work on E500 when write a tlb entry.

---
 arch/powerpc/include/asm/kvm_ppc.h |    2 ++
 arch/powerpc/kvm/44x_tlb.c         |    8 ++++++++
 arch/powerpc/kvm/booke.c           |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm_ppc.h +2 -0
index f4b041b..82547c8 100644
@@ -63,6 +63,8 @@ extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
 extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
 extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
                               gva_t eaddr);
+extern void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu);
+extern void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu);
 
 extern struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm,
                                                 unsigned int id);
arch/powerpc/kvm/44x_tlb.c +8 -0
index e67b731..4a16f47 100644
@@ -232,6 +232,14 @@ int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
 	return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as);
 }
 
+void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu)
+{
+}
+
+void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu)
+{
+}
+
 static void kvmppc_44x_shadow_release(struct kvmppc_vcpu_44x *vcpu_44x,
                                       unsigned int stlb_index)
 {
arch/powerpc/kvm/booke.c +2 -0
index a73b395..933c406 100644
@@ -295,6 +295,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 			kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DTLB_MISS);
 			vcpu->arch.dear = vcpu->arch.fault_dear;
 			vcpu->arch.esr = vcpu->arch.fault_esr;
+			kvmppc_mmu_dtlb_miss(vcpu);
 			kvmppc_account_exit(vcpu, DTLB_REAL_MISS_EXITS);
 			r = RESUME_GUEST;
 			break;
@@ -337,6 +338,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 		if (gtlb_index < 0) {
 			/* The guest didn't have a mapping for it. */
 			kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ITLB_MISS);
+			kvmppc_mmu_itlb_miss(vcpu);
 			kvmppc_account_exit(vcpu, ITLB_REAL_MISS_EXITS);
 			break;
 		}
Signature · 1 line
1.5.4
#1 lore raw
Quoted 55 lines · Liu Yu

When itlb or dtlb miss happens, E500 needs to update some mmu registers. So that the auto-load mechanism can work on E500 when write a tlb entry.

---
 arch/powerpc/include/asm/kvm_ppc.h |    2 ++
 arch/powerpc/kvm/44x_tlb.c         |    8 ++++++++
 arch/powerpc/kvm/booke.c           |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/kvm_ppc.h +2 -0
index f4b041b..82547c8 100644
@@ -63,6 +63,8 @@ extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
 extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
 extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
                               gva_t eaddr);
+extern void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu);
+extern void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu);
 
 extern struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm,
                                                 unsigned int id);
arch/powerpc/kvm/44x_tlb.c +8 -0
index e67b731..4a16f47 100644
@@ -232,6 +232,14 @@ int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
 	return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as);
 }
 
+void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu)
+{
+}
+
+void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu)
+{
+}
+
 static void kvmppc_44x_shadow_release(struct kvmppc_vcpu_44x *vcpu_44x,
                                       unsigned int stlb_index)
 {
arch/powerpc/kvm/booke.c +1 -0
index a73b395..933c406 100644
@@ -295,6 +295,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 			kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DTLB_MISS);
 			vcpu->arch.dear = vcpu->arch.fault_dear;
 			vcpu->arch.esr = vcpu->arch.fault_esr;
+			kvmppc_mmu_dtlb_miss(vcpu);
 			kvmppc_account_exit(vcpu, DTLB_REAL_MISS_EXITS);
 			r = RESUME_GUEST;
 			break;

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 344

Quoted 7 lines
arch/powerpc/kvm/booke.c +1 -0
@@ -337,6 +338,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 		if (gtlb_index < 0) {
 			/* The guest didn't have a mapping for it. */
 			kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ITLB_MISS);
+			kvmppc_mmu_itlb_miss(vcpu);
 			kvmppc_account_exit(vcpu, ITLB_REAL_MISS_EXITS);
 			break;
 		}

I don't think you've supplied an implementation of these hooks for e500. Does it build with this patch series applied?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
author
#2 lore raw
In reply to Liu Yu
Quoted 80 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hollis Blanchard
Sent: Friday, December 19, 2008 7:49 AM
To: Liu Yu-B13201
Cc: [email protected]
Subject: Re: [PATCH 07/10] Add kvmppc_mmu_dtlb/itlb_miss for booke

Quoted 1 line · Liu Yu

When itlb or dtlb miss happens, E500 needs to update some

mmu registers.

Quoted 1 line

So that the auto-load mechanism can work on E500 when write

a tlb entry.

Review

Quoted 9 lines
---
 arch/powerpc/include/asm/kvm_ppc.h |    2 ++
 arch/powerpc/kvm/44x_tlb.c         |    8 ++++++++
 arch/powerpc/kvm/booke.c           |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/powerpc/include/asm/kvm_ppc.h

arch/powerpc/include/asm/kvm_ppc.h extern int kvmppc_mmu_dtlb_index(struct

Quoted 4 lines

index f4b041b..82547c8 100644

arch/powerpc/include/asm/kvm_ppc.h +0 -0
@@ -63,6 +63,8 @@ extern int kvmppc_mmu_dtlb_index(struct 

kvm_vcpu *vcpu, gva_t eaddr);

arch/powerpc/include/asm/kvm_ppc.h extern int kvmppc_mmu_dtlb_index(struct · line 63

Quoted 1 line
arch/powerpc/include/asm/kvm_ppc.h +0 -0
 extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, 

gva_t eaddr);

arch/powerpc/include/asm/kvm_ppc.h extern int kvmppc_mmu_dtlb_index(struct · line 64

Quoted 1 line
arch/powerpc/include/asm/kvm_ppc.h +0 -0
 extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, 

unsigned int gtlb_index,

arch/powerpc/kvm/44x_tlb.c int kvmppc_mmu_dtlb_index(struct

Quoted 11 lines
arch/powerpc/include/asm/kvm_ppc.h +2 -0
                               gva_t eaddr);
+extern void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu);
+extern void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu);
 
 extern struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm,
                                                 unsigned int id);
arch/powerpc/kvm/44x_tlb.c +0 -0
index e67b731..4a16f47 100644
@@ -232,6 +232,14 @@ int kvmppc_mmu_dtlb_index(struct 

kvm_vcpu *vcpu, gva_t eaddr)

arch/powerpc/kvm/44x_tlb.c int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)

Quoted 12 lines
arch/powerpc/kvm/44x_tlb.c +8 -0
 	return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as);
 }
 
+void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu)
+{
+}
+
+void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu)
+{
+}
+
 static void kvmppc_44x_shadow_release(struct 

kvmppc_vcpu_44x *vcpu_44x,

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run

Quoted 7 lines
arch/powerpc/kvm/44x_tlb.c +0 -0
                                       unsigned int stlb_index)
 {
arch/powerpc/kvm/booke.c +0 -0
index a73b395..933c406 100644
@@ -295,6 +295,7 @@ int kvmppc_handle_exit(struct kvm_run 

*run, struct kvm_vcpu *vcpu,

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run · line 295

Quoted 1 line
arch/powerpc/kvm/booke.c +0 -0
 			kvmppc_booke_queue_irqprio(vcpu, 

BOOKE_IRQPRIO_DTLB_MISS);

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run

Quoted 7 lines
arch/powerpc/kvm/booke.c +1 -0
 			vcpu->arch.dear = vcpu->arch.fault_dear;
 			vcpu->arch.esr = vcpu->arch.fault_esr;
+			kvmppc_mmu_dtlb_miss(vcpu);
 			kvmppc_account_exit(vcpu, DTLB_REAL_MISS_EXITS);
 			r = RESUME_GUEST;
 			break;
@@ -337,6 +338,7 @@ int kvmppc_handle_exit(struct kvm_run 

*run, struct kvm_vcpu *vcpu,

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,

Quoted 3 lines
arch/powerpc/kvm/booke.c +0 -0
 		if (gtlb_index < 0) {
 			/* The guest didn't have a mapping for it. */
 			kvmppc_booke_queue_irqprio(vcpu, 

BOOKE_IRQPRIO_ITLB_MISS);

Quoted 9 lines

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, · line 344

Quoted 4 lines
arch/powerpc/kvm/booke.c +1 -0
+			kvmppc_mmu_itlb_miss(vcpu);
 			kvmppc_account_exit(vcpu, ITLB_REAL_MISS_EXITS);
 			break;
 		}

I don't think you've supplied an implementation of these hooks for e500.
Does it build with this patch series applied?

Sorry, these hooks for e500 exists in "[PATCH 06/10] E500 TLB emulation".

--
+static inline void kvmppc_e500_deliver_tlb_miss(struct kvm_vcpu *vcpu,
+ unsigned int eaddr, int as)
+{
+ struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
+ unsigned int victim, pidsel, tsized;
+ int tlbsel;
+
+ /* since we only have two TLBs, only lower bit is used. */
+ tlbsel = (vcpu_e500->mas4 >> 28) & 0x1;
+ victim = (tlbsel = 0) ? tlb0_get_next_victim(vcpu_e500) : 0;
+ pidsel = (vcpu_e500->mas4 >> 16) & 0xf;
+ tsized = (vcpu_e500->mas4 >> 8) & 0xf;
+
+ vcpu_e500->mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(victim)
+ | MAS0_NV(vcpu_e500->guest_tlb_nv[tlbsel]);
+ vcpu_e500->mas1 = MAS1_VALID | (as ? MAS1_TS : 0)
+ | MAS1_TID(vcpu_e500->pid[pidsel])
+ | MAS1_TSIZE(tsized);
+ vcpu_e500->mas2 = (eaddr & MAS2_EPN)
+ | (vcpu_e500->mas4 & MAS2_ATTRIB_MASK);
+ vcpu_e500->mas3 &= MAS3_U0 | MAS3_U1 | MAS3_U2 | MAS3_U3;
+ vcpu_e500->mas6 = (vcpu_e500->mas6 & MAS6_SPID1)
+ | (get_cur_pid(vcpu) << 16)
+ | (as ? MAS6_SAS : 0);
+ vcpu_e500->mas7 = 0;
+}

+void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu)
+{
+ unsigned int as = !!(vcpu->arch.msr & MSR_IS);
+
+ kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.pc, as);
+}
+
+void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu)
+{
+ unsigned int as = !!(vcpu->arch.msr & MSR_DS);
+
+ kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.fault_dear, as);
+}

author
#3 lore raw
In reply to Liu Yu
Quoted 9 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hollis Blanchard
Sent: Friday, December 19, 2008 7:49 AM
To: Liu Yu-B13201
Cc: [email protected]
Subject: Re: [PATCH 07/10] Add kvmppc_mmu_dtlb/itlb_miss for booke

Quoted 4 lines

I don't think you've supplied an implementation of these hooks for e500.
Does it build with this patch series applied?

Yes. I have git-am all this patch series, rebuilt and retested them.