Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp416086rdb; Thu, 22 Feb 2024 07:40:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU/FWvbXrhsfMjg3/N1dYtWOCQPV5z/WQaJ1YZZI1kFdYwpHqx+htn2M4M4MizpvubzJvlPo03PwnGxZugev6whL/LM76APKS07F5Gckg== X-Google-Smtp-Source: AGHT+IHixZias3Azx0M2eKFsK/rk7rdU+Bx9+8mLlHlg9r0CWL8iEKy6A0ikNj6TX2X6HLpQWwnG X-Received: by 2002:a17:902:a385:b0:1db:9e2a:7e24 with SMTP id x5-20020a170902a38500b001db9e2a7e24mr18247351pla.15.1708616424928; Thu, 22 Feb 2024 07:40:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708616424; cv=pass; d=google.com; s=arc-20160816; b=rwhJ5clfCFcOh0V9T5EcvwQWqQeAcHsDWZgLmbfYa/cI9M/WM8OfGf8KATLog6F+YT 9NZVP14IwvAd+kBt6BkF5zxl7j/CQvUZ7zbIiCLtct6EuQZ1Bg1/pXRorObOqBToq02I +NyC7NAi+mCHtWWFCiAPf9DFhO6sVjlSBnM+TfANmcAZZ1ZsGiotRgTB1BL6TC377wVp TIgGNVvwOFtdYHfMfBpi16j8eRjq6HOUeuBsKEQfMuBMyQyRTZ/+0mxco/ieRTdCzRiT PjMd1Drtim3be56QRj7Fj8tvmtK0IXuGT7zVrFAixENdqdvc4Fto46XOvd6ujcpCTe4e VUrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=VibanHsWurbjJQYG4lXLF7viHAr4t2VDSgMch2ofZlI=; fh=8scsGQn+hJ1HvbMI23kGOdGh/wtWpH4wdCi8Q1zCFc4=; b=fthVrByZrQfgIh7EMwrMpd97Cx+pKT+NOkiUa1z8fp416xAvnO418Fwy5BFK3AgBmi QgF2u9nZdIUKYoS3QIMhF4cr/fQSNw3tvlIyDwqnwCoilQUW82mdt1FctYPmLQRBdf+L wxQfVz07bbyU9JRovtDcISrBnpPsn1PWNmmg6P80DESQrugsjEwyw9BIicsm8mx7In+i SxAU1tjhD3BR+8uGv6pJ3hpa3TBskS1LtMibatLpKPFOf4t4F5FmZaaANkHSzvmG/SKO y36+MwAip1xDKH3V7SyS9bfhK/BnEjx7GRh6/91T4oDgiggjSiw+TLsQQHSLsbVq+/tS 8lPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Of0qbvK6; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b6-20020a170902650600b001dc0039037csi6878176plk.281.2024.02.22.07.40.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:40:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Of0qbvK6; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-76713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7116CB23800 for ; Thu, 22 Feb 2024 14:37:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 989731482E9; Thu, 22 Feb 2024 14:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Of0qbvK6" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06BC636B15; Thu, 22 Feb 2024 14:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708612647; cv=none; b=ej++9jh0zxX9ceRVJpV5yFbnGP+/1lX5HvSRTMmrReFbM6UYDwgmEHO2/7+IqBDyZayPdGXoLHnZu/8BC9DbowQGd+hMATYonf57M+BroRyTF17EfJHEU52n9uNXp1dNbRT3dQz5aB+S11dW9rt65lL0NzRqEbBMX/IFomiFavo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708612647; c=relaxed/simple; bh=nA+GwPV8So810YxlOsuziJpf9lYOI6OtcvWyEM/PeAI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dwl84NuN6+a3w6GZejHcII+GsAoU9oOdvgMBKDs7jT9DGvJohcn4zsPQ+TzpSG82kkA94ogOneg3AvrVrRP+Z8BNIgF6c8PJ+9dV38ZlwPWB2f/qnl7yHC2HNYFZfjNwFp+lQQ32C9SowifGd0abIZHDEF+fwrCHO3rK/DAq/Zk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Of0qbvK6; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708612647; x=1740148647; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=nA+GwPV8So810YxlOsuziJpf9lYOI6OtcvWyEM/PeAI=; b=Of0qbvK6jpIl1T63Paf5joZ8kWBW4UsFOERUsSYZUJaQl6z12GbD9AYQ sRg3IgbHzlFzGiyFjrlP70f+N9A3DF6wh34Rl9QLWfz6NX+IQrQSdHd/k OpKyj6aWOeS/DRIBKbT6hRmRWqfy8v/sCRYIOJOadktvXn0plnfVcOv4e nNqbTKkrlUE4u/enBAIJWP+epjmydDfUAIbc9eOqRumk7DCk3+riMpWxs 1xNDWUNhCzUiS/PJO2L8uTQ0yaChryk/PeDXtTLeAwJP+zyEGbeLVcTFw VaNRAY3VjMsYL25cudYJbaIsjs+ASFlJTbDtDqOu0x2A2xmFnxbFiazx6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="2961658" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="2961658" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 06:37:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="5411770" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.93.18.46]) ([10.93.18.46]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 06:37:22 -0800 Message-ID: Date: Thu, 22 Feb 2024 22:37:19 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v18 074/121] KVM: TDX: complete interrupts after tdexit To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com References: <379b4d2e8995f0f8b5e6635010b4fd12f4c2571f.1705965635.git.isaku.yamahata@intel.com> From: Binbin Wu In-Reply-To: <379b4d2e8995f0f8b5e6635010b4fd12f4c2571f.1705965635.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/23/2024 7:53 AM, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > This corresponds to VMX __vmx_complete_interrupts(). Because TDX > virtualize vAPIC, KVM only needs to care NMI injection. Nit: complete -> Complete in shortlog. Reviewed-by: Binbin Wu > > 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 71c6fc10e8c4..3b2ba9f974be 100644 > --- a/arch/x86/kvm/vmx/tdx.c > +++ b/arch/x86/kvm/vmx/tdx.c > @@ -585,6 +585,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; > @@ -713,6 +721,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 883eb05d207f..9082a2604ec6 100644 > --- a/arch/x86/kvm/vmx/tdx.h > +++ b/arch/x86/kvm/vmx/tdx.h > @@ -201,6 +201,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;