]> Pileus Git - ~andy/linux/commitdiff
KVM: PPC: e500: emulate tlbilx
authorScott Wood <scottwood@freescale.com>
Tue, 20 Dec 2011 15:34:39 +0000 (15:34 +0000)
committerAvi Kivity <avi@redhat.com>
Sun, 8 Apr 2012 09:51:16 +0000 (12:51 +0300)
tlbilx is the new, preferred invalidation instruction.  It is not
found on e500 prior to e500mc, but there should be no harm in
supporting it on all e500.

Based on code from Ashish Kalra <Ashish.Kalra@freescale.com>.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/powerpc/kvm/e500.h
arch/powerpc/kvm/e500_emulate.c
arch/powerpc/kvm/e500_tlb.c

index f4dee55ae6c7d799c3bfce408c4d63b8e6482c48..ce3f163f702e9c9512044d9e7a1ae28d5f1b24ef 100644 (file)
@@ -124,6 +124,7 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500,
 int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu);
 int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu);
 int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb);
+int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb);
 int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb);
 int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500);
 void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500);
index c80794d097d33cd911791da6a66ff7475dca3c02..af02c18fc798367b81e5dfb8d106cd37d1a860f6 100644 (file)
@@ -22,6 +22,7 @@
 #define XOP_TLBSX   914
 #define XOP_TLBRE   946
 #define XOP_TLBWE   978
+#define XOP_TLBILX  18
 
 int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
                            unsigned int inst, int *advance)
@@ -29,6 +30,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
        int emulated = EMULATE_DONE;
        int ra;
        int rb;
+       int rt;
 
        switch (get_op(inst)) {
        case 31:
@@ -47,6 +49,13 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
                        emulated = kvmppc_e500_emul_tlbsx(vcpu,rb);
                        break;
 
+               case XOP_TLBILX:
+                       ra = get_ra(inst);
+                       rb = get_rb(inst);
+                       rt = get_rt(inst);
+                       emulated = kvmppc_e500_emul_tlbilx(vcpu, rt, ra, rb);
+                       break;
+
                case XOP_TLBIVAX:
                        ra = get_ra(inst);
                        rb = get_rb(inst);
index c8ce51d03a2fcbdbfb10a09fcf551d5f1c34d7a3..6eb5d655bdb4e7a77ca60c051212538c80cc5b39 100644 (file)
@@ -631,6 +631,58 @@ int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb)
        return EMULATE_DONE;
 }
 
+static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
+                      int pid, int rt)
+{
+       struct kvm_book3e_206_tlb_entry *tlbe;
+       int tid, esel;
+
+       /* invalidate all entries */
+       for (esel = 0; esel < vcpu_e500->gtlb_params[tlbsel].entries; esel++) {
+               tlbe = get_entry(vcpu_e500, tlbsel, esel);
+               tid = get_tlb_tid(tlbe);
+               if (rt == 0 || tid == pid) {
+                       inval_gtlbe_on_host(vcpu_e500, tlbsel, esel);
+                       kvmppc_e500_gtlbe_invalidate(vcpu_e500, tlbsel, esel);
+               }
+       }
+}
+
+static void tlbilx_one(struct kvmppc_vcpu_e500 *vcpu_e500, int pid,
+                      int ra, int rb)
+{
+       int tlbsel, esel;
+       gva_t ea;
+
+       ea = kvmppc_get_gpr(&vcpu_e500->vcpu, rb);
+       if (ra)
+               ea += kvmppc_get_gpr(&vcpu_e500->vcpu, ra);
+
+       for (tlbsel = 0; tlbsel < 2; tlbsel++) {
+               esel = kvmppc_e500_tlb_index(vcpu_e500, ea, tlbsel, pid, -1);
+               if (esel >= 0) {
+                       inval_gtlbe_on_host(vcpu_e500, tlbsel, esel);
+                       kvmppc_e500_gtlbe_invalidate(vcpu_e500, tlbsel, esel);
+                       break;
+               }
+       }
+}
+
+int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb)
+{
+       struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
+       int pid = get_cur_spid(vcpu);
+
+       if (rt == 0 || rt == 1) {
+               tlbilx_all(vcpu_e500, 0, pid, rt);
+               tlbilx_all(vcpu_e500, 1, pid, rt);
+       } else if (rt == 3) {
+               tlbilx_one(vcpu_e500, pid, ra, rb);
+       }
+
+       return EMULATE_DONE;
+}
+
 int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu)
 {
        struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);