Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2611871rdg; Mon, 16 Oct 2023 09:21:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCZk8r1JCMp6eJKhCb3SbJ8F9Tos4dnjG7TN++2rFtMYgh3FfJeCf3mkTcKcfhb7OoDc7I X-Received: by 2002:a05:6358:430b:b0:132:d333:4a5c with SMTP id r11-20020a056358430b00b00132d3334a5cmr38925774rwc.10.1697473278940; Mon, 16 Oct 2023 09:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697473278; cv=none; d=google.com; s=arc-20160816; b=lXyey/a3JKU28u0P9lVugDrbz3hl9gaMp0JwaFnjgDhYfCH7yZoTexkT/iQYMuOei3 4GQhkhtqR6gb6siHz4N40pjedWdneGA+vylSRZs8tF3hBfAm0llIz03i23OpAS+zF31A +CDpX59U0CEr0zeanFvfZZ4lWMYufhlhMMnuzOhHWArJgpDVgJ0sKEpEwDRqa/KXqq9B EOZSQ0A87pCHNLO1qwD9erwyPrEjwcvw84TBQStvaxrMOyFZyDdopVKK6Fjhzhf+Pwdf Kuzs7oDG3JlZRtaTbt2A+HszgvK1FuLWje2zPi1IdB8BgtOrAMsxnSB3GIRz1ZVuY+CS QEnA== 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=Ak2+2aHOaa6wuDJCf1dwUYElRvCYtesa5sTTw23Nfuw=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=HeUfqQxcnY7UshraXwTfHmBIGz7dNv1SkdfYiIYI1XC/Jy2YyajSGHAv0nw6qQPf+6 mdn3GBwQ8tfytVGz8pAhBgcYoJK4opbiMgM4cPUBmzpdBRzViC6F/jKHhbWkGZijn3qY F0ViK4+u4oaT/xFRWVrp5l1u5Mp8/QkU+/u5qlyGduuU0RyJot240RFcUbdbRg/1fibH dUTZt1y7RLsoa1fcBhYJwuoqNdcpxmWTFFzmGML9kS7B6WUmONb4//SqNA0dtt1foKX2 l3pUmnfQR50p/HnlNxiU1O80vv0jMRVF2h9v7iQthszVvnn2yhFCMB0dRuY7Ftgw9Tpz 4zHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bn3URaOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id d17-20020a056a00245100b00690ca3d66bbsi134933pfj.262.2023.10.16.09.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bn3URaOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 69FF88021586; Mon, 16 Oct 2023 09:21:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbjJPQUs (ORCPT + 99 others); Mon, 16 Oct 2023 12:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234084AbjJPQUV (ORCPT ); Mon, 16 Oct 2023 12:20:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146AB1FFF; Mon, 16 Oct 2023 09:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473079; x=1729009079; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mkxP9VJwWzUwqCSmFtoMrnor7KWi8C2c3YkXKtyRER0=; b=bn3URaOP8GDBMCE0tLmSZJnBpELnMxaBYLBQ4JsdkCJsEYg/Hfvtlb0L NLU1VinNlKd3ctW/BuDiHBTlFD0gptsFRsEjJ8MlC2QGtVu0fsaNwB9OT gH2oKrgwkXr6c4HLtVN5Cj9zWtJT9Fjoq4RWGAC4MiiErS1s43cc4aNia ZlCnoz876bHKJwbnF2jB1MUfGK7UX7E+DGYhXPKECqRoHgcDgMlqcJIzc TvT852t1H2A2LsTpEUnUv+44fMsXBvlrGWEyw4lpvJim+UUx3837Gl5HG TiYj+sQGhxuo57Rcaa+qcxtcEzfXFAd1IiT8ipupug1zLYDMGJmBuD16V A==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364921897" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364921897" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="846448211" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="846448211" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09: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 v16 069/116] KVM: TDX: complete interrupts after tdexit Date: Mon, 16 Oct 2023 09:14:21 -0700 Message-Id: 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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:21:16 -0700 (PDT) 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 b5493d6c7cdd..e29df39630e8 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -509,6 +509,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; @@ -637,6 +645,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 45f5c2744d78..c700792c08e2 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_args out; -- 2.25.1