Re: [PATCH v5 3/7] x86/virt/tdx: Mark memory cache state incoherent when making SEAMCALL

From: Huang, Kai
Date: Wed Aug 13 2025 - 20:09:55 EST


On Tue, 2025-08-12 at 01:32 +0000, Huang, Kai wrote:
> On Tue, 2025-08-12 at 00:51 +0000, Edgecombe, Rick P wrote:
> > On Tue, 2025-07-29 at 00:28 +1200, Kai Huang wrote:
> > > +static __always_inline u64 do_seamcall(sc_func_t func, u64 fn,
> > > +        struct tdx_module_args *args)
> > > +{
> > > + lockdep_assert_preemption_disabled();
> > > +
> > > + /*
> > > + * SEAMCALLs are made to the TDX module and can generate dirty
> > > + * cachelines of TDX private memory.  Mark cache state incoherent
> > > + * so that the cache can be flushed during kexec.
> > > + *
> > > + * This needs to be done before actually making the SEAMCALL,
> > > + * because kexec-ing CPU could send NMI to stop remote CPUs,
> > > + * in which case even disabling IRQ won't help here.
> > > + */
> > > + this_cpu_write(cache_state_incoherent, true);
> > > +
> > > + return func(fn, args);
> > > +}
> > > +
> >
> >
> > Functionally it looks good now, but I still think the chain of names is not
> > acceptable:
> >
> > seamcall()
> > sc_retry()
> > do_seamcall()
> > __seamcall()
> >
> > sc_retry() is the only one with a hint of what is different about it, but it
> > randomly uses sc abbreviation instead of seamcall. That is an existing thing.
> > But the additional one should be named with something about the cache part that
> > it does, like seamcall_dirty_cache() or something. "do_seamcall()" tells the
> > reader nothing.
>
> OK. I'll change do_seamcall() to seamcall_dirty_cache().
>

Talked to Rick offline on this. seamcall_dirty_cache() seems more like a
high level helper, e.g., could look like a wrapper to existing
seamcall*(). We agreed to change to __seamcall_dirty_cache(), which looks
like a low level helper instead.