Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753391AbbEHORe (ORCPT ); Fri, 8 May 2015 10:17:34 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:11169 "EHLO imgpgp01.kl.imgtec.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752635AbbEHORb (ORCPT ); Fri, 8 May 2015 10:17:31 -0400 X-PGP-Universal: processed; by imgpgp01.kl.imgtec.org on Fri, 08 May 2015 15:17:29 +0100 Message-ID: <554CC530.20906@imgtec.com> Date: Fri, 8 May 2015 15:16:16 +0100 From: James Hogan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Nicholas Mc Guire , Gleb Natapov CC: Paolo Bonzini , Ralf Baechle , , , Subject: Re: [PATCH] MIPS: KVM: do not sign extend on unsigned MMIO load References: <1431002870-30098-1-git-send-email-hofrat@osadl.org> In-Reply-To: <1431002870-30098-1-git-send-email-hofrat@osadl.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4TxPvu4HkAHppA9S3Lc6EsaAl9OuAmtwq" X-Originating-IP: [192.168.154.110] X-ESG-ENCRYPT-TAG: b93fcccb Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2840 Lines: 83 --4TxPvu4HkAHppA9S3Lc6EsaAl9OuAmtwq Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07/05/15 13:47, Nicholas Mc Guire wrote: > Fix possible unintended sign extension in unsigned MMIO loads by castin= g > to uint16_t in the case of mmio_needed !=3D 2. >=20 > Signed-off-by: Nicholas Mc Guire Looks good to me. I wrote an MMIO test to reproduce the issue, and this fixes it. Reviewed-by: James Hogan Tested-by: James Hogan It looks suitable for stable too (3.10+). Cheers James > --- >=20 > Thanks to James Hogan for the explaination of = > mmio_needed (there is not really any helpful comment in the code on thi= s) > in this case (mmio_needed!=3D2) it should be unsigned. >=20 > Patch was only compile tested msp71xx_defconfig + CONFIG_KVM=3Dm >=20 > Patch is against 4.1-rc2 (localversion-next is -next-20150506) >=20 > arch/mips/kvm/emulate.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > 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 =3D=3D 2) > *gpr =3D *(int16_t *) run->mmio.data; > else > - *gpr =3D *(int16_t *) run->mmio.data; > + *gpr =3D *(uint16_t *)run->mmio.data; > =20 > break; > case 1: >=20 --4TxPvu4HkAHppA9S3Lc6EsaAl9OuAmtwq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVTMU4AAoJEGwLaZPeOHZ67k0QAJPO9DMmHX3BH3vhjAcm2Qkm RFKiVTkXqyypH14iYaCy6fpuQdIqzm4cqLnT9qZK/eSGovblhSpvIUcaxAPfAEqw bsBV9ksQoONQIPrhlEXwiBW8TJa4V3ljBH9/Zx+lZuOgS79XREbrwtAH3/MhmVfF BNamNA0S3Onjh+B4uExFMROaONb+vVbQID+FBS+T/USfwrNP+QcP6RCUNtDsjhGr jj+LUn50miN1zWThm6V8fmUhgVaf6Ehcs7bUM04q5wgPV1r1xU12fsPkbZH5SbeI N+D4KkX/YS0Q/DiNy2KCMKd7DpGil9Uu9RL34WmtV4a3cfmJZJ3GWdsrQinh2PL5 R/xdGrQ/wQJZxhZ9Q2Da7FniqXoHfVFtnk/58fFVP+kD4R2BKfNp2i81dHb3zUQF FBxiBqLe/w+2gg1hrpYq0SfXGBXhc78y4qHxgbG+6f8kAJUGA6wmSULNofM1L1pO 3z8ckKDTJUnsD2Wb8RzliU2czeM94wnQE3N4MxSBndKkZ3h0YNKXO5SDKt9CxMhO 66nyZmXDi3VPmOhbE2cAimMsutpemgmIzYBTplfr2S3kNPe7UsbcbHXhjEZNCH4v QOdRCeD8QgAe6ZOmDukRcWGftq1s4WmwkXFXd/BXSH50FwsjPy3C1bCBiZ8CvwLu KDNcwhetO1VV3ufMs8s1 =aOsa -----END PGP SIGNATURE----- --4TxPvu4HkAHppA9S3Lc6EsaAl9OuAmtwq-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/