From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 16BEB33F36E for ; Fri, 23 Jan 2026 15:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180425; cv=none; b=To6SrbKJz4qkUves/KPrr4Es0szoHv9JyCFK4MCjsaU9hbNGTpJxcU2R4NJkuW/rv8yYvoWw66FRGtS+xuwS0PsZ/3ANwQqruAUt/s9s9S3dgmuojing0aKgB980tlpVf0d6idnGMgkimjBF1pmdcq/Qee/Y01vZEG+zIw0QNUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180425; c=relaxed/simple; bh=5q4zqWajw/8RUodFT+CwqmTk6wtdoZ/kJ+GQJqa5ufU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FyE58XjNAbwdpbQGhbx78V8AJFy00uhleQ0cdMyGMaGQ6oFc9Gf+eOxeIRDPg/DidNIYivZMhaw3jYhDzZoFScU4Lm0K8PshJ6fymkTrSSFYzzknyvO5gUYroRY1j8c5REZmPTLMObxQQ4Too6BixjvWG4aaFBdfVe+QopBT1YE= 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=mxyNmbKQ; arc=none smtp.client-ip=192.198.163.17 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mxyNmbKQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769180422; x=1800716422; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5q4zqWajw/8RUodFT+CwqmTk6wtdoZ/kJ+GQJqa5ufU=; b=mxyNmbKQhf2PpoXRpV/Q7le8ypdOzONlGBPgR22E80XzhScUpsGZWFdj zMdqnrmlvyzVPV9aMZPjNi61gzpp0D39Wjfeik26brqhsFInirMu06YbS sgTtX1dp4Q3jXF6VjNcZQZMmlobZx7NYNI2ZKXplMDDaTq7y9wpIlr53N Y/wh0sgc9diaa4nF9VjD40DvmBZy7KWMcsUoy6kWcS1iTFqxEjUlb+KbA avGO7KI5QM72Rhc+H96Dvv/xg/nY/0XcE73HZEcuoh72s2Zg49m/tKa0b ZNW+TyXcYgZLf+dZBci5juWUdxJrFZgSdHUPKES5FesIXudQJM15bvNUG g==; X-CSE-ConnectionGUID: oH6nJPlVQ8Skr1e0aei3lA== X-CSE-MsgGUID: /z2QNk48QNiIPj8aPpYqXA== X-IronPort-AV: E=McAfee;i="6800,10657,11680"; a="70334388" X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="70334388" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2026 07:00:12 -0800 X-CSE-ConnectionGUID: v1yJjE8FR869Sza7hB3BRg== X-CSE-MsgGUID: 7Ue34iN0Tw6r5nEkThgzlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,248,1763452800"; d="scan'208";a="237697104" Received: from 984fee019967.jf.intel.com ([10.23.153.244]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2026 07:00:12 -0800 From: Chao Gao To: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org Cc: reinette.chatre@intel.com, ira.weiny@intel.com, kai.huang@intel.com, dan.j.williams@intel.com, yilun.xu@linux.intel.com, sagis@google.com, vannapurve@google.com, paulmck@kernel.org, nik.borisov@suse.com, zhenzhong.duan@intel.com, seanjc@google.com, rick.p.edgecombe@intel.com, kas@kernel.org, dave.hansen@linux.intel.com, vishal.l.verma@intel.com, Chao Gao , Farrah Chen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH v3 08/26] x86/virt/seamldr: Retrieve P-SEAMLDR information Date: Fri, 23 Jan 2026 06:55:16 -0800 Message-ID: <20260123145645.90444-9-chao.gao@intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260123145645.90444-1-chao.gao@intel.com> References: <20260123145645.90444-1-chao.gao@intel.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit P-SEAMLDR returns its information e.g., version and supported features, in response to the SEAMLDR.INFO SEAMCALL. This information is useful for userspace. For example, the admin can decide which TDX module versions are compatible with the P-SEAMLDR according to the P-SEAMLDR version. Add and export seamldr_get_info() which retrieves P-SEAMLDR information by invoking SEAMLDR.INFO SEAMCALL in preparation for exposing P-SEAMLDR version and other necessary information to userspace. Signed-off-by: Chao Gao Tested-by: Farrah Chen --- arch/x86/include/asm/seamldr.h | 27 +++++++++++++++++++++++++++ arch/x86/virt/vmx/tdx/seamldr.c | 17 ++++++++++++++++- 2 files changed, 43 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 000000000000..d1e9f6e16e8d --- /dev/null +++ b/arch/x86/include/asm/seamldr.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SEAMLDR_H +#define _ASM_X86_SEAMLDR_H + +#include + +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; + u8 reserved0[4]; + u32 num_remaining_updates; + u8 reserved1[224]; +} __packed; + +#ifdef CONFIG_INTEL_TDX_MODULE_UPDATE +const struct seamldr_info *seamldr_get_info(void); +#else +static inline const struct seamldr_info *seamldr_get_info(void) { return NULL; } +#endif + +#endif diff --git a/arch/x86/virt/vmx/tdx/seamldr.c b/arch/x86/virt/vmx/tdx/seamldr.c index b99d73f7bb08..6a83ae405fac 100644 --- a/arch/x86/virt/vmx/tdx/seamldr.c +++ b/arch/x86/virt/vmx/tdx/seamldr.c @@ -9,9 +9,16 @@ #include #include +#include + #include "seamcall.h" -static __maybe_unused int seamldr_call(u64 fn, struct tdx_module_args *args) +/* P-SEAMLDR SEAMCALL leaf function */ +#define P_SEAMLDR_INFO 0x8000000000000000 + +static struct seamldr_info seamldr_info __aligned(256); + +static inline int seamldr_call(u64 fn, struct tdx_module_args *args) { unsigned long flags; u64 vmcs; @@ -54,3 +61,11 @@ static __maybe_unused int seamldr_call(u64 fn, struct tdx_module_args *args) WARN_ONCE(1, "Failed to save/restore the current VMCS"); return -EIO; } + +const struct seamldr_info *seamldr_get_info(void) +{ + struct tdx_module_args args = { .rcx = __pa(&seamldr_info) }; + + return seamldr_call(P_SEAMLDR_INFO, &args) ? NULL : &seamldr_info; +} +EXPORT_SYMBOL_FOR_MODULES(seamldr_get_info, "tdx-host"); -- 2.47.3