Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2578555iob; Fri, 6 May 2022 06:10:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoqs+hRkyH0Gv57rpp/YxaVg1eyDxlUb0u/UXBWTxsKt4H2YU4Trx2wARyImxA+KVg+rCW X-Received: by 2002:a17:907:948c:b0:6f5:183f:eb6 with SMTP id dm12-20020a170907948c00b006f5183f0eb6mr2651011ejc.112.1651842607730; Fri, 06 May 2022 06:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651842607; cv=none; d=google.com; s=arc-20160816; b=d1ZbrQrGnpZanrbcC2yy76lF3s46U8DlFJU97VcI8DLXdbhjOkZdYXp8xfuqAhkZ1M TzE0YHgjzJ44LJnTiWp/GUZawD4sa1bVtat5xXvi8CeGRsWD+I8WIyx4bisK0oZs0RNe DoeOUAZVBr6U1Uu4dbjsxMPH4jamCmhQNQ4MlBC2+m6b1JbZyvQtVZ5NNAbfxp5N+u1I WWQaN70PgNmRF6g1u6PJwE4XlwpxeTYKPV/TFOwHpfuK4jo3b+7y+JFzbCzblFW6qf5a eBuszawIHTQEkD9s0r9nA/wO0eE93dAXEhYGEMimPhG+zACaOUMCkcNew9nxy+B4f4uV LXmA== 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=YosdBWPvLtUw7lJOrGpzBhl0lcno0PT8ZlDjuRH7ulE=; b=b47uAwf4BMQyfU1Nhjfd+gPqpuu3LPhD2c1/8/mF6SR7KFaexEQh1+K5xTHIqxdXBd 4cRtLPkVvRWWmY1wliCMLv4nOu6nrKJ/OthERrObg3CMQ1wjSGlbshgqKEk+9kTCGVWf T8nh2RxBWCcSaXtzxfaaSF4o/T69HZ061iwwOfkinQo3efMZUahzNXHRk0hF4vRsEDlR VLj4Y3QB2TCGmNlCv9Dt/LGIUSWYVe+CHqgW/GB08jUrr5d0b4lNynse/85NbBKBdWMB Fd5Ubgy2dol3tzdUKF8EHctk7aWSPJUq8vGXjSBwrLLBE0EczvJP+99xHst4LAKDMBEa DpyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iz4Gx0P9; 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 sb37-20020a1709076da500b006f3e77d98b6si5432017ejc.174.2022.05.06.06.09.40; Fri, 06 May 2022 06:10:07 -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=iz4Gx0P9; 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 S1383698AbiEESWt (ORCPT + 99 others); Thu, 5 May 2022 14:22:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383174AbiEESTl (ORCPT ); Thu, 5 May 2022 14:19:41 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 606ED1AF04; Thu, 5 May 2022 11:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651774551; x=1683310551; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zi32JicQj96LCv9Y/HZhsTD683f+9s81qGHuSBeE4Tg=; b=iz4Gx0P9iSU4+DJzOsrTZkfdntoh9Qs7ER6afel6iu5tayq1fAKvojZ5 FwibsN1p674K1WxgLHOpmphdKgeDxE6L/SAZWbHWAQD3cRAGUTuh9/UfS c5BzvwqSonNzDJ4VCNJFDsoFRvBKyRjvxgxlhTMXN+FpqLj0J1j2moXvn t6yMpNF8P/rucfUzy6aJGmf3iQwzuLARCFCIwnIBItLgKBu5LytzpigGd ctAqoSMLS1AE2kDAmoktIQ0G1B9xDIiPRoD+7o+D9ut5KKv/316WRutpi CcxZDjH4OeEksQq8HgLvi6B5/vxY64CD05Mp5PXPIsJgh0h3nHmjJs6mJ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="248113899" X-IronPort-AV: E=Sophos;i="5.91,202,1647327600"; d="scan'208";a="248113899" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 11:15:51 -0700 X-IronPort-AV: E=Sophos;i="5.91,202,1647327600"; d="scan'208";a="665083396" 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; 05 May 2022 11:15:51 -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: [RFC PATCH v6 071/104] KVM: TDX: complete interrupts after tdexit Date: Thu, 5 May 2022 11:15:05 -0700 Message-Id: <3dc5e620557dc7d44b8ad3e0da9ff0bf5fefc1a8.1651774250.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=-5.0 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_PASS,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 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 80fe76214b3d..7af7c84f8891 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -591,6 +591,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; @@ -659,6 +667,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