From patchwork Fri Nov 9 15:07:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 995582 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lcxR5vN5"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="NxFve5VF"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42s3Rr2NnDz9s0n for ; Sat, 10 Nov 2018 02:07:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p41I401vTEPHuoAdGcWgoypg2Hf/d/WczZx0sWvs7Bg=; b=lcxR5vN5mWfx9W qVBMIWQOAZU60E0giKZMfuGyuU/f8CSpuymRkOYVFzQn5DwZsKLm/kzuYVcSJeTgkJNBo8cuFYkcX Dnkh+OrzFzLC9MrPmxKnJ/oOspm8PjC1DR3+Unf172NU2UTRh/nYcnOMdMpya+YegHBg4ItP/MK59 ZX7UpuW+DrjigHkPd9avnxt1osHJ2h//ECw4ALhJH5WHH2YapNNyXDUscKMAw4sYqkSnbRPaJGpe1 76DdE54yzpuG9XDyf8tbIu7jwa2VA5Z9ffFX7NYSmo4VDq4u2r7T+ljjdDpsblZBdS9zG3Uf0GJZF T7KdzNNsahkJB/PLfpog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL8Nt-0003yi-Eo; Fri, 09 Nov 2018 15:07:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL8Nj-0003qA-GH for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Nov 2018 15:07:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=h44iUnwAjS5QuDKN/NKj6zFmJZoFIaYED3GsA3GpOVc=; b=NxFve5VForMaGWaiUJkCUgFmcu 6wSVm/xQHH2cv7oc2ex0NWomc47SYvz0pzpePkyhE1hyl54eWi4tnl+WbJyCCCL2BiBC4KhLmiLML /ZmLjhCbsHYqlKlD+155wPDUMdxcUYtViEMsXGlucf1+IPR+/+/U57h+m42fve9C99txKL1ika0s9 Eb1Oj4KD0WQ3sd0fMZTpKhKdGOeJR+fpQRX+ll8ZB0CEHjlTbBp+q3oKCuEeh5D1AHVNEnuHDzazj tADBdMDg4/Ef4tdA2qmjpqaIQg+Efqd2HxV7lrMTESFFOL8god8qWl2yowp0PR/zmDOad27WX6085 Jr8mJT+g==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL8Nf-0004Yx-Q4 for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2018 15:07:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 99A9215AB; Fri, 9 Nov 2018 07:07:22 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4467D3F5BD; Fri, 9 Nov 2018 07:07:21 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] kvm/arm: skip MMIO insn after emulation Date: Fri, 9 Nov 2018 15:07:10 +0000 Message-Id: <20181109150711.45864-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181109150711.45864-1-mark.rutland@arm.com> References: <20181109150711.45864-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181109_150732_027800_60C07755 X-CRM114-Status: GOOD ( 12.49 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-5.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, peter.maydell@linaro.org, marc.zyngier@arm.com, christoffer.dall@arm.com, alex.bennee@linaro.org, kvmarm@lists.cs.columbia.edu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org When we emulate an MMIO instruction, we advance the CPU state within decode_hsr(), before emulating the instruction effects. Having this logic in decode_hsr() is opaque, and advancing the state before emulation is problematic. It gets in the way of applying consistent single-step logic, and it prevents us from being able to fail an MMIO instruction with a synchronous exception. Clean this up by only advancing the CPU state *after* the effects of the instruction are emulated. Signed-off-by: Mark Rutland Cc: Alex Bennée Cc: Christoffer Dall Cc: Marc Zyngier Cc: Peter Maydell Reviewed-by: Alex Bennée Reviewed-by: Christoffer Dall --- virt/kvm/arm/mmio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/mmio.c b/virt/kvm/arm/mmio.c index dac7ceb1a677..08443a15e6be 100644 --- a/virt/kvm/arm/mmio.c +++ b/virt/kvm/arm/mmio.c @@ -117,6 +117,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) vcpu_set_reg(vcpu, vcpu->arch.mmio_decode.rt, data); } + /* + * The MMIO instruction is emulated and should not be re-executed + * in the guest. + */ + kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); + return 0; } @@ -144,11 +150,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, bool *is_write, int *len) vcpu->arch.mmio_decode.sign_extend = sign_extend; vcpu->arch.mmio_decode.rt = rt; - /* - * The MMIO instruction is emulated and should not be re-executed - * in the guest. - */ - kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); return 0; }