Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp221159lqb; Thu, 14 Mar 2024 09:27:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTJeUFxMI2bZ/3B2EIUVibKwRjiUXr4crgoblBDa7g27z/0FBJcUjOMMbOdb+MIX3diyfrB+22OEnd6+OMi6Ji8G2iKunDgC5dWGTIRA== X-Google-Smtp-Source: AGHT+IGkS5xrRQpw4yJ2DaR8eUY87hnGaclYarYG5Ueh9PI5Dtyq4h1obHyZogMhHtRK3CgVRT/e X-Received: by 2002:a05:6820:1c9d:b0:5a1:b571:484f with SMTP id ct29-20020a0568201c9d00b005a1b571484fmr2880129oob.4.1710433646914; Thu, 14 Mar 2024 09:27:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710433646; cv=pass; d=google.com; s=arc-20160816; b=Fs38YGx+lmzMQy8Z6DH8aP0s85OmRafUIZCAFm3NQ+u4cGXOmDZie14UUwXwEGoz0f MoV3GKVwcKPjlWQJkt5CGtZHENv1AuGcAOKUj349pU80mwIlQtqcWTkSS1IsB1iD/vPk Wjl2h5iVl/dUd8RB8EnpeFXYJI2dARRzr1T0lBmRU9+s9K8JZMUZcLEMVgjdIvkZuC8s uXkH0vMDKpjHSDK9qnF1VdLsmGMD9BqDZA8me/Z78NR34rL5wjNz5RmLe11hiIkYXOjT fGgm2HZl+dnP5OkmlpKTbmO3bfoLYCbp+wNnU+CMDpgQB6ii/jXXhHkkwNmWfnRShEd9 VRkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8SDqTUcvl3Ckr/2o5jHXdpZ572EDUrGmWbWHBU2R81c=; fh=P/quV/w7uXmndbL78FtEpLTNkJRPx4LJS51PzREvtL8=; b=UpNLUuJVxIdYBg3YLnBeJetzEhO9F2iDlihcGXooyVt5eJ2EJeWYqWMMzFXctM18lF tWf4OhDVogsbk1qYFqWXmXhQ5/5/X8RYwitrFyEH3zUvcuNVv5vIZhm/VgTuw3W3Ul/j NDg2SmH1c1ZtHrC5aN1DMyrZpn6MSzDQQG8C3YqqBkJFMI4BTA3Uq0JlbyBndLl8R6XH kUCh+UGMEwjUwcBngf5gUALsQ5xG+CBVuoUYu9XlRDGgY5dxcyozgiMyqluzon1fd0gq gN4USBDiIt1QvGD0prngsLWsFrNEzGm3rWMigApTlCVCO2f418q9v++sBv7rmD8fJHGl mIIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dnHhI9cm; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103569-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103569-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r13-20020a0562140c4d00b0068cb7c10125si952427qvj.141.2024.03.14.09.27.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 09:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103569-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dnHhI9cm; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103569-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103569-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9E4C51C21271 for ; Thu, 14 Mar 2024 16:27:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8FAC7352E; Thu, 14 Mar 2024 16:27:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dnHhI9cm" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 5C99B73181; Thu, 14 Mar 2024 16:27:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710433636; cv=none; b=AFz5dRF28CoRuqFAGcoTb1oLwMut8O+XnHgL/zvp03DR04On0uLCJGTgbpMA2TMCZ5XbOuuiISNIJLb4o2RI1YTkLc4Dr6UZfC2ch5oZhU2Dkd+v/QDlMu0OW4i0iItKXhAmYY4NKBYgUc/8IqRnZnzaeuX9QBqTlfrSlQwm3L4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710433636; c=relaxed/simple; bh=YpfZ0LjRR83dRF+eHwxHgnO/MhB/Otx/i8hyxDgocTc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mndxgYoRa3Ltkcxv2iEMM7wFfCso0UoPyqWbkcK03nRj4PeElEU0Hmc4q2zfW8HHNrbuyHSyS33Qabvget2WyRY0N7D/szfPET4FC7g55S4gdpaGJ5J7U/QT9It65KL4JD+fvYrC3OofNkus77MwDQdu5K3IIpF6Qd6TbNMAUcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dnHhI9cm; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710433634; x=1741969634; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=YpfZ0LjRR83dRF+eHwxHgnO/MhB/Otx/i8hyxDgocTc=; b=dnHhI9cmigc2T/YHBVuWnwrqJxottsoBoNqdk/2S5U6wwulMRtibIl0n 3DBhabv+SE0nkcae4bcQiPMFspQUjt3fsf4ukN3opWvq1uVkoTKrudnOn JhNMbDMgwsOTU4pV4DcLe4V3XsatsAxxgc33R03giAxfWleS73MRxKHHx 5LnI6ZqFWGsSQvlJN0SoiEP7cswZeUz1oupCQSS88hDfJwweWYFtv2uBT NXB62Vac7uySGF2nL2AdSZJ79SVnf63JAvM0DTzpcfMco1FU8lPemgWDW hO+uEuG3nbN79NN6X1Drdgnrql86fsUoNceQM+tO5hhxt2/vZbZ3BiEp5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="27736526" X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="27736526" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 09:27:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="12418727" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 09:27:13 -0700 Date: Thu, 14 Mar 2024 09:27:12 -0700 From: Isaku Yamahata To: Binbin Wu Cc: isaku.yamahata@intel.com, 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, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 023/130] KVM: TDX: Initialize the TDX module when loading the KVM intel kernel module Message-ID: <20240314162712.GO935089@ls.amr.corp.intel.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Thu, Mar 14, 2024 at 10:05:35AM +0800, Binbin Wu wrote: > > diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c > > index 18cecf12c7c8..18aef6e23aab 100644 > > --- a/arch/x86/kvm/vmx/main.c > > +++ b/arch/x86/kvm/vmx/main.c > > @@ -6,6 +6,22 @@ > > #include "nested.h" > > #include "pmu.h" > > +static bool enable_tdx __ro_after_init; > > +module_param_named(tdx, enable_tdx, bool, 0444); > > + > > +static __init int vt_hardware_setup(void) > > +{ > > + int ret; > > + > > + ret = vmx_hardware_setup(); > > + if (ret) > > + return ret; > > + > > + enable_tdx = enable_tdx && !tdx_hardware_setup(&vt_x86_ops); > > + > > + return 0; > > +} > > + > > #define VMX_REQUIRED_APICV_INHIBITS \ > > (BIT(APICV_INHIBIT_REASON_DISABLE)| \ > > BIT(APICV_INHIBIT_REASON_ABSENT) | \ > > @@ -22,6 +38,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = { > > .hardware_unsetup = vmx_hardware_unsetup, > > + /* TDX cpu enablement is done by tdx_hardware_setup(). */ > > How about if there are some LPs that are offline. > In tdx_hardware_setup(), only online LPs are initialed for TDX, right? Correct. > Then when an offline LP becoming online, it doesn't have a chance to call > tdx_cpu_enable()? KVM registers kvm_online/offline_cpu() @ kvm_main.c as cpu hotplug callbacks. Eventually x86 kvm hardware_enable() is called on online/offline event. -- Isaku Yamahata