Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2685067imj; Mon, 11 Feb 2019 07:01:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbCfP+E7d4vPEciikkm03moj4YfLt1m8NTSGU+cQ235p7Mf19UdBPlkUIB3U5M6RZyTdrxR X-Received: by 2002:a63:6506:: with SMTP id z6mr33956550pgb.334.1549897285151; Mon, 11 Feb 2019 07:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897285; cv=none; d=google.com; s=arc-20160816; b=CyXu0x6L7zvJI/B1BuM8JyitaV3KQC1QXHP3hYfmG34HXwvfxAtZVg6FrJEesfUiAX Lb6Re9WpwqpsY+za1Ypa7MNr8qXysmxi+RIT4KGvQSWMyeJOpuVYMJvxZo66iJ5PBScB 9wXD9ZT2WFskEHHLvlqPkK+knRSeTufnSI49tLRFBdKicscYbRgNpC8vPmWoAfqmLRnz nEiRe/4EkLiX+idM6+LTSEpAlBr9q6gU1jUDfach/5umh+oUdkIk4+Q4AGJAgXTKUQcT wf+vqPp6O19BHqxvdDs9CoWZ5hIygUFJEOlSNwLYqD/bDg2eRnA8/mt0izYHYkiJuEj4 SxCw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Q4d93aRz6hMuR5Waikomb9yjD4ZriHcxLBQSTBZs4IU=; b=cjZC5g4rfqvFXpsz+kvoI6U8x98TWurVgbTYgsyrHqkUBg8EFHmBJY/hqTEPZnEWpj DCXqj6u4IDRtKdQYQCefXbg3k6javoE3+MFyVegEkyHkWP2EvDp5bU5jkDzAOqTLuzwd CBRtL77mCYX+Tf4yqqu9IpwqQ2wFuW/EIotqvOk+ozddOva2wTssAgPTzLzPCPfqBtIL jC/EWnu4mBOqfEvQr+NA6I8/37exAP6UsVFaCDP/ydWowLLJWw33b6mHhDj1ebiZmd5T 4d9B9E3A2QWvlD6wrdHFgfUq6VurIS7qGsdKMgdByjYdGQ0L+CsksXNfUezsvborb67U S7Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OizTPr4L; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si9361668plr.50.2019.02.11.07.01.07; Mon, 11 Feb 2019 07:01:25 -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=OizTPr4L; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389263AbfBKO7J (ORCPT + 99 others); Mon, 11 Feb 2019 09:59:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:46844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389714AbfBKO7F (ORCPT ); Mon, 11 Feb 2019 09:59:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A78D206BA; Mon, 11 Feb 2019 14:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897144; bh=p4Ety/U7j/8+xNeXTgMbczlm6SSSlp05rVJ+Fa1T7Ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OizTPr4LtFfv1QwHPrBm+vKwbm6HjBrQmytGqNg2WpsvUYVQ1WmtV0KxJV/s0OJcv Pbo6kBcpQuNlyLsbHbn4fVuSXR3GZbNAhohsuewalh2zeh2+sLDU2s7jKGmkje8P7a XHCp3ov7w0xPfKTDrmaLbVrttbJ1FQduxJ1LIj20= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Mark Rutland , Marc Zyngier , Sasha Levin Subject: [PATCH 4.14 105/205] arm64: KVM: Skip MMIO insn after emulation Date: Mon, 11 Feb 2019 15:18:23 +0100 Message-Id: <20190211141835.430716432@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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