From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFnV2-0001VO-Pg for qemu-devel@nongnu.org; Thu, 16 Jul 2015 14:03:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFnUz-0002pV-PK for qemu-devel@nongnu.org; Thu, 16 Jul 2015 14:03:12 -0400 Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 16 Jul 2015 20:02:51 +0200 Message-Id: <1437069778-8954-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1437069778-8954-1-git-send-email-pbonzini@redhat.com> References: <1437069778-8954-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 1/8] mips/kvm: Fix Big endian 32-bit register access List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: James Hogan , Leon Alrae , kvm@vger.kernel.org, Aurelien Jarno , qemu-stable@nongnu.org From: James Hogan Fix access to 32-bit registers on big endian targets. The pointer passed to the kernel must be for the actual 32-bit value, not a temporary 64-bit value, otherwise on big endian systems the kernel will only interpret the upper half. Signed-off-by: James Hogan Cc: Paolo Bonzini Cc: Leon Alrae Cc: Aurelien Jarno Cc: kvm@vger.kernel.org Cc: qemu-stable@nongnu.org Message-Id: <1429871214-23514-2-git-send-email-james.hogan@imgtec.com> Signed-off-by: Paolo Bonzini --- target-mips/kvm.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/target-mips/kvm.c b/target-mips/kvm.c index bd64a70..85256f3 100644 --- a/target-mips/kvm.c +++ b/target-mips/kvm.c @@ -235,10 +235,9 @@ int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level) static inline int kvm_mips_put_one_reg(CPUState *cs, uint64_t reg_id, int32_t *addr) { - uint64_t val64 = *addr; struct kvm_one_reg cp0reg = { .id = reg_id, - .addr = (uintptr_t)&val64 + .addr = (uintptr_t)addr }; return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &cp0reg); @@ -270,18 +269,12 @@ static inline int kvm_mips_put_one_reg64(CPUState *cs, uint64_t reg_id, static inline int kvm_mips_get_one_reg(CPUState *cs, uint64_t reg_id, int32_t *addr) { - int ret; - uint64_t val64 = 0; struct kvm_one_reg cp0reg = { .id = reg_id, - .addr = (uintptr_t)&val64 + .addr = (uintptr_t)addr }; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &cp0reg); - if (ret >= 0) { - *addr = val64; - } - return ret; + return kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &cp0reg); } static inline int kvm_mips_get_one_ulreg(CPUState *cs, uint64 reg_id, -- 2.4.3