Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3487254rwb; Fri, 30 Sep 2022 04:27:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4BhqIYpMFOOJwwznZ4pGQoYVoHFeiRXNcmdN2fNL7IEmcdWiB3QqQOyzsxiRDlavdNG5PM X-Received: by 2002:a17:907:80a:b0:783:2585:5d73 with SMTP id wv10-20020a170907080a00b0078325855d73mr6155381ejb.642.1664537248958; Fri, 30 Sep 2022 04:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664537248; cv=none; d=google.com; s=arc-20160816; b=EUKRTmvci8Au/4H4K3KK7xd34B/smGBF5JpGe3191LB69mUNOrxfqntd7+b16hphHM mS/8g5WE4KlfdyhfqHtjcSrAbKaoedQ6Rqg8AoltFi/Qqf4xVuT2kHMgQBhSe53I8jPi RFBPqteqncut/V3iqCuKybyTFaBx49Zhnru7MQ4xIe/A/6uocSwgMwPEDfLpt7ReyrFd 1Y42NQISFXzPfFillpt4ueKNecsVm17gMn94UsBfyjv/cepA4cT/6YwDwArt9E7JJWg+ O1kuUAJJn1wVqFAhqeqdq7iST/UUHhxQzBngNcQGorFqlyI8eJek+bN8ixw/WlVVL6mv goKQ== 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=yUW0/UJYZQu9jHIOjRUrwTmR3ppaPU6iI+Vt6a3TCdQ=; b=HtOp/4owrbK6Tos2YdEVDQ0Tr0sNR0SU14EusBm0fOCWTIWm1M2qz9cqFQQ6KPtWjf L25oReqVgwVRROCl0ouUer3rKkZBgwlJdojhyEySwOZ767JKQtVSoWs93Abe7yDGWzm9 ypX/WwJcNzbaJ4yO+0kIb42Rae/xTok/Cf0qaCzi3vpGogOSuOeUyZT4C0ek6XYMqQJi Ko/hzWBiNapNOL/w+Ws1Z3RjITWx/sBIzySCSC0wAdWpjOpF+aiAdZwPh5L6NthnLi0q 88/dzGr9Og4JOHRdCyO6SNxr26cTSrXIDZDDsvfdyFAQYGTSEOMQvXGl/wy/UqzxXTEh Fuvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mn6TAA9V; 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 p9-20020a17090628c900b00767e24156dbsi1236226ejd.256.2022.09.30.04.27.02; Fri, 30 Sep 2022 04:27:28 -0700 (PDT) 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=Mn6TAA9V; 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 S232257AbiI3KWv (ORCPT + 99 others); Fri, 30 Sep 2022 06:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbiI3KTG (ORCPT ); Fri, 30 Sep 2022 06:19:06 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3D115ED22; Fri, 30 Sep 2022 03:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664533144; x=1696069144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sYjSgzyHZOauPeGBFjFdTepSx4d5F989a1T77Uo0A2o=; b=Mn6TAA9VC5Ynia/ez3OAQlJAKo2c1MCBJPDRJSjw9owFAovkXl0T7Als rOJR7KR65QbgkYA/hoReEmYqtONChteAwd4x3Rqkl79tfgNKM1/PMyUFZ qmdOURZ1SNvyM8Joonh5tCcbju1XYdGmC8GuS1zNNM5lFXy5GTRhJ1A3I 64GPQ1ocpMz3AVxohw5CcWShhFw+kGxy7N6ZwYj3823rqZ/nNM4XQ3j9M WKWxw+hyxsd3QuSbHHwbNtQPagrW68w/dkpe6h1llTZkbjGV0ZmwnSWQy mSnRaSVH679M1BYM/0FnL/Kerpv1AVbb4Zsc2vPqnojpCU0aagWOmwdka w==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="289320474" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="289320474" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:19:03 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="726807734" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="726807734" 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; 30 Sep 2022 03:19:03 -0700 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 Subject: [PATCH v9 071/105] KVM: TDX: complete interrupts after tdexit Date: Fri, 30 Sep 2022 03:18:05 -0700 Message-Id: <99f9671e2dca2e8272c5d624b83a1571970b0b41.1664530908.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 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index b6fdfc5135e6..44c8bdb5b1d0 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -448,6 +448,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; @@ -516,6 +524,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; } -- 2.25.1