Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3397353iog; Mon, 27 Jun 2022 15:26:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v4pBXyKgWP0dtDP5cdnuobqB/f5EpYJb3ZM/Ww4q7ejktJZ7TsDR0KTyEwFAX7yCyoF9/J X-Received: by 2002:a05:6402:5408:b0:435:60fa:5017 with SMTP id ev8-20020a056402540800b0043560fa5017mr19445774edb.223.1656368794186; Mon, 27 Jun 2022 15:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656368794; cv=none; d=google.com; s=arc-20160816; b=B/ZJCQRwAzYS0HSqt+0L7N4mA0YuCyYvU3lH8dGX3wp57WZf7ch5J8pEtPxKDGHai4 WszPlqedfl3QSEVzg82Y65owJIdJaJT4MJRCe0ISbc1cAcLF66IRZ0xYIotVf7Y+2lrj pBAoTdupas4qJZKorecQQt3kdNevi8/z8YaaAe0dyFaLsWZqTkHjEyJhRrTuheukrt5J zqjXKegBY1vJ+Y8yTGsJ6JADLuOQEzBjY1jp0a84mjSS1vmVPEnr+Rv56CUqapDmOH/4 d0yjce+Ii/vcqW2S/0+wf/gfxsiheWkdqWlmBPGwUM4sYazhjSPZpREVZ30pLZAgxYDt QZBw== 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=hBhXKVwh4pYymHa+HMtOEL4ce9IfBlQYcjRDUF2meo0=; b=x0S2DYplmBGRJP73tmqsFM8E6JNkU+08LQptPQZg4I1awKeHtMZdIcLExcrOMFLEM3 P6YBINEvfYCXD4odHqsxSf/+v+NMRMoC/ltB2K3k6g0OOJpYzIUIMT11EkCjojMRGQLx QcFFa2DlboRSKmVMD6dFlCCeOODEAnQjrMdQ9CKh+xk7qf/jG2Y/RgVGtkQlJpLrlccJ V+x4MAaFAs/J3UQN/n+mmxDcL3OyTkDfMTWpdtRBPuGbvncoCPc9OhiLi3e2ClsHOPNh 0h8Voy3YwnNgyED9tl430Xaxn8rRACwkFz2HIwt+NQFc3bhSbmK0ZL0F7Q7PLdbZEJ7A ra8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PB5SXCfp; 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 dn21-20020a17090794d500b00726b8a9f9ddsi1000738ejc.527.2022.06.27.15.26.08; Mon, 27 Jun 2022 15:26: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=PB5SXCfp; 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 S241868AbiF0V7v (ORCPT + 99 others); Mon, 27 Jun 2022 17:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241517AbiF0Vzb (ORCPT ); Mon, 27 Jun 2022 17:55:31 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D634CBE15; Mon, 27 Jun 2022 14:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656366901; x=1687902901; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZWye9xQ20TriTrBfAdBneMOChyCwBotAHsNoYsjFIQM=; b=PB5SXCfpWPJ9lWhHjiH/sgFe0CwL6IUANjfCtCyaZ8iNwO/Qtbpk6kJv /8WQAMcvN3jaSDwGIK2gkiR2+YnCe21IR9FTo/KCc4jsNxY4F3I5ST5Pl A9hvDfQnVRD8itLndgh7jYxL3hL4r33prYzURyMW/OsDYoHYWs5mYyMt6 lYuNO8WnU7mQhuoFWyUlOR6mksWJxjtiwrdwUCHca162/C5B4M3bJfivp 7dIrEuHQEaGFO73uhylZwVp4343PW7za1geKDcNLdcG7C3VzqWEVuRJul Ki1MVv5Nq+xxHye1M1DkxeCZT5kct5a0lz/a4S8v2J8UrYDpOoIvDhgK3 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="279116112" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="279116112" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:54:58 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="657863663" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:54:58 -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 Subject: [PATCH v7 070/102] KVM: TDX: complete interrupts after tdexit Date: Mon, 27 Jun 2022 14:54:02 -0700 Message-Id: <035b6173982e59544fa2b3f3f9967c1d0aeada91.1656366338.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, 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 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 3d9898b677bc..c9cb9670f7cf 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -593,6 +593,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; @@ -661,6 +669,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