From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9004738DC57; Fri, 9 Oct 2026 13:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791551304; cv=none; b=HEUkdlwsLj6XM40mkHubS2Ev1DyDm5Iegx00O8nlhCs4UIgpxb5XNdn3dg+faMndBHgTZ9rJfmF5ZF/r4Mvh86FDiB7LVpsLWDJTK1IRWU1as9lMwaFuq22ft92aq+FFJipkGEzRMzz/1nktptZh9QrAlm460wc+0j8TCArds0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791551304; c=relaxed/simple; bh=yhTc7H+0IqN4frsO9baGH1rCR17Pji1FxlEXnUH5cBg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JS3UlEe1SK+DVBqD9RHNTOWIofCMnPpwgVi8Y1kKGEeAc9CROl8t8ZUtDBVW4IlRN6gLUCx4OOgnvOE7PUORYyrnevgPe4ocLZn94uDu1PCalRj89Ei/lFpKAQ5B+K8VMb9ra/MV002bk3xZZ1RGmW+2TnNFU0ueNQUJsfL3las= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c2qqCgv0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c2qqCgv0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F98C1F00893; Fri, 9 Oct 2026 13:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791551303; bh=FpUIQG2ildfJUJXlKIPJfIgmZEi5bWUOemoR8HcahF4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=c2qqCgv0D58/0e+k9zxI9o6dg3GYpDAHOtqCZbpcGXac3qwbIvxYpa3bQHSmqrAyV VsbnWIASJih0kFuAw4OTbBagMheW9GxPXdx7eadF0QUvCJ7NM2xmMlSZ0qprbBTc/K n20YP9NzuQfludLWwDvLQjdb6QoK3liPhRuyryMZHAyPbZs9AAR4Px0k1NL88KQp9u UxYSlHPSPJvYXRhzh37T9CMKT8VZVA9w3hFuCqZVVCu9jX6FPCT7ecTe605nzua1sr biOTq+gYuahC7BnenqIHkldbrWfR2yghlxyKT0NuYKmSdqfectrWBgw2AirTZ9L/f5 k1njNHyfO800Q== Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfauth.ams.internal (Postfix) with ESMTP id 92507198003A; Fri, 9 Oct 2026 09:08:16 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 09 Oct 2026 09:08:19 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFj6c6YPtf1RuC5ge2DhrVWepaKzhdu396taV7DKjafJHPQen98eiWB0+ajyHRDBo V9e4R6BapcDruKkFzt7wbLaUPtObKYs7i9noBdPNd/Q6HdaKBiK7wc4jCqMfUhvS89D9zD 6H8Qa2Lh150MpeNHzv+CKjV1NHARmiVAuljI7sPclv0uj2VaIlohhugxZpGz+KzF2cLXXD aw9miqNb9hjy9GUg6ZWhHJkCKHUPOnumFVmQYAyIbqyiR9vu2DTsyIAAhfPUlXZgZ4aiFu QOaOGft0y6E/laBs0cB6CcqW5Ibby+5XmFvevcK3EPGURVWQnT6jrlijFDsdGYcPZOA3gT mvvTl13TDo8h6/vmkHXJs1G7Ql6NxAv+Ch5hGDhY70m3VIQ9uhGLUoy9F7cLI/eJu4b/nH lZHFRwYYsu8dWgU8q3poX6OpVnmzbYLjMIAvFBb07hNoBj1OAiC7+LOJNVo0Wlqf709ua/ unpiNAskSwxOrVmfClu4Wi6a5hNXGTwKeZao5bkjWPxcs5imNSE0IINWKBTC4avlAQQbZ3 AMAI7l/Pat2dhWY2egMZFwwCy61AKkUl32pYmptN5sGsIrbFue5WT2TB2Y5QPmTWSaFT7q dOeSzIVEOjElCH6Rc9LqzfHAEcPBk6BUIy5wGHyo0tpH6H2v3Ux0jgPpbRAQ X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Oct 2026 09:08:14 -0400 (EDT) Date: Fri, 9 Oct 2026 14:08:13 +0100 From: Kiryl Shutsemau To: Xu Yilun Cc: x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Rick Edgecombe , Dave Hansen , dave.hansen@intel.com, kvm@vger.kernel.org, yilun.xu@intel.com, xiaoyao.li@intel.com, sohil.mehta@intel.com, adrian.hunter@intel.com, kishen.maloor@intel.com, tony.lindgren@linux.intel.com, peter.fang@intel.com, baolu.lu@linux.intel.com, zhenzhong.duan@intel.com, chao.gao@intel.com, artem.bityutskiy@linux.intel.com, nik.borisov@suse.com Subject: Re: [PATCH v3 1/6] x86/virt/tdx: Move TDH.SYS.CONFIG operations into a wrapper Message-ID: References: <20261006-tdx-module-ext-v3-0-db52cb05b918@linux.intel.com> <20261006-tdx-module-ext-v3-1-db52cb05b918@linux.intel.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261006-tdx-module-ext-v3-1-db52cb05b918@linux.intel.com> On Tue, Oct 06, 2026 at 01:41:45AM +0800, Xu Yilun wrote: > In Linux, SEAMCALL wrappers are introduced to avoid broad SEAMCALL > access by exposing only a selection of SEAMCALL leafs, but also to > abstract the SEAMCALL register ABIs. The abstraction improves > readability and reuse for SEAMCALL leafs that are called multiple times. > > Some SEAMCALL leafs are not explicitly wrapped because the level of TDX > ABI details needed to perform the call is low enough to flow well with > the calling code. > > For some of the currently unwrapped SEAMCALL leafs, the TDX architecture > has evolved the ABI to introduce new leaf versions. The host can select > the version to call based on what is supported by the loaded TDX module. > When future kernel implements this version selection, more ABI details > will leak into the surrounding caller code, which decreases the > readability of the caller logic. To keep the ABI details contained, move > the SEAMCALL leaf that will need version selection into a wrapper. > > When defining the wrapper, the cleanest separation would be to have > kernel data types for the SEAMCALL wrapper arguments, and have them > marshaled into SEAMCALL leaf ABI types (often u64s) inside the wrapper. > This works for many SEAMCALL leafs but becomes cumbersome when the > register ABI type is a physical address which points to a buffer for an > in-memory ABI. If the SEAMCALL wrapper only accepts kernel data types, > it may need duplicate buffer allocation and copies to match the > in-memory ABI. Another solution is to define a named helper structure > that mirrors the in-memory ABI, populate it in a separate flow, then > pass it to the SEAMCALL wrapper. struct seamldr_params is an existing > example of this pattern. > > TDH.SYS.CONFIG requires a list of TDMR information in the form of a PA > array. The PA array is the in-memory ABI. Create a structure for the PA > array, use it as the argument when creating the wrapper for > TDH.SYS.CONFIG. > > For readability, adjust a bit of the existing PA array size calculation: > use the new PA array structure's element type instead of hardcoding u64. > > Signed-off-by: Xu Yilun > Reviewed-by: Nikolay Borisov > Reviewed-by: Tony Lindgren Reviewed-by: Kiryl Shutsemau (Meta) -- Kiryl Shutsemau / Kirill A. Shutemov