Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp552396rwb; Thu, 12 Jan 2023 09:14:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXcx0JaV91Ou5MzcAm0Cbiw6zFSMq05RmweAFkcVNso5krV1ikbAj8J2ydahuOuC+0edcd X-Received: by 2002:a17:907:d48e:b0:862:fc76:6f8e with SMTP id vj14-20020a170907d48e00b00862fc766f8emr5193559ejc.36.1673543647017; Thu, 12 Jan 2023 09:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673543647; cv=none; d=google.com; s=arc-20160816; b=yvFYyZgDMK0n58YbJoz71tNW82jn1Lry05oDoepC18s6C2OqFuSq9Uv1nsotVC0twp SEqv15mD8cZOvp+GUvGTlq0yExN22lRaqJKW7s4BjnmhHjVeV/9ja0mYjeyWPwDetPU3 VvTilrydxveULtfFTZFyrhYEKyf1rS43gWddqU37F3Vs6aBHkwnNcv4ZqORHm1hQs0bX mBJitY8DMp38eYllbasQqqO9XyHp2sjQsz7DNEQvYZ53UCcofvf5mp9cpWFlnrUnO54b 39hjyAR+dLH2WFTUQEZ+j5S2zA6b4EaqjSRsBPV3LYUW8Ex+Yme/DHnbgfFrXeSMBvVE 1bwA== 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=MASA/gHlWekKKtL9sQZoldJCAZDpui1J6oA+xdpIezM=; b=QPADK89QjGQ4tm4zimqh3ge7/7Za8VO7kJ/F+kfNfdWZLkqbgOGicSNIx9/d8H2ILZ 53oz2AWKDCEyyjsHW+JHGVEtYDr41/PVvdnBORD+f3mQfqd4cHE3qaLh2CsNAMiGlyVX qVZl2aj1l06yaUqFRtUCPeyd0seX5LV7Eo4WlW3UuMVccfU0f4ezOuVA/3NOZm4X3vay btRaasM+NvF1BPxsC5Uji6pjFw6ugEV/1brSMkaTiETkJxGSQ+Wk+mtrx2tsI2EZAbha XCLM4BP1Hg6msEToe/EJ0b3CIapsrUnbqqWJCrx/4S6F8MTH15GSCroPNLmpcm8z/5Sm AV8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fBJmsYht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h20-20020a170906111400b007c19ace9796si14602470eja.940.2023.01.12.09.13.54; Thu, 12 Jan 2023 09:14:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fBJmsYht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbjALQhc (ORCPT + 50 others); Thu, 12 Jan 2023 11:37:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232416AbjALQhL (ORCPT ); Thu, 12 Jan 2023 11:37:11 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D06B1D5; Thu, 12 Jan 2023 08:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673541214; x=1705077214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MPWl4F7wroh7Y9p+NdgHiJYHNEUl+NXfnFsRhRHUtb8=; b=fBJmsYhtXoZ3eJvqzK5zNgu4HOyrmnFZ3ywDfiJ03iVUK9cni4XH6Nm3 P//DCfQWmACDZagd/5gBzjsAsltEJRv6yKfWIUGJXUwL69KDURYfjKG0y xXvBtvk//JoCAKacvl4aCpeGjgQpTVO0sjAM16l2XjS0xErzIji8zJA+/ px7J5Y+30n6rnvP7KDkteXI5bccvfV0aG05imh/RaisK3LWDS5zRY4t92 7YErXGV3ocpqbLAFo+f+XhDr+F/QRXDkP7cPbhH5tDhbMddDjJeVqqlmf tgDnna9AVMKgrcRZi1TxXX00hcVzUDVgPHGPKNFmpBermyq2oXRlr+I4p g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="386089615" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="386089615" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:33:33 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="726372469" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="726372469" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:33:32 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack Subject: [PATCH v11 071/113] KVM: TDX: complete interrupts after tdexit Date: Thu, 12 Jan 2023 08:32:19 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 From: Isaku Yamahata This corresponds to VMX __vmx_complete_interrupts(). Because TDX virtualize vAPIC, KVM only needs to care NMI injection. Signed-off-by: Isaku Yamahata Reviewed-by: Paolo Bonzini --- arch/x86/kvm/vmx/tdx.c | 10 ++++++++++ arch/x86/kvm/vmx/tdx.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 4bd651b31172..40546e692222 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -461,6 +461,14 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) vcpu->kvm->vm_bugged = true; } +static void tdx_complete_interrupts(struct kvm_vcpu *vcpu) +{ + /* Avoid costly SEAMCALL if no nmi was injected */ + if (vcpu->arch.nmi_injected) + vcpu->arch.nmi_injected = td_management_read8(to_tdx(vcpu), + TD_VCPU_PEND_NMI); +} + struct tdx_uret_msr { u32 msr; unsigned int slot; @@ -529,6 +537,8 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu) vcpu->arch.regs_avail &= ~VMX_REGS_LAZY_LOAD_SET; trace_kvm_exit(vcpu, KVM_ISA_VMX); + tdx_complete_interrupts(vcpu); + return EXIT_FASTPATH_NONE; } diff --git a/arch/x86/kvm/vmx/tdx.h b/arch/x86/kvm/vmx/tdx.h index 63916388fdcf..e97cb19a7a50 100644 --- a/arch/x86/kvm/vmx/tdx.h +++ b/arch/x86/kvm/vmx/tdx.h @@ -192,6 +192,8 @@ TDX_BUILD_TDVPS_ACCESSORS(16, VMCS, vmcs); TDX_BUILD_TDVPS_ACCESSORS(32, VMCS, vmcs); TDX_BUILD_TDVPS_ACCESSORS(64, VMCS, vmcs); +TDX_BUILD_TDVPS_ACCESSORS(8, MANAGEMENT, management); + static __always_inline u64 td_tdcs_exec_read64(struct kvm_tdx *kvm_tdx, u32 field) { struct tdx_module_output out; -- 2.25.1