Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1AAEC7EE2D for ; Mon, 27 Feb 2023 08:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231633AbjB0I2o (ORCPT ); Mon, 27 Feb 2023 03:28:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbjB0I2J (ORCPT ); Mon, 27 Feb 2023 03:28:09 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE54B1EBE5; Mon, 27 Feb 2023 00:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677486317; x=1709022317; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DlwMNkw053J3WJvncMnbVtQODdBLGKqN9ksDYBpJ4yk=; b=eewTGA5h4KFHZccmed4Izr0ds0GzqG3ux/6yvQkZzB+3X0QM35XT7wj0 IxOGzrbj4zVKCMu+KIdCvf1kZn9U4NY+ilx9ZQU2YaqQilk8zcMJT6plp 99sDgzsvN2IPQmshaQprXDaROzouHRQQBLp75DeoHxgQPy01OHibVklYg RsyB39BKd9jhXBOVhK70SPWSZPUNiOV6gtWYccWvNxcz/8deq6NcYAHKN zE/9cadVjFziWk5QrNdPJxQz81pgKfvhiBsRJqv0XinMOdP1zMg/sQR5a FQ8s1Cb+kPDekFBjstmknViVY2As5nKgA/B5Wkm9N1UeQLruP0R8GBUU5 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="317608945" X-IronPort-AV: E=Sophos;i="5.97,331,1669104000"; d="scan'208";a="317608945" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2023 00:24:14 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10633"; a="783242295" X-IronPort-AV: E=Sophos;i="5.97,331,1669104000"; d="scan'208";a="783242295" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2023 00:24:13 -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 , Kai Huang , Zhi Wang Subject: [PATCH v12 063/106] KVM: TDX: complete interrupts after tdexit Date: Mon, 27 Feb 2023 00:23:02 -0800 Message-Id: <583bb97acb8a2d6da4ae4b2b8270fc7831aa4810.1677484918.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 de8d2d4b03aa..0e07fd13ec66 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -506,6 +506,14 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) return; } +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; @@ -574,6 +582,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 cd50d366b7ee..e66e5762ae04 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