Re: [RFC PATCH v1 1/3] x86/tdx: Make TDX metadata available via SYSFS
From: Kirill A . Shutemov
Date: Tue Mar 18 2025 - 05:31:39 EST
On Mon, Mar 17, 2025 at 06:35:35PM -0700, Dan Williams wrote:
> Kirill A . Shutemov wrote:
> > On Fri, Mar 14, 2025 at 04:42:31PM -0700, Dan Williams wrote:
> > > Alexey Gladkov wrote:
> > > > From: "Alexey Gladkov (Intel)" <legion@xxxxxxxxxx>
> > > >
> > > > Expose the TDX module information to userspace. The version information
> > > > is valuable for debugging, as knowing the exact module version can help
> > > > reproduce TDX-related issues.
> > > >
> > > > Signed-off-by: Alexey Gladkov (Intel) <legion@xxxxxxxxxx>
> > > > ---
> > > > arch/x86/Kconfig | 1 +
> > > > arch/x86/include/asm/shared/tdx.h | 2 +
> > > > arch/x86/include/asm/tdx.h | 12 +++++
> > > > arch/x86/virt/vmx/tdx/tdx.c | 74 +++++++++++++++++++++++++++++++
> > > > 4 files changed, 89 insertions(+)
> > > >
> [..]
> > > > +__init static int tdh_sysfs_init(void)
> > > > +{
> > > > + struct kobject *tdx_kobj;
> > > > + int ret;
> > > > +
> > > > + if (!hypervisor_kobj)
> > > > + return -ENOMEM;
> > > > +
> > > > + tdx_kobj = kobject_create_and_add("tdx", hypervisor_kobj);
> > >
> > > So this "/sys/hypervisor" proposal is clearly unaware of some other
> > > discussions that have been happening around sysfs ABI for TEE Security
> > > Managers like the PSP or TDX Module [1]. That PCI/TSM series discusses
> > > the motivation for a bus/class + device model, not just raw hand-crafted
> > > kobjects.
> > >
> > > My other concern for hand-crafted kobjects is that it also destroys the
> > > relationship with other existing objects. A /sys/hypervisor/$technology
> > > is awkward when ABI like Documentation/ABI/testing/sysfs-driver-ccp
> > > already exists.
> > >
> > > So, no, I am not on board with this proposal. There are already patches
> > > in flight to have TDX create a 'struct device' object that plays a
> > > similar role as the PSP device object. For any potential common
> > > attributes across vendors the proposal is that be handled via a typical
> > > sysfs class device construction that links back to the $technology
> > > device. That "tsm" class device is present in the PCI/TSM series [1].
> > >
> > > [1]: http://lore.kernel.org/174107245357.1288555.10863541957822891561.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > Dan, could you elaborate on what is actual proposal? I am not sure I
> > understand what 'struct device' can have info on TDX module version be
> > attached to it.
>
> Confused, you do not understand that devices can have sysfs attributes?
I didn't understand what device it would be in TDX case.
> Documentation/ABI/testing/sysfs-driver-ccp describes a device object and
> sysfs attributes for SEV-SNP firmware status.
>
> For TDX, the proposal is to create virtual device to stand in for the
> lack of a PCI device that fills the same role as AMD PSP.
Okay, I got it.
Do you see a problem having the same interface for both host and guest?
We obviously need indication what level we are running on.
> With the expectation that all TSM technolgies (SEV-SNP, TDX, CCA, etc)
> register a device, udev rules can trigger off a common class device
> uevent. That proposal is detailed here [1]:
>
> [1]: http://lore.kernel.org/174107247268.1288555.9365605713564715054.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx
Joerg, what do you think? How does it fit your ideas for SEV-SNP?
--
Kiryl Shutsemau / Kirill A. Shutemov