Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbbEGM4L (ORCPT ); Thu, 7 May 2015 08:56:11 -0400 Received: from www.osadl.org ([62.245.132.105]:36095 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751363AbbEGM4I (ORCPT ); Thu, 7 May 2015 08:56:08 -0400 From: Nicholas Mc Guire To: Gleb Natapov Cc: Paolo Bonzini , Ralf Baechle , kvm@vger.kernel.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] MIPS: KVM: do not sign extend on unsigned MMIO load Date: Thu, 7 May 2015 14:47:50 +0200 Message-Id: <1431002870-30098-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1275 Lines: 38 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 --- Thanks to James Hogan 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 -- 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/