Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1758438pxb; Mon, 12 Apr 2021 06:11:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ2f9znbFf9vWtOVlsqcH3EJzXQvl2Zo56lBQtN90zNp3VLV8VeVlTnwovrt/uEBo9W1Hj X-Received: by 2002:a63:df56:: with SMTP id h22mr26974636pgj.84.1618233081645; Mon, 12 Apr 2021 06:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618233081; cv=none; d=google.com; s=arc-20160816; b=sOkG4HEB36HLizmAspszNocXoqopVlQFxViiMb+JrXEPFDTzGXoOOZWmHNKRBGihdX 79bWNv3kklBbjOTchEQ7LaHqTXvtBzmelywkQ6qr2fOUlGNOcPczGdz51Hn+/lBM608d Vr0ThZ8wigf3kZ6uNeHg+VHrpYz3LA58q+Z7SesHTs91BDhJV0PbcIj4r/TVzMnOkbVd nvipYjwbN4f/XJUsmHZDka/h+srpYvHbXB+Js+owpKcWr590ds3M1xPaLfV9V06ImqAg IBJf2YSkf+A0vCYngayFuoIyqn6JiSv/9rcaziPoyt2h5YhJzFzihmMy+HeESqGw5fEh 8GIw== 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=1K0iw42KNFYBkLsYKyjD7325njwHj63G+RvjjAS+EuE=; b=gUZ9bAeEUDZ9cG9PAa7tUAzFWgjBLm/G4jEO2Z006zDBCznve/TQlyrtqz0fOqZC8F yroqeNdGynjawOI3pC+ZtYlIdHWdKJ3Gu8LXk/CFY+StiX5nFJDj1PsZcMXv/A9mlILM cLkq4t6VpAgNiliYfeLHB/991s3WVe4kTHJXdN9rIFfCdM5lmmXXJNBKUAOKjn5AJLpB IUR0n4XZ+bHB59VLD09YnNxyLvYtqeYJ08dogPAI8soyl4URA1QcS2Ovq0XYEZWVujr9 LEabCS0cl3HM+lU0YW9lHtdke1BZRmmkKk8OlguyNNgbttNcrYg4Td10zS+Q9vN4E9Fz 2Mzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="R/IakVPV"; 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 a14si13716290pjv.27.2021.04.12.06.11.09; Mon, 12 Apr 2021 06:11:21 -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="R/IakVPV"; 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 S241867AbhDLNKO (ORCPT + 99 others); Mon, 12 Apr 2021 09:10:14 -0400 Received: from wforward5-smtp.messagingengine.com ([64.147.123.35]:51081 "EHLO wforward5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241768AbhDLNKE (ORCPT ); Mon, 12 Apr 2021 09:10:04 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailforward.west.internal (Postfix) with ESMTP id 66D4B16A9; Mon, 12 Apr 2021 09:09:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 12 Apr 2021 09:09:45 -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=1K0iw42KNFYBkLsYKyjD7325njwHj63G+RvjjAS+EuE=; b=R/IakVPV utKtTSlbR0+xhb25rcCLvulXpHR/hFfF3pvjb/uGYY7Kp9bxL00Iz35pdGilK65i J6pS7y2UxVqx6LqdM6IjpzpEs16qVcGDRfHF7gkm8Scc7uL7pJVDBTt7Oq116EH+ UKodGf2pyc2DDSfTTjiKo/Y7v+n1I1qsuOfWOWUGx9PfySM0x2x8lcwXn0L1uZV/ 4j2saZCOT5PQwZDf8Ry+BKd3IntfCGnaBSK4F3311JbMV97WdZ0uqYZaksBfxNgX mp0XYPfn0dAsYD6YypG8a6Wvhv2N5ItLRqOjyZ9tTzsjtaJsQx3z+Jd4EfWnvNVu h3+rHPvDH+EvKA== 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 9333B24005D; Mon, 12 Apr 2021 09:09:42 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id db9db3bc; 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 4/6] KVM: x86: pass a proper reason to kvm_emulate_instruction() Date: Mon, 12 Apr 2021 14:09:35 +0100 Message-Id: <20210412130938.68178-5-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 Declare various causes of emulation and use them as appropriate. Signed-off-by: Joao Martins Signed-off-by: David Edmondson --- arch/x86/include/asm/kvm_host.h | 6 ++++++ arch/x86/kvm/mmu/mmu.c | 4 ++-- arch/x86/kvm/x86.c | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 556dc51e322a..79e9ca756742 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1529,6 +1529,12 @@ extern u64 kvm_mce_cap_supported; enum { EMULREASON_UNKNOWN = 0, + EMULREASON_SKIP, + EMULREASON_GP, + EMULREASON_IO, + EMULREASON_IO_COMPLETE, + EMULREASON_UD, + EMULREASON_PF, }; int kvm_emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type, diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 515ff790b7c5..14ddf1a5ac12 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5056,8 +5056,8 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 error_code, if (!mmio_info_in_cache(vcpu, cr2_or_gpa, direct) && !is_guest_mode(vcpu)) emulation_type |= EMULTYPE_ALLOW_RETRY_PF; emulate: - return x86_emulate_instruction(vcpu, cr2_or_gpa, emulation_type, 0, - insn, insn_len); + return x86_emulate_instruction(vcpu, cr2_or_gpa, emulation_type, + EMULREASON_PF, insn, insn_len); } EXPORT_SYMBOL_GPL(kvm_mmu_page_fault); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 88519bf6bd00..41020eba8e21 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6197,7 +6197,7 @@ int handle_ud(struct kvm_vcpu *vcpu) emul_type = EMULTYPE_TRAP_UD_FORCED; } - return kvm_emulate_instruction(vcpu, emul_type, 0); + return kvm_emulate_instruction(vcpu, emul_type, EMULREASON_UD); } EXPORT_SYMBOL_GPL(handle_ud); @@ -9343,7 +9343,8 @@ static inline int complete_emulated_io(struct kvm_vcpu *vcpu) int r; vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); - r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE, 0); + r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE, + EMULREASON_IO_COMPLETE); srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); return r; } -- 2.30.2