From nobody Sun May 24 19:34:45 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 C814D39280C; Fri, 22 May 2026 17:26:27 +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=1779470789; cv=none; b=riqcRkp1/9JgD29+tZ0E555fT8qV+d3F1gJMxkANkMqx209NbYybstk5417EjwGTgO5Adf+b8l9jq3wThsKSqICejdV2M3aSEYS7MT1nEZHRqWQRc7O9UOU1vYBu1mjXxUCmNBvLjsnq4aRUMF6lZCBWLN7a3QatRPLdnEbKSfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470789; c=relaxed/simple; bh=dp/2JRJzE68s88wCd6p8ZFKryayN/kphkEvaADHz9e4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=PX/Pta9OabVqKmFfK5tRU7CvqyJWh/Ginu1W9gdp/hpB/tFNHfvGU5WaLBMQhhUHelH8yRllBXu6gIouaSHDDuVuL8x6bXpEESPmBChzAPsNPlfNss5nsp9EMSienLDlDYg0WyMuvSLzRbGehcT36xBeW7zJ+ywyXynO0wXcVQg= 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=sY7Fo12z; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AaZvdeTK; 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="sY7Fo12z"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AaZvdeTK" Date: Fri, 22 May 2026 17:26:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779470786; 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=IpaaLR8gOaSu8m67hRvIbzdeXOoD8R803Cm4fir/UJI=; b=sY7Fo12zOWpmVSw6ewrE+E4w9N/9669bx8de377ogARwWITaXnU50R9f9shRpMmK26hBro Aoi4SaFxEcqFbPy8XdX29587g1mHlTEp+0Kc/eCJ8GqKjBpk1ZWWToETegM7gQTAUwwG0h bV4+H7HZYw6BVRpDMd6zb4y87W+y1KEn6jM/BNxRTN4ylROn6MbifLsybXkVjZSCokPB6J qfDDK1gmhFBjip7ZMWvTckRBBz0YTLo8lvJmXPwjE7dzyg3VHh7cEr2VJVzCFjYTTE9TbE dJZ7zm+jyCvx8VP91HEmEFles1agoQ4JqLL0t4KIlpQ95ZdS0Wghw/nFOztqrw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779470786; 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=IpaaLR8gOaSu8m67hRvIbzdeXOoD8R803Cm4fir/UJI=; b=AaZvdeTKEOSM2qcV2TPUa8lNT/LRNlfB0x7zWv3T2LGq12Au6F7/4xMnL6kBGdM6xhX6jf fLNYMgDhPZ8pyfBw== 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/seamldr: Add a helper to retrieve P-SEAMLDR information Cc: Chao Gao , Dave Hansen , Kai Huang , "Kiryl Shutsemau (Meta)" , Xiaoyao Li , Rick Edgecombe , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260520222856.F362C738@davehans-spike.ostc.intel.com> References: <20260520222856.F362C738@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: <177947078491.711.14378564828985313918.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: fcbc30f0d66fed9a484a723d22702e704b02656c Gitweb: https://git.kernel.org/tip/fcbc30f0d66fed9a484a723d22702e704= b02656c Author: Chao Gao AuthorDate: Wed, 20 May 2026 15:28:56 -07:00 Committer: Dave Hansen CommitterDate: Wed, 20 May 2026 15:37:09 -07:00 x86/virt/seamldr: Add a helper to retrieve P-SEAMLDR information P-SEAMLDR reports its state via SEAMLDR.INFO, including its version and the number of remaining runtime updates. This information is useful for userspace. For example, userspace can use the P-SEAMLDR version to determine whether a candidate TDX module is compatible with the running loader, and can use the remaining update count to determine whether another runtime update is still possible. Add a helper to retrieve P-SEAMLDR information in preparation for exposing P-SEAMLDR version and other necessary information to userspace. Export the new kAPI for use by the "tdx_host" device. Note that there are two distinct P-SEAMLDR APIs with similar names: "SEAMLDR.INFO" is metadata about the loader. It's metadata for the update process. "SEAMLDR.SEAMINFO" is metadata about SEAM mode. It is for the module init process, not for the update process. Use SEAMLDR.INFO here. For details, see "Intel Trust Domain Extensions - SEAM Loader (SEAMLDR) Interface Specification". Signed-off-by: Chao Gao Signed-off-by: Dave Hansen Reviewed-by: Kai Huang Reviewed-by: Kiryl Shutsemau (Meta) Reviewed-by: Xiaoyao Li Reviewed-by: Rick Edgecombe Reviewed-by: Dave Hansen Link: https://patch.msgid.link/20260520133909.409394-10-chao.gao@intel.com Link: https://patch.msgid.link/20260520222856.F362C738@davehans-spike.ostc.= intel.com --- arch/x86/include/asm/seamldr.h | 35 ++++++++++++++++++++++++++++++++- arch/x86/virt/vmx/tdx/seamldr.c | 20 +++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/seamldr.h diff --git a/arch/x86/include/asm/seamldr.h b/arch/x86/include/asm/seamldr.h new file mode 100644 index 0000000..a74151b --- /dev/null +++ b/arch/x86/include/asm/seamldr.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SEAMLDR_H +#define _ASM_X86_SEAMLDR_H + +#include + +/* + * This is the "SEAMLDR_INFO" data structure defined in the + * "SEAM Loader (SEAMLDR) Interface Specification". + * + * Must be aligned to a 256-byte boundary. + */ +struct seamldr_info { + u32 version; + u32 attributes; + u32 vendor_id; + u32 build_date; + u16 build_num; + u16 minor_version; + u16 major_version; + u16 update_version; + u32 acm_x2apicid; + u32 num_remaining_updates; + u8 seam_info[128]; + u8 seam_ready; + u8 seam_debug; + u8 p_seam_ready; + u8 reserved[93]; +} __packed __aligned(256); + +static_assert(sizeof(struct seamldr_info) =3D=3D 256); + +int seamldr_get_info(struct seamldr_info *seamldr_info); + +#endif /* _ASM_X86_SEAMLDR_H */ diff --git a/arch/x86/virt/vmx/tdx/seamldr.c b/arch/x86/virt/vmx/tdx/seamld= r.c index 65616dd..7269a23 100644 --- a/arch/x86/virt/vmx/tdx/seamldr.c +++ b/arch/x86/virt/vmx/tdx/seamldr.c @@ -8,8 +8,13 @@ =20 #include =20 +#include + #include "seamcall_internal.h" =20 +/* P-SEAMLDR SEAMCALL leaf function */ +#define P_SEAMLDR_INFO 0x8000000000000000 + /* * Serialize P-SEAMLDR calls since the hardware only allows a single CPU to * interact with P-SEAMLDR simultaneously. Use raw version as the calls can @@ -18,8 +23,21 @@ */ static DEFINE_RAW_SPINLOCK(seamldr_lock); =20 -static __maybe_unused int seamldr_call(u64 fn, struct tdx_module_args *arg= s) +static int seamldr_call(u64 fn, struct tdx_module_args *args) { guard(raw_spinlock)(&seamldr_lock); return seamcall_prerr(fn, args); } + +int seamldr_get_info(struct seamldr_info *seamldr_info) +{ + struct tdx_module_args args =3D {}; + + /* + * Use slow_virt_to_phys() since @seamldr_info may be allocated on + * the stack. + */ + args.rcx =3D slow_virt_to_phys(seamldr_info); + return seamldr_call(P_SEAMLDR_INFO, &args); +} +EXPORT_SYMBOL_FOR_MODULES(seamldr_get_info, "tdx-host");