From nobody Mon Jun 8 06:36:39 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4319B48165A; Fri, 5 Jun 2026 21:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780694739; cv=none; b=ExTJBh9jQKx5S/FwPn/nMZr6tGres4lm6H4Lt9wi9NBT8Sunn+lo+lrPdfrZfhX9eHOH6HuiyAH1pCoASSjwF9jWnd5TYMN7cy2TpKnjgLypzzsZkymCAKz+HYUiDsWquZuM6vghwb8VyMiDuZ42n4ZelvK0C9zaD2ek+9PcA2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780694739; c=relaxed/simple; bh=BJAOWldscDtYuk66ue2t8MgjGgD2GlmIsrjcvjjDJqI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=ns7mZ9rlrWfuVBiQeEa4VYD9QTAU5UUb8GFDDu6aQGRQlp4bJLMtH15mafG9jx1blwrVGYPlRxHmZcm4asjXovHGCDw2+rdLWp8ytQZuOk8cy1cLHDS3ggML8LUAwPKLsw03jJbjrAlSKgnqwrg2bBJtjjcEHxfw/jXQpuCW2CA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zpuN+YXM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=I2oc9Cg4; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zpuN+YXM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="I2oc9Cg4" Date: Fri, 05 Jun 2026 21:25:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780694736; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mEaFBJ4dq8jxbtgEwtUq5RDnw3T2kzv/e0UQW6Yp43w=; b=zpuN+YXMW1/RkKfUeo4GG3OCFWXWeJ6HUxWDsRNBdreQtj5Q5EgB7Fgi5Ga2RWl3MKc8dh E1x7MIPsmWy7dwdhK/dBCVCnltOwsJ3TDWTS1Bf1QtaSClFRTScVkUGpUzukj92dGMSYu9 XVhLKu7/559EpNE39cGR0uL5vX3SyUYKnMD+uWBavrZJLUFgnF73EEvsecKF7qxMdxRgWO rDeU04lGmrs0MBTrnJkz5HHVJgpuK0mAG47Yy5lrd/p4IOF943RsrJvhrnaZm63UGE/sqP ASuk6zzrAyw4Jo9U3o9g2l3xNmMwUmTyq4NubA1DJy5FkBb8leiDLdL889K7dQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780694736; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mEaFBJ4dq8jxbtgEwtUq5RDnw3T2kzv/e0UQW6Yp43w=; b=I2oc9Cg4x/PTokrnPm3pvRpEOMMCpLYs8Nm3FIC+omrp92nV6nl2WOKXSC0XT8+H5TUqGf IIhb2bW9QOnUBUBg== From: "tip-bot2 for Chao Gao" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/tdx] x86/virt/tdx: Move TDX global initialization states to file scope Cc: Chao Gao , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260520133909.409394-3-chao.gao@intel.com> References: <20260520133909.409394-3-chao.gao@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178069473524.710.14711209469035566331.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/tdx branch of tip: Commit-ID: 9c0c68708dc48e8ae4f9043c96b387a0173361f1 Gitweb: https://git.kernel.org/tip/9c0c68708dc48e8ae4f9043c96b387a01= 73361f1 Author: Chao Gao AuthorDate: Wed, 20 May 2026 15:28:47 -07:00 Committer: Dave Hansen CommitterDate: Wed, 03 Jun 2026 08:14:50 -07:00 x86/virt/tdx: Move TDX global initialization states to file scope TDX module global initialization is executed only once. The first call caches both the result and the "done" state, and later callers reuse the saved result. A lock protects that cached states. Those states and the lock are currently kept as function-local statics because they are used only by try_init_module_global(). TDX module updates need to reset the cached states so TDX global initialization can be run again after an update. That will add another access site in the same file. Move the cached states to file scope so it is accessible outside try_init_module_global(), and move the lock along with the states it protects. No functional change intended. Signed-off-by: Chao Gao Signed-off-by: Dave Hansen Link: https://patch.msgid.link/20260520133909.409394-3-chao.gao@intel.com --- arch/x86/virt/vmx/tdx/tdx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index ad56f14..40444a3 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -105,6 +105,10 @@ static __always_inline int sc_retry_prerr(sc_func_t fu= nc, #define seamcall_prerr_ret(__fn, __args) \ sc_retry_prerr(__seamcall_ret, seamcall_err_ret, (__fn), (__args)) =20 +static DEFINE_RAW_SPINLOCK(sysinit_lock); +static bool sysinit_done; +static int sysinit_ret; + /* * Do the module global initialization once and return its result. * It can be done on any cpu, and from task or IRQ context. @@ -112,9 +116,6 @@ static __always_inline int sc_retry_prerr(sc_func_t fun= c, static int try_init_module_global(void) { struct tdx_module_args args =3D {}; - static DEFINE_RAW_SPINLOCK(sysinit_lock); - static bool sysinit_done; - static int sysinit_ret; int ret; =20 raw_spin_lock(&sysinit_lock);