kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: KVM: do not sign extend on unsigned MMIO load
@ 2015-05-07 12:47 Nicholas Mc Guire
  2015-05-08 14:16 ` James Hogan
  0 siblings, 1 reply; 7+ messages in thread
From: Nicholas Mc Guire @ 2015-05-07 12:47 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: Paolo Bonzini, Ralf Baechle, kvm, linux-mips, linux-kernel,
	Nicholas Mc Guire

Fix possible unintended sign extension in unsigned MMIO loads by casting
to uint16_t in the case of mmio_needed != 2.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Thanks to James Hogan <james.hogan@imgtec.com> for the explaination of 
mmio_needed (there is not really any helpful comment in the code on this)
in this case (mmio_needed!=2) it should be unsigned.

Patch was only compile tested msp71xx_defconfig + CONFIG_KVM=m

Patch is against 4.1-rc2 (localversion-next is -next-20150506)

 arch/mips/kvm/emulate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index 6230f37..2f0fc60 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -2415,7 +2415,7 @@ enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu,
 		if (vcpu->mmio_needed == 2)
 			*gpr = *(int16_t *) run->mmio.data;
 		else
-			*gpr = *(int16_t *) run->mmio.data;
+			*gpr = *(uint16_t *)run->mmio.data;
 
 		break;
 	case 1:
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-08 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-07 12:47 [PATCH] MIPS: KVM: do not sign extend on unsigned MMIO load Nicholas Mc Guire
2015-05-08 14:16 ` James Hogan
2015-06-08  8:33   ` James Hogan
2015-06-10 12:57     ` Jiri Slaby
2015-06-12 12:07     ` Luis Henriques
2015-06-19 19:14     ` Greg KH
2015-07-08 14:25       ` [PATCH stable <3.17] MIPS: KVM: Do " James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).