From patchwork Wed Oct 24 11:25:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 1637671 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B974B40135 for ; Wed, 24 Oct 2012 11:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758410Ab2JXLbF (ORCPT ); Wed, 24 Oct 2012 07:31:05 -0400 Received: from ozlabs.org ([203.10.76.45]:50350 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758242Ab2JXL36 (ORCPT ); Wed, 24 Oct 2012 07:29:58 -0400 Received: by ozlabs.org (Postfix, from userid 1011) id 0D30A2C01FB; Wed, 24 Oct 2012 22:29:55 +1100 (EST) From: Rusty Russell To: Will Deacon Cc: Christoffer Dall , "kvm@vger.kernel.org" , dave.martin@linaro.org, Rusty Russell Subject: [PATCH 09/10] kvm: avoid reference vcpu->arch.hxfar by making thumb offset_addr relative Date: Wed, 24 Oct 2012 21:55:22 +1030 Message-Id: <1351077923-17977-10-git-send-email-rusty@rustcorp.com.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1351077923-17977-1-git-send-email-rusty@rustcorp.com.au> References: <20121022174555.GD26619@mudshark.cambridge.arm.com> <1351077923-17977-1-git-send-email-rusty@rustcorp.com.au> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Rusty Russell For generic code we won't know the hdfar, so make the offset_addr relative in thumb mode. Signed-off-by: Rusty Russell --- arch/arm/kvm/emulate.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c index 5ac4cf7..c0014e1 100644 --- a/arch/arm/kvm/emulate.c +++ b/arch/arm/kvm/emulate.c @@ -567,18 +567,17 @@ struct thumb_decode { static bool decode_thumb_wb(struct kvm_vcpu *vcpu, struct arm_insn *ti) { u8 imm8 = ti->instr & 0xff; - u32 offset_addr = vcpu->arch.hxfar; ti->P = (ti->instr >> 10) & 1; ti->U = (ti->instr >> 9) & 1; ti->Rn = (ti->instr >> 16) & 0xf; ti->Rd = (ti->instr >> 12) & 0xf; - /* Handle Writeback */ + /* Handle Writeback: offset_addr relative to fault address. */ if (!ti->P && ti->U) - ti->offset_addr = offset_addr + imm8; + ti->offset_addr = imm8; else if (!ti->P && !ti->U) - ti->offset_addr = offset_addr - imm8; + ti->offset_addr = -imm8; return true; } @@ -740,8 +739,10 @@ static bool execute(struct kvm_vcpu *vcpu, struct kvm_exit_mmio *mmio, if (kvm_vcpu_reg_is_pc(vcpu, ai->Rn)) return false; - if (!ai->P) - *vcpu_reg(vcpu, ai->Rn) = ai->offset_addr; + if (!ai->P) { + *vcpu_reg(vcpu, ai->Rn) + = vcpu->arch.hxfar + ai->offset_addr; + } vcpu->arch.mmio.sign_extend = ai->sign_extend; return true; }