From nobody Sun May 24 19:33:55 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 81A9537204D; Fri, 22 May 2026 17:26:36 +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=1779470798; cv=none; b=nSbUaV4/yGLUiuAsWbolB4ffci0o6WKQBngFKGU9DZiEigIpQAz60RN+ls0eFsIPF02W7q1Saxst8aJJj9GGX44KCTEEgygcfk4PtKmgKGws5QkIceAF1u0TAVUwhp8B7l04TisDO62fvVxu72KCjJjyxeYhwtySAcslhVyG7MA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470798; c=relaxed/simple; bh=2sdb9Cvcp37PKRCrwNqaIbXvkrqAmWdk7pcu+kSWGmA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=L7nR4xxYaQcSxm3pIgb0qsrc45l1VfruhFQ+TKMEooiFFVz/qHtJ6qbsI9Qd7hXjGa4XsQkNe1n8WL2KkPQteZ/QtLqLPtecmZ2iVwa6kRdmVu/1g/WP/Nrg7dUuc727O/CXv0DGgMFMJzt/LXfidfa6vw1rw+6hjyh3I9VX75U= 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=Q5dKmrEq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OJ8tAaaq; 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="Q5dKmrEq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OJ8tAaaq" Date: Fri, 22 May 2026 17:26:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779470795; 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=6tUGjtlcjSyV0GRNYnWIfEv0LPYS8ZNswzNUQHExj9Y=; b=Q5dKmrEqqZHcc/pIPbxvWHQh1TSzBA5iOu2ngETlxMqa/XuGIzn7Jn8l6lT6dtr5btAzcR +JIR0N+MlZXjHQGNybywGzt9YfeFOKJ3DNB4LNsVH2njm7upgEDKsXxWBElSLMYKT7216p pgJktQCWo6hBJX+w2YTWKY6zw5RBY/8A93BENm3+ADqieOhmEr7RA0vGHsW9mmKYh6fzYJ TO6rt+JZ2v+zzshdHx359UJOhGxOYCgtvmq8nfXx8fm18cN0f9mvsDBlL7A4K/uB4eRIIV 4o0To+930XpPicw8LxHVWEe+ilKrJUIyQnImRmMpWN0BexM49gOec/wqfqTNVA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779470795; 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=6tUGjtlcjSyV0GRNYnWIfEv0LPYS8ZNswzNUQHExj9Y=; b=OJ8tAaaqeQIEcRCzbKishR1ZLax2JMVVKh+G4azoyDI5zagSFGQztpYlfSNfZFeBqjCVzm HqgPa3DecXx3HQAw== 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: <20260520222847.BED50ACD@davehans-spike.ostc.intel.com> References: <20260520222847.BED50ACD@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177947079385.711.12923934620412895985.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: 2f410fa074fb12167b9788263b4862a5ffc5a6d7 Gitweb: https://git.kernel.org/tip/2f410fa074fb12167b9788263b4862a5f= fc5a6d7 Author: Chao Gao AuthorDate: Wed, 20 May 2026 15:28:47 -07:00 Committer: Dave Hansen CommitterDate: Wed, 20 May 2026 15:37:08 -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 Link: https://patch.msgid.link/20260520222847.BED50ACD@davehans-spike.ostc.= 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);