All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Paolo Bonzini <pbonzini@redhat.com>, Ralf Baechle <ralf@linux-mips.org>
Cc: "James Hogan" <james.hogan@imgtec.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	linux-mips@linux-mips.org, kvm@vger.kernel.org
Subject: [PATCH 01/17] MIPS: KVM: Fix translation of MFC0 ErrCtl
Date: Wed, 15 Jun 2016 19:29:45 +0100	[thread overview]
Message-ID: <1466015401-24433-2-git-send-email-james.hogan@imgtec.com> (raw)
In-Reply-To: <1466015401-24433-1-git-send-email-james.hogan@imgtec.com>

The MIPS KVM dynamic translation is meant to translate "MFC0 rt, ErrCtl"
instructions into "ADD rt, zero, zero" to zero the destination register,
however the rt register number was copied into rt of the ADD instruction
encoding, which is the 2nd source operand. This results in "ADD zero,
zero, rt" which is a no-op, so only the first execution of each such
MFC0 from ErrCtl will actually read 0.

Fix the shift to put the rt from the MFC0 encoding into the rd field of
the ADD.

Fixes: 50c8308538dc ("KVM/MIPS32: Binary patching of select privileged instructions.")
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kvm/dyntrans.c b/arch/mips/kvm/dyntrans.c
index d4a86fb239cd..79b134c91333 100644
--- a/arch/mips/kvm/dyntrans.c
+++ b/arch/mips/kvm/dyntrans.c
@@ -82,7 +82,7 @@ int kvm_mips_trans_mfc0(u32 inst, u32 *opc, struct kvm_vcpu *vcpu)
 
 	if ((rd == MIPS_CP0_ERRCTL) && (sel == 0)) {
 		mfc0_inst = CLEAR_TEMPLATE;
-		mfc0_inst |= ((rt & 0x1f) << 16);
+		mfc0_inst |= ((rt & 0x1f) << 11);
 	} else {
 		mfc0_inst = LW_TEMPLATE;
 		mfc0_inst |= ((rt & 0x1f) << 16);
-- 
2.4.10

  reply	other threads:[~2016-06-15 18:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15 18:29 [PATCH 00/17] MIPS: KVM: Misc KVM T&E improvements James Hogan
2016-06-15 18:29 ` James Hogan [this message]
2016-06-15 18:29 ` [PATCH 02/17] MIPS: KVM: Factor writing of translated guest instructions James Hogan
2016-06-15 18:29 ` [PATCH 03/17] MIPS: KVM: Convert emulation to use asm/inst.h James Hogan
2016-06-15 19:04   ` Ralf Baechle
2016-06-15 18:29 ` [PATCH 04/17] MIPS: KVM: Pass all unknown registers to callbacks James Hogan
2016-06-15 18:29 ` [PATCH 05/17] MIPS: KVM: Make KVM_GET_REG_LIST dynamic James Hogan
2016-06-15 18:29 ` [PATCH 06/17] MIPS: KVM: Use raw_cpu_has_fpu in kvm_mips_guest_can_have_fpu() James Hogan
2016-06-15 18:29 ` [PATCH 07/17] MIPS: KVM: List FPU/MSA registers James Hogan
2016-06-15 18:29 ` [PATCH 08/17] MIPS: Clean up RDHWR handling James Hogan
2016-06-15 19:05   ` Ralf Baechle
2016-06-15 18:29 ` [PATCH 09/17] MIPS: KVM: Don't hardcode restored HWREna James Hogan
2016-06-15 21:50   ` Ralf Baechle
2016-06-15 18:29 ` [PATCH 10/17] MIPS: KVM: Allow ULRI to restrict UserLocal register James Hogan
2016-06-15 18:29 ` [PATCH 11/17] MIPS: KVM: Emulate RDHWR CPUNum register James Hogan
2016-06-15 18:29 ` [PATCH 12/17] MIPS: KVM: Add KScratch registers James Hogan
2016-06-15 18:29 ` [PATCH 13/17] MIPS: KVM: Move commpage so 0x0 is unmapped James Hogan
2016-06-15 18:29 ` [PATCH 14/17] MIPS: KVM: Use host CCA for TLB mappings James Hogan
2016-06-15 18:29 ` [PATCH 15/17] MIPS: Add define for Config.VI (virtual icache) bit James Hogan
2016-06-15 18:29   ` James Hogan
2016-06-15 19:07   ` Ralf Baechle
2016-06-15 18:30 ` [PATCH 16/17] MIPS: KVM: Report more accurate CP0_Config fields to guest James Hogan
2016-06-15 18:30 ` [PATCH 17/17] MIPS: KVM: Use mipsregs.h defs for config registers James Hogan

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=1466015401-24433-2-git-send-email-james.hogan@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.