Re: [PATCH v3] x86/virt/tdx: Formalize SEAMCALL version encoding support

From: Xu Yilun

Date: Thu Jul 23 2026 - 23:15:06 EST


> > static __always_inline u64 __seamcall_dirty_cache(sc_func_t func, u64 fn,
> > struct tdx_module_args *args)
> > {
> > + /*
> > + * fn contains base leaf number for TDX module calls and P-SEAMLDR
> > + * calls. Other fields in SEAMCALL leaf like leaf ABI version number
> > + * are in struct tdx_module_args.
> > + */
> > + BUILD_BUG_ON(fn & ~(SEAMCALL_LEAF_MASK | SEAMCALL_SEAMLDR_MASK));
> > +
>
> I guess this works because the __always_inline is enough for the compiler to
> trace fn to a compile time constant up the callchain. It seems somewhat compiler
> sensitive though. Did you convince yourself somehow that some compiler will not
> complain?

I see the previous talk [1][2], that existing __seamcall*() rely on the
direct call, though there is no guarantee. We accept the assumption
until there is compiler issue. So I think this doesn't add more problem.

[1] https://lore.kernel.org/lkml/20250605145914.GW39944@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
[2] 0b3bc018e86a ("x86/virt/tdx: Avoid indirect calls to TDX assembly function")