From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EFACC10F01 for ; Mon, 18 Feb 2019 14:16:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E3DB2177E for ; Mon, 18 Feb 2019 14:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550499414; bh=1bB/fmSSkBOdklc1O7sbIFSgWwQuJNke0eeF5zICOW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c1xssSYLadw3Gt/EB8E1b5D4ADhtZL2afBqOe4arCZxZRZgBN/I8t74U3y3xzG09x Nua6o7jlA+eSJzuoiLRXDAEuepM4OKghuRCvPSmDIAV3uChJ3l3Q+w8V+VW4777XXp 25elwxxPTsnwjgJnVbw25V5w+Hraq4DjhPE03xj8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391507AbfBROKc (ORCPT ); Mon, 18 Feb 2019 09:10:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:54310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391504AbfBROKc (ORCPT ); Mon, 18 Feb 2019 09:10:32 -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 F05DC217D7; Mon, 18 Feb 2019 14:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550499031; bh=1bB/fmSSkBOdklc1O7sbIFSgWwQuJNke0eeF5zICOW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9hJA4MKCtom4w6Zw4PRlfnrMaLj7INr8mOu59reJgPg5xJ/BnKTAjjbAuYRqkeoM gxBhyfTXI4sum3wLeXQW/sMubw5t+N7sqmmqnJl+Dc7tM4iy+SdSMSFXY5VMf3ECbX cHUreOLpLF4YAta2s0bUYZYd1sr1p5oKMg1GrRIw= 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 3.18 029/108] arm64: KVM: Skip MMIO insn after emulation Date: Mon, 18 Feb 2019 14:43:25 +0100 Message-Id: <20190218133520.887570098@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133519.525507231@linuxfoundation.org> References: <20190218133519.525507231@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 3.18-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 --- arch/arm/kvm/mmio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c index 4cb5a93182e9..c215bb4423ac 100644 --- a/arch/arm/kvm/mmio.c +++ b/arch/arm/kvm/mmio.c @@ -118,6 +118,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) *vcpu_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; } @@ -154,11 +160,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, 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