From nobody Sun May 24 19:34:22 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 2CF3F367F4A; Fri, 22 May 2026 17:26:17 +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=1779470780; cv=none; b=exi9TDeYjMSvUXlNFlPpmPsLngv71ItTDZcCY6VEqSbGSPFv1yBMJIu7Dis4QOCetBLL0qKxj8OzfgTh164LKo+kv6woT8AXjyYE2YQ0iz6a+7v4WgZhpJx2QE9+hREdkBCKCFmuUcAjAFMxEKnNS9o5lFZm74ghaxgLj6Oou5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470780; c=relaxed/simple; bh=e+q++DGkLmAhJZR4A0T+uWieRQ5qv9b+TZelyWId7C0=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=UAj0Ox48pu/4pE0dCtU5xTQNSKqkS13nSdsNAr3dCinUNbaXzXZoQHRf3tzUNHu7jEG0SchUPH2AN87ZEVNYYQPrNlgapezmlxK+rVdRuMLPXaugoOKWx4y1FDZD49TjwmKiIL3uirhWcO8U+fZBGEdjOvvZpdB4VxPcghbqywg= 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=QtWXI86a; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nhnJO4LY; 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="QtWXI86a"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nhnJO4LY" Date: Fri, 22 May 2026 17:26:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779470776; 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=viOUNQSErtt20QX3W26O6rN9Wn+blwwp9Ezhc1doXY8=; b=QtWXI86azbO0pvhF6ulyFmVFUbflnRMvFkMUHGlqra+PDv0w2ZxqVFfTj7h62cw4mgpV3Y XuSmNUegpaOPDZ/BeJ4GA3iHMCXAQSip2zzGYr6JFRAwGogS0emQbc4nYIY3Z7/SvL+pA2 zs9Ucdg/DCfzx4kyUGNf6no/PRePK9xqJqAqo+/tCZYqSkaRQcEb/u3TmW3qEzq7OJ/P/T w8V1/hWENTdsrLyxuuyw+eqCrZ/49jdEKYb018PRfAq0t7V/Qv+IOvKesqnFK42T6QwWH8 h3WwZD0iUD94KxNfIzZCO/VKEjxLfEg6H7XuU/uFBjrc60yq1YH9Q9aOcMNYtA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779470776; 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=viOUNQSErtt20QX3W26O6rN9Wn+blwwp9Ezhc1doXY8=; b=nhnJO4LYZcKJm93Xf9OZzjjrHNJgM4zInV59ortSpJivUFqTtVhX+3NS4hFxZX8BpZp4iK ofnPe4ywOs2gvhBg== 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: Reset software states during TDX module shutdown Cc: Chao Gao , Dave Hansen , Tony Lindgren , Kai Huang , Rick Edgecombe , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260520222906.A1E5DB91@davehans-spike.ostc.intel.com> References: <20260520222906.A1E5DB91@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: <177947077461.711.4053045613103460867.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: 522bacc2fbac65fdf2a91fdb5835f832b7aba31e Gitweb: https://git.kernel.org/tip/522bacc2fbac65fdf2a91fdb5835f832b= 7aba31e Author: Chao Gao AuthorDate: Wed, 20 May 2026 15:29:06 -07:00 Committer: Dave Hansen CommitterDate: Wed, 20 May 2026 15:37:10 -07:00 x86/virt/tdx: Reset software states during TDX module shutdown The TDX module requires a one-time global initialization (TDH.SYS.INIT) and per-CPU initialization (TDH.SYS.LP.INIT) before use. These initializations are guarded by software flags to prevent repetition. Reset all software flags guarding the initialization flows to allow the global and per-CPU initializations to be triggered again after updates. [ dhansen: trim down changelog ] Signed-off-by: Chao Gao Signed-off-by: Dave Hansen Reviewed-by: Tony Lindgren Reviewed-by: Kai Huang Reviewed-by: Rick Edgecombe Link: https://patch.msgid.link/20260520133909.409394-18-chao.gao@intel.com Link: https://patch.msgid.link/20260520222906.A1E5DB91@davehans-spike.ostc.= intel.com --- arch/x86/virt/vmx/tdx/tdx.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 3fe01b5..37e52cd 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -1279,6 +1279,7 @@ int tdx_module_shutdown(void) struct tdx_sys_info_handoff handoff =3D {}; struct tdx_module_args args =3D {}; int ret; + int cpu; =20 ret =3D get_tdx_sys_info_handoff(&handoff); /* @@ -1294,7 +1295,21 @@ int tdx_module_shutdown(void) */ args.rcx =3D handoff.module_hv; =20 - return seamcall_prerr(TDH_SYS_SHUTDOWN, &args); + ret =3D seamcall_prerr(TDH_SYS_SHUTDOWN, &args); + if (ret) + return ret; + + /* + * Clear global and per-CPU initialization flags so the new module + * can be fully re-initialized after a successful update. + * + * No locks needed as no concurrent accesses can occur here. + */ + memset(&tdx_module_state, 0, sizeof(tdx_module_state)); + for_each_possible_cpu(cpu) + per_cpu(tdx_lp_initialized, cpu) =3D false; + + return 0; } =20 static bool is_pamt_page(unsigned long phys)