Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1757841pxb; Mon, 12 Apr 2021 06:10:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwenyXAJM+qq/aZNoBF7qYw95kx7l6hhNvyhGA0lgIkFxwo/PWW6q9vnmxDx509DNHakNs2 X-Received: by 2002:a17:90a:a613:: with SMTP id c19mr16777769pjq.117.1618233040627; Mon, 12 Apr 2021 06:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618233040; cv=none; d=google.com; s=arc-20160816; b=cpkbUweBsfrxpn355soJpNPiKNXIFgOiVBCvAN7ZRKKWe01lanKrAnTCAI7NDyD5YY EuL/RTS6ISzb4lSJ4GC6EYDDco7XanY/9NZ+y3Nql4+Xmihu8+elp0EN1oIoSkkfqTJp SIdS7q4n7JXgQPER6Rn6Jfo0O5lQi+kXTo4rb2no9rYbSWmMIEk/YY96bFlYs5tfMEon GhInim8ijRdE0hEuKPejLTod1eR0ER47pEyc+R/6XRGccATbYISrHlahjPJjLa13bMWF a3ZlF2TdDtphmmxs+cVt1bxPbKHC450agr+zObuIlMcjC/QJ4bbY3y3W/TPmkV29nYvZ rXtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XPQNUQKEXupnV63KWZ9Hhwvi3ppqpPrjyh3rpylALHE=; b=uc6adMcY1Eb4qCQ7zB0LDDqTk2FvFx76xwaOkgaex+PFaGWcuSz9vY8fMH6q4psVQ0 CxI1h8brjr93yqwz/h4183FwpbWIOab+f21f9jRSxUrIckSax1qQ71xtvdWmbWsDChaE uMjWqQixlV1H2O0LZ+4oBJSeiiz/QCnzjm2Vys9jLWAUmz/Ibs+A3ZEDAEe6+lm7Q2GZ qyKkfLU9WxdxW8Ktzhb0RSF9zZPqnUAhBn46G/UU5v5HHddTPMXI4cy8MLIqGL+yVPLe GIr7YQf5JZkA2W7dY86LIXyZ7Zzy9XPvIgOXfgK3sXI4YrPishHZQum5ENYWPpGbjEEf QuGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=aM0WZ6Oq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si11953431pfl.94.2021.04.12.06.10.28; Mon, 12 Apr 2021 06:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=aM0WZ6Oq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241807AbhDLNKH (ORCPT + 99 others); Mon, 12 Apr 2021 09:10:07 -0400 Received: from wforward5-smtp.messagingengine.com ([64.147.123.35]:55157 "EHLO wforward5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241746AbhDLNKD (ORCPT ); Mon, 12 Apr 2021 09:10:03 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.west.internal (Postfix) with ESMTP id CA7041664; Mon, 12 Apr 2021 09:09:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 12 Apr 2021 09:09:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=XPQNUQKEXupnV63KWZ9Hhwvi3ppqpPrjyh3rpylALHE=; b=aM0WZ6Oq GYhemC17mMmRqflfeG+bRPqUL3JAwGcaMQP75i0iYjXJdoH0x/1MKrRBeNj5xJL0 qkmo7XzwxBh5Y+RsAaLj6VhvtB+oEw0ZuRp4EPmfxZf+Nqw70jOMfQ7JBnDp7T7i 2OjPBjUlLRhOwar2fVCewM+xZ4D1W256pRPOY1r87EY4ljB9ThxKsCq7aRED+YXr 4woCEEgD2m2qPTuyxyYhI+W0JzvfJ/MOzN5Z5Ws3+TOOvEXJXBld4Di7huHLtYiS jLodJWKtQOu0Aa3cbGSTEacx0OzzSz97eI38igykUBmxgHmbZAEzB73+aBtOmNgj OFuSFurOTH064g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekjedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffrghvihgu ucfgughmohhnughsohhnuceouggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrd gtohhmqeenucggtffrrghtthgvrhhnpedufeetjefgfefhtdejhfehtdfftefhteekhefg leehfffhiefhgeelgfejtdehkeenucfkphepkedurddukeejrddviedrvdefkeenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurghvihgurdgv ughmohhnughsohhnsehorhgrtghlvgdrtghomh X-ME-Proxy: Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net [81.187.26.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 3A00F240066; Mon, 12 Apr 2021 09:09:41 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id d79b2990; Mon, 12 Apr 2021 13:09:38 +0000 (UTC) From: David Edmondson To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , "H. Peter Anvin" , x86@kernel.org, Sean Christopherson , Thomas Gleixner , Joerg Roedel , Wanpeng Li , Borislav Petkov , Jim Mattson , Ingo Molnar , Joao Martins , David Edmondson Subject: [PATCH 2/6] KVM: x86: pass emulation_reason to handle_emulation_failure() Date: Mon, 12 Apr 2021 14:09:33 +0100 Message-Id: <20210412130938.68178-3-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210412130938.68178-1-david.edmondson@oracle.com> References: <20210412130938.68178-1-david.edmondson@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joao Martins Make the emulation_reason available up stack when reporting an emulation failure. Signed-off-by: Joao Martins Signed-off-by: David Edmondson --- arch/x86/kvm/x86.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 87e76f3aee64..b9225012ebd2 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7119,7 +7119,8 @@ void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) } EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt); -static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type) +static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type, + int emulation_reason) { ++vcpu->stat.insn_emulation_fail; trace_kvm_emulate_insn_failed(vcpu); @@ -7132,7 +7133,8 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type) if (emulation_type & EMULTYPE_SKIP) { vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; - vcpu->run->internal.ndata = 0; + vcpu->run->internal.data[0] = emulation_reason; + vcpu->run->internal.ndata = 1; return 0; } @@ -7141,7 +7143,8 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type) if (!is_guest_mode(vcpu) && static_call(kvm_x86_get_cpl)(vcpu) == 0) { vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; - vcpu->run->internal.ndata = 0; + vcpu->run->internal.data[0] = emulation_reason; + vcpu->run->internal.ndata = 1; return 0; } @@ -7490,7 +7493,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, inject_emulated_exception(vcpu); return 1; } - return handle_emulation_failure(vcpu, emulation_type); + return handle_emulation_failure(vcpu, emulation_type, + emulation_reason); } } @@ -7547,7 +7551,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, emulation_type)) return 1; - return handle_emulation_failure(vcpu, emulation_type); + return handle_emulation_failure(vcpu, emulation_type, + emulation_reason); } if (ctxt->have_exception) { -- 2.30.2