Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2260768pxm; Fri, 4 Mar 2022 12:33:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGzoPc2isumnUYJCG5iYBgpV3nhLgTT6eWvVm0m4tMNv4JZPQnCdpZHoMDHB1JLmEcK6du X-Received: by 2002:a17:902:7c13:b0:151:a784:34c7 with SMTP id x19-20020a1709027c1300b00151a78434c7mr352661pll.174.1646426002378; Fri, 04 Mar 2022 12:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646426002; cv=none; d=google.com; s=arc-20160816; b=lqoSQ/0qeNlu2MM8lAZlS+Kn4cobXmKhCd/2I2aKg9KF2YRMboBAINMbQiQTsYGyhB zb27woY3zZbKa/UcrGvmMjT1rDTLYuGG9lYhQ3PnRgIzv58N6Do0wMP7n8mHD7Oqm3OI K9VyynKMC67M0KJ6+98n3s5mkU7exX5MN+8VYrKiHeTxeGzbp8cRZPwgSbBO9X+yoSJh 4quoLRNbs61TRsewo/OFW2ol/3bDUrazhijGAU/5yuT+IyfhBmYr+WleN6eni8WTkwkC ciauTww0yVYe6JZXLwPKE7MNvoKnLMmLTG/uu8b+n2BOvffGVlY+085YwkmzhHp3oCRc MKAw== 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=+RDWzl6+k9+oluAkwmaH4ajWjZ8caIBejFfc8FuCHL8=; b=S4zTCzERmno/KxiQp9Z1NYn7YylnWZQguX1jfLSqEWq+oN5/rEV0bpfqeve6Y/Yeql 1VIOMciXICq71CJIVSZvUsl29BCAaIwHBDeJfntzBlrd6l8jEHJkK4OEhlzRjYMzoT/q dfSEwgahSet5Ip70/dMoEmtyBsPAlHrVTRkiQluvV00M9qWStRImCJWu5se9wgHeoi+H B7wh2c4oSxIGsi8RTKPP9pIXx1umrDCuB1KNGkDbtGB/VioIfejjYu7haNS6Ge4pkbB5 971ty4cBUvLZUBhhmksrGf+/n+OjW2laMMDgt0B5UxM03oFzDl1YkE0SVqcXzua/lLmH d/gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TEiN4RMM; 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 f7-20020a631f07000000b003742311bf67si5446239pgf.770.2022.03.04.12.33.06; Fri, 04 Mar 2022 12:33:22 -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=TEiN4RMM; 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 S230434AbiCDUct (ORCPT + 99 others); Fri, 4 Mar 2022 15:32:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbiCDUcV (ORCPT ); Fri, 4 Mar 2022 15:32:21 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE1571E6EA9; Fri, 4 Mar 2022 12:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646425891; x=1677961891; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZjxKYa04oRaSCWshHf18f3TOhG+oryrLgSOPKMBRnso=; b=TEiN4RMMd/VsbA6WTsYbexi6IrKL03LTQoODAuqiqBDZbkXUEymmX0kq BQujUAx5p3rVCuEfXg2c8NX1o8crnSTwgwsHFDcbvLzg2u6N9qrIWaBq9 cQzwFHy+CsxDRa9NCMJEtZeVOtfM/5cAOfgcs2vEtKwVM3CbrIpdZRfbf auCx7I4ZU2msOzhcmlQZOfZBhZj8BrirqZGAd4nysjFCvAMBbJhmQYFSv eKhUnRCeZb50ab6lv3W4oOuo5UuIbv2HQCdDiAHyhcM2EZ2angZ4FlKi+ wb4MuORuP+4S3yXrg8i2HHSWF3wMAL1DohGqLT3kDznY+SLPGIhT0jK9T A==; X-IronPort-AV: E=McAfee;i="6200,9189,10276"; a="251624269" X-IronPort-AV: E=Sophos;i="5.90,156,1643702400"; d="scan'208";a="251624269" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 11:50:34 -0800 X-IronPort-AV: E=Sophos;i="5.90,156,1643702400"; d="scan'208";a="552344473" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 11:50:34 -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 , Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Subject: [RFC PATCH v5 070/104] KVM: TDX: complete interrupts after tdexit Date: Fri, 4 Mar 2022 11:49:26 -0800 Message-Id: <45507ecee0a0d23229e9e7f8bb74077034a40bcd.1646422845.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=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H2,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 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 --- 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 c1366aac7d96..3cb2fbd1c12c 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -550,6 +550,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; @@ -618,6 +626,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); + if (tdx->exit_reason.error || tdx->exit_reason.non_recoverable) return EXIT_FASTPATH_NONE; return EXIT_FASTPATH_NONE; -- 2.25.1