Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp210209rdb; Tue, 5 Dec 2023 03:23:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZHKCN8xC0e+Pkky+kIOZ0IrRiuSSMKLLH0A7aJYnQxlEnSnnJ5Fb2OVBe+qegz6kkhSaf X-Received: by 2002:a17:902:c408:b0:1d0:6ffd:cea0 with SMTP id k8-20020a170902c40800b001d06ffdcea0mr3638113plk.89.1701775417545; Tue, 05 Dec 2023 03:23:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701775417; cv=none; d=google.com; s=arc-20160816; b=VxrplNFwkgxFoWz8jl9wquqjlUOHavHK3Yq4H6yxjkfN/ii6flJRx5qlp4/xZj45v7 wrdjo/GwXJ7Q+flD2bV0C6DzMpWvh7i+kArfzRqkRsHy+kHOhPZz+zAIlXh+4bNwzvp7 nz6woXmEpFcP73csvJy64xhZyH1DD2jmkj2CunFivkRhW++ldWp4bEI7uuc/o4WASyp3 qAgpBrJMXFDlbDBe82pdNzPYVSZ3qr1dwTHAMYia0msfSKMJObzNaDjLg22q6RwW9KdI /eEKW6uE1C57kJvycG7zhWpXChgsir+Icu4PrFzfA2yCw4QgOnqfUA3gK1CfFdAN0Sh7 7a7w== 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=W6K6QDQ1PjFq5xNjsQi6yuGJggPcNK3D2E89u5Y/lVA=; fh=uCCWEUVpLc/xDP/D3WvGY/BxHU9d0NQYu/T71GEsNmA=; b=ywwcbsAzUrNPTR9RhRjhkc5263kdXHhWqqI8TsdmFUTeMECOiC1omFdknGt9SrZGB8 R+ZT4+EGb99/tBzaBXzX5ZY2hrX4mQl+vAmSr4yI5/lBdtMs4FNk55pJPB28nM7AMhSE L1Lki84FEvMw7Uw+s7EaJmvrZlE6BljSgSnNheZQDYY0yl/JhPFYRfvmaIvy4xugXw5J nJBMgcDB0V1YVwgUHEVSkX7IbqSkG0OhLivltQ/eA4JNQDoG8RZax05ukdm9hGPhjURL zELZ4HQnDic75UMeQ1yyzwHegtnH0/0Sk1Ky+QPcpjjsNU+z2d6c1AhQRNRIHz9bIARH d3Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OlibKuwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y14-20020a1709027c8e00b001cfc4d8eddfsi9223384pll.602.2023.12.05.03.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 03:23:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OlibKuwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5499480C2446; Tue, 5 Dec 2023 03:23:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442117AbjLELXE (ORCPT + 99 others); Tue, 5 Dec 2023 06:23:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442178AbjLELVn (ORCPT ); Tue, 5 Dec 2023 06:21:43 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF6B0D4F; Tue, 5 Dec 2023 03:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701775297; x=1733311297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SQLskgfezeMmMUQK7hRm+in8U5EG93C8+IUmjWFkZJ4=; b=OlibKuwEy+FIpwvCBCGs+hWByLFWCrEdYyxCLxmuOIaVvDNP73o4CRR4 rolX/+63VpPr7pTHYRG8d4crgG0FBeVAFdfScFiDMparkTpkfigk10Bju iBip5D6Yfu6JAFG0E8wi890/2x08MLIKtmfU2VBuEjho1EEFUFzzpRETX 6+vzpc1Wdf409bqbNeaCRWvxtg6jKI8ApaUTn6m/yCqyk8CiAYfZVmuZl BXIP1MbQ8WU0K6NdcQf2Bb8h/fhmOB7HnSFFTYs6K4DxoRRx1Vmmmi0O8 V+9mqmj/hR9q48R1s6rRxsa+x6EXC7WqAFHkT6n8vGwVZnJSD3fMpJe2n A==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="942718" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="942718" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 03:21:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018193012" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018193012" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 03:21:26 -0800 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com, shan.kang@intel.com Subject: [PATCH v13 32/35] KVM: VMX: Call fred_entry_from_kvm() for IRQ/NMI handling Date: Tue, 5 Dec 2023 02:50:21 -0800 Message-ID: <20231205105030.8698-33-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205105030.8698-1-xin3.li@intel.com> References: <20231205105030.8698-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 05 Dec 2023 03:23:36 -0800 (PST) When FRED is enabled, call fred_entry_from_kvm() to handle IRQ/NMI in IRQ/NMI induced VM exits. Tested-by: Shan Kang Signed-off-by: Xin Li Acked-by: Paolo Bonzini --- arch/x86/kvm/vmx/vmx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index be20a60047b1..ba5cd26137e0 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -6962,14 +6963,16 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu) { u32 intr_info = vmx_get_intr_info(vcpu); unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK; - gate_desc *desc = (gate_desc *)host_idt_base + vector; if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm, "unexpected VM-Exit interrupt info: 0x%x", intr_info)) return; kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ); - vmx_do_interrupt_irqoff(gate_offset(desc)); + if (cpu_feature_enabled(X86_FEATURE_FRED)) + fred_entry_from_kvm(EVENT_TYPE_EXTINT, vector); + else + vmx_do_interrupt_irqoff(gate_offset((gate_desc *)host_idt_base + vector)); kvm_after_interrupt(vcpu); vcpu->arch.at_instruction_boundary = true; @@ -7262,7 +7265,10 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, if ((u16)vmx->exit_reason.basic == EXIT_REASON_EXCEPTION_NMI && is_nmi(vmx_get_intr_info(vcpu))) { kvm_before_interrupt(vcpu, KVM_HANDLING_NMI); - vmx_do_nmi_irqoff(); + if (cpu_feature_enabled(X86_FEATURE_FRED)) + fred_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR); + else + vmx_do_nmi_irqoff(); kvm_after_interrupt(vcpu); } -- 2.43.0