Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp219360imm; Thu, 6 Sep 2018 01:03:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZKIvd746vN6Qp0AFWof36ezP001K/1b1YRh+tGxZgatsLVhmKYjnzI/NGX9f9qrR1mJ6vE X-Received: by 2002:a17:902:468:: with SMTP id 95-v6mr1492003ple.122.1536221030662; Thu, 06 Sep 2018 01:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536221030; cv=none; d=google.com; s=arc-20160816; b=HOpxG+dS45TvAPE4KXw8uZRjZc8/Ge5kn14kNPFFrCeC9agL3Vmu9htrl2a+bk3o6S SAevj5272Mcfcsw9QIIcSPDv2xjrNT+PRDJmaeHNBKAh38/I9hb97RGeKqM8m9zq81rZ 2Fp2C024PBLRzjlgrIu654oftUngDu0c0iUbnymRWToQ0nQ1qxFb6jTLy9rQ7kN7zk5R e09OuP9OeCYTkgUlf9/+2K1TTaGIlF9PyaGl2HKdk/FO2aWcdJFfUfS61r1xOBE2nd9Z 4FRwmZLa8g7URBq4r33o8XQichm3KX5gQaxrJJLwnyF6M/pwYhvaBjt35eP875p1z0Bi EUog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=kjnK5zrRNMRpaMTGDJE4UMjbvOFec9LGv9otukEfPTQ=; b=xCh0xtYP3gPjcZaM7V3lluXX5d5qrGg84zJraXZGqFYLgEcoHILHzVCxOytSBs/liG lNgUiIoYz6cxsx9V+/F2xx444XjjS9Q/rZPOzSyxZhziqHHT9oL5C8/phO63R7GB78AK OrFvukUuyiesrVkIFZRCEEztaoJGyuU/O5zKNEeW4nkgXRTwo57dbP09M4e86ppHrdyG 8EoYKGx5cqXIchZVb5POwta4bSRBNGp7E24DXfnEomZ3Poc5ECXUKtnhJvoyN3qhO3uT aRccuLO9O+GfcGOEnVT7j9fCaaOsNJpsno2eWlThcHfRus7N2cl/fH8BfbFe0TwayZRE v7cw== ARC-Authentication-Results: i=1; mx.google.com; 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 h12-v6si4337328pll.416.2018.09.06.01.03.34; Thu, 06 Sep 2018 01:03:50 -0700 (PDT) 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; 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 S1727963AbeIFMgj (ORCPT + 99 others); Thu, 6 Sep 2018 08:36:39 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:38954 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbeIFMgj (ORCPT ); Thu, 6 Sep 2018 08:36:39 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id B337999253F060502F3D; Thu, 6 Sep 2018 16:02:22 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w8682CnL089915; Thu, 6 Sep 2018 16:02:13 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018090616022007-7466155 ; Thu, 6 Sep 2018 16:02:20 +0800 From: Yi Wang To: pbonzini@redhat.com Cc: rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wang.yi59@zte.com.cn, zhong.weidong@zte.com.cn, xu.xi8@zte.com.cn Subject: [PATCH] KVM: x86: fix failure of injecting exceptions in x86_emulate_instruction Date: Thu, 6 Sep 2018 16:02:44 +0800 Message-Id: <1536220964-8412-1-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-09-06 16:02:20, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-09-06 16:02:01, Serialize complete at 2018-09-06 16:02:01 X-MAIL: mse01.zte.com.cn w8682CnL089915 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to fix a page table walk issue, commit 6ea6e84309ca ("KVM: x86: inject exceptions produced by x86_decode_insn") check if variable ctxt->have_exception true and inject the exception. Unfortunately, ctxt->have_exception is set to true only in function x86_emulate_insn(), which won't be called before invoking inject_emulated_exception() in the 6ea6e84309ca. This patch fix this issue. Signed-off-by: Yi Wang Reviewed-by: Xi Xu --- arch/x86/kvm/emulate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 106482d..aecf9a72 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -5105,8 +5105,11 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) memcpy(ctxt->fetch.data, insn, insn_len); else { rc = __do_insn_fetch_bytes(ctxt, 1); - if (rc != X86EMUL_CONTINUE) + if (rc != X86EMUL_CONTINUE) { + if (rc == X86EMUL_PROPAGATE_FAULT) + ctxt->have_exception = true; return rc; + } } switch (mode) { -- 1.8.3.1