Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3633321imu; Mon, 28 Jan 2019 08:10:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN6EbOLCoac3URyEmQ3fd7exxF2TZWTvNXWOkmVgM/wlamHV0etFFXxhVg/00LCh2MghPGqE X-Received: by 2002:a62:c185:: with SMTP id i127mr22657576pfg.43.1548691808978; Mon, 28 Jan 2019 08:10:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691808; cv=none; d=google.com; s=arc-20160816; b=R3JXEi6RS7kOW+DZWNRRsIm5gZkSu8vyluuN6bd5TFbYKb6ndXTBFVoFBPP+vxla44 OcLj+TDb0m5YbiPki1RTicrc2BI08BZ/Xa5E5ISQNlx2nBOxeN+8GmQ7DVsqWvPnNBG2 2CRidnnjt+fT1975sVY/p4jeODMhksay1YAlJwKWj+X/q2r5RqrV9TKEidf5MEFoGjEM n6il4bc+TjpXm/hGRK8vAyjAx3UzxMvg9aOw0pvNhoCv3Be/GzR3Wa862tcKlFFwvihf xn4bekvrlPFTNGKzy9yzKgobgaQ7RFLMZLJOyfHdcWXC5Knx0l7JfEkZEi9vIOLSXY6t YGwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6ubxm3AJU1u7frop0pDN87sp7IPpnqPDaoNv2U6FU9c=; b=b77Xk3ccuaYMWgZ2mUlkesb66DRdR7aGFG16RzNPcXBwsgK2TI4fwMkGyn/2ZeIX87 sL8+lzrvIj9XZGcar/dmfRze6UiTMpZRqa8+a29jYOxOgQq41H4q3t4SDYHQ+GGRd9cb /wuKhyz2H82lxjvTa2TOZfO9+dmvTIkfjwt7isg3Blot0CbvEvB2jgOB8o2f5C740OD/ iOULB268b/+1AFdSiDyWzs/vnoNVxiC9T+EqhB4YWL9QHgL5CFhT0e/e18xCFIfk+Ba5 82FIjQdRRTRjbV0rqsf91Xpdbttz2w3ORb04UL7wD/4cPXv+UcEUzodNNRN2aQ5FcRbi S7Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2p9lt5TF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si31663467plo.254.2019.01.28.08.09.52; Mon, 28 Jan 2019 08:10:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2p9lt5TF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732248AbfA1QHj (ORCPT + 99 others); Mon, 28 Jan 2019 11:07:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:58466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731680AbfA1QHf (ORCPT ); Mon, 28 Jan 2019 11:07:35 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E046B2171F; Mon, 28 Jan 2019 16:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691654; bh=plehLW++cCBs67mqYGqkjRQlhcZgJMYE72FXx4W1ogQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2p9lt5TFaIT/BwkdkN8FwiD919p0kO8hgC47eVr4Z84HmcHKPOr1YXvMCV4QUj2RV +c4dXHolyxHf7uPp/3JWd1CSvY2Sy/KAojq9e0JYL+hMIQazgHZyqmwySE6V8waR1O ELxZ8vEW+WycdSwV9Y19bkJe4Dhd9JbWWQLP+csU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Rutland , Peter Maydell , Marc Zyngier , Sasha Levin , kvmarm@lists.cs.columbia.edu Subject: [PATCH AUTOSEL 4.19 175/258] arm64: KVM: Skip MMIO insn after emulation Date: Mon, 28 Jan 2019 10:58:01 -0500 Message-Id: <20190128155924.51521-175-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland [ Upstream commit 0d640732dbebed0f10f18526de21652931f0b2f2 ] 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. Cc: Peter Maydell Reviewed-by: Alex Bennée Reviewed-by: Christoffer Dall Signed-off-by: Mark Rutland Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- 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; } -- 2.19.1