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

Xu Yilun <[email protected]> Fri, 24 Jul 2026 11:14:16 +0800
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.linux-kernel
Message-ID <amLYiGOfYJEuYKkY@yilunxu-OptiPlex-7050>
> >  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/[email protected]/
[2] 0b3bc018e86a ("x86/virt/tdx: Avoid indirect calls to TDX assembly function")