Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp270233rwb; Tue, 25 Jul 2023 15:47:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlFb7yEg8MNrMEki8DtX4Cy3w9j2pngsBQQ5aWRb1PpV0k/4qBrcqnPdJnnG4tndm3iPW2NG X-Received: by 2002:a05:6a00:248a:b0:682:57f0:7c00 with SMTP id c10-20020a056a00248a00b0068257f07c00mr650176pfv.3.1690325254304; Tue, 25 Jul 2023 15:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690325254; cv=none; d=google.com; s=arc-20160816; b=0rmXMFDR+RUvgXJXTlQoGW4rlJIQjMqeA5FxoUjZ1fjelwvzzQmRx3QPh8n8ZCSDU9 4e1ZV9i6uZp3gCDLlAcN8EFJfIq3NyM8zCfrMhUyiemlf4W38rszCDNQEbrur8CdC2jT reeUnykwaseWieA8PLdr5tMXoEw2UXLFil3XsoKSb1H0glUg7s0TlJP/F8KsmJoJNHl5 TrXbp6yOulHbi3m+ak6gyoedzZ9QopzjrOYGVDQ3bixHGFb+nXR9qdJ2ngs1dL1YrxAT PKCXLRFQZ7zhC1x7gMWYjIAY3G0OJ2AjSoBXRK9/KxZU95J7xe6TFgWpdOly4UFsB3Kl vROw== 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=TGWiRXU5DNtqMXhzD7nSJ9xsKsGwktE/aWOr4oT4r0Y=; fh=juxwNcA6iKwLISFgUCNwdoIYC0NKLUseq3xZdq25RR4=; b=PrNxzZy7x9GJsO290tkPNo3nbyGHnlvc5wcEakhNHDzDFWwmQWBNUZyO5Iw/E1h4SV 3NumxDg7Er/w31M7ohBdf3p3X4ne6NJ2B3D+vSV1LdOrAHcUxWm15V4TildMftJ0H2hn 9Bual3DPqpIr4YZyhKHnsbft8dg9i47m4DQ3BWsdk1Ud8YPSoxGPzr46wKi3NO/hUSPv 1aN0Rs6desZZFgpJ/FwF+5akpjTX4C1SaKaDpG5/n6yHndE9Upil2RrjUGlWg/xwY4PS PVVCJIV3Q2FV7PET/syVwBTOssbt8/j6h6l229ARYOzNuc4kWKYMrYHkiqwfud5COrWi baSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kYFVgjwU; 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 b26-20020a6567da000000b00563ddcdb306si704607pgs.384.2023.07.25.15.47.22; Tue, 25 Jul 2023 15:47:34 -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=kYFVgjwU; 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 S232362AbjGYWVB (ORCPT + 99 others); Tue, 25 Jul 2023 18:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbjGYWTw (ORCPT ); Tue, 25 Jul 2023 18:19:52 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21BD346B5; Tue, 25 Jul 2023 15:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323415; x=1721859415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fn1ZFUnwK0JunRRUkqWvyzNDXT79+TfdiTiGrjXZKRs=; b=kYFVgjwU4TRiljLUV6OzUv8fRiytBubKP9LUAgqsbA2tPaYqUPq9eZIl RaM8Iv50hS9cBKXz3/VXNj9bBLv0IbYVvawV9FoxfTYME+qUAzMtuYKUF fiD4pZrbl2Hg8eB/cxqqF8F3oGLb5vyB6S/fId0b7W4eV3Z8s6jWtfKG1 0eucRJ4H2QLJ161RjXvFI56hKF2107o6t2cJhOt5cQKVvFmb0kKe3abp4 +Y3NXwypVlPDePvud3Y3U9UMLz3QYu3hOmsi2ih2YGlYivxgTGRWWo7/f AoxZ+NQ4HHuvg2vEy53sul5ZAHhxMCXLkeU+9PXwDr4qyC3CQzRv6VUm+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="367882574" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="367882574" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="840001811" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="840001811" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:53 -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 , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v15 070/115] KVM: TDX: complete interrupts after tdexit Date: Tue, 25 Jul 2023 15:14:21 -0700 Message-Id: <0cd95cb8151b8db3c4fb2ce66144beee1c816169.1690322424.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.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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 1ae72c84d40e..6e08d4ec132e 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -484,6 +484,14 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) */ } +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; @@ -561,6 +569,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 98c8d07723a1..2970536e014a 100644 --- a/arch/x86/kvm/vmx/tdx.h +++ b/arch/x86/kvm/vmx/tdx.h @@ -200,6 +200,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