From: James Hogan <james.hogan@imgtec.com>
To: Paolo Bonzini <pbonzini@redhat.com>, Ralf Baechle <ralf@linux-mips.org>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Paul Burton" <paul.burton@imgtec.com>,
"James Hogan" <james.hogan@imgtec.com>,
linux-mips@linux-mips.org, kvm@vger.kernel.org
Subject: [PATCH 7/9] MIPS: KVM: Recognise r6 CACHE encoding
Date: Mon, 4 Jul 2016 19:35:13 +0100 [thread overview]
Message-ID: <1467657315-19975-8-git-send-email-james.hogan@imgtec.com> (raw)
In-Reply-To: <1467657315-19975-1-git-send-email-james.hogan@imgtec.com>
Recognise the new MIPSr6 CACHE instruction encoding rather than the
pre-r6 one when an r6 kernel is being built. A SPECIAL3 opcode is used
and the immediate field is reduced to 9 bits wide since MIPSr6.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
---
arch/mips/kvm/dyntrans.c | 5 ++++-
arch/mips/kvm/emulate.c | 21 ++++++++++++++++++++-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/arch/mips/kvm/dyntrans.c b/arch/mips/kvm/dyntrans.c
index 8a1833b9eb38..91ebd2b6034f 100644
--- a/arch/mips/kvm/dyntrans.c
+++ b/arch/mips/kvm/dyntrans.c
@@ -72,7 +72,10 @@ int kvm_mips_trans_cache_va(union mips_instruction inst, u32 *opc,
synci_inst.i_format.opcode = bcond_op;
synci_inst.i_format.rs = inst.i_format.rs;
synci_inst.i_format.rt = synci_op;
- synci_inst.i_format.simmediate = inst.i_format.simmediate;
+ if (cpu_has_mips_r6)
+ synci_inst.i_format.simmediate = inst.spec3_format.simmediate;
+ else
+ synci_inst.i_format.simmediate = inst.i_format.simmediate;
return kvm_mips_trans_replace(vcpu, opc, synci_inst);
}
diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index f0fa9e956056..62e6a7b313ae 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -1601,7 +1601,10 @@ enum emulation_result kvm_mips_emulate_cache(union mips_instruction inst,
base = inst.i_format.rs;
op_inst = inst.i_format.rt;
- offset = inst.i_format.simmediate;
+ if (cpu_has_mips_r6)
+ offset = inst.spec3_format.simmediate;
+ else
+ offset = inst.i_format.simmediate;
cache = op_inst & CacheOp_Cache;
op = op_inst & CacheOp_Op;
@@ -1764,11 +1767,27 @@ enum emulation_result kvm_mips_emulate_inst(u32 cause, u32 *opc,
er = kvm_mips_emulate_load(inst, cause, run, vcpu);
break;
+#ifndef CONFIG_CPU_MIPSR6
case cache_op:
++vcpu->stat.cache_exits;
trace_kvm_exit(vcpu, KVM_TRACE_EXIT_CACHE);
er = kvm_mips_emulate_cache(inst, opc, cause, run, vcpu);
break;
+#else
+ case spec3_op:
+ switch (inst.spec3_format.func) {
+ case cache6_op:
+ ++vcpu->stat.cache_exits;
+ trace_kvm_exit(vcpu, KVM_TRACE_EXIT_CACHE);
+ er = kvm_mips_emulate_cache(inst, opc, cause, run,
+ vcpu);
+ break;
+ default:
+ goto unknown;
+ };
+ break;
+unknown:
+#endif
default:
kvm_err("Instruction emulation not supported (%p/%#x)\n", opc,
--
2.4.10
next prev parent reply other threads:[~2016-07-04 18:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 18:35 [PATCH 0/9] MIPS: KVM: MIPS r6 support James Hogan
2016-07-04 18:35 ` [PATCH 3/9] MIPS: KVM: Fix fpu.S misassembly with r6 James Hogan
2016-07-04 18:35 ` [PATCH 4/9] MIPS: KVM: Fix pre-r6 ll/sc instructions on r6 James Hogan
2016-07-04 18:35 ` [PATCH 5/9] MIPS: KVM: Don't save/restore lo/hi for r6 James Hogan
2016-07-04 18:35 ` [PATCH 6/9] MIPS: KVM: Support r6 compact branch emulation James Hogan
2016-07-04 18:35 ` James Hogan [this message]
2016-07-04 18:35 ` [PATCH 8/9] MIPS: KVM: Decode RDHWR more strictly James Hogan
2016-07-05 11:16 ` Sergei Shtylyov
2016-07-05 12:39 ` Paolo Bonzini
2016-07-05 14:34 ` Sergei Shtylyov
2016-07-05 12:51 ` Ralf Baechle
2016-07-04 18:35 ` [PATCH 9/9] MIPS: KVM: Emulate generic QEMU machine on r6 T&E James Hogan
2016-07-05 13:58 ` [PATCH 0/9] MIPS: KVM: MIPS r6 support Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467657315-19975-8-git-send-email-james.hogan@imgtec.com \
--to=james.hogan@imgtec.com \
--cc=kvm@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=paul.burton@imgtec.com \
--cc=pbonzini@redhat.com \
--cc=ralf@linux-mips.org \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox