Re: [PATCH v4 3/4] virt: tdx-guest: Use a variable to store the Quote buffer size
From: Dave Hansen
Date: Tue Sep 22 2026 - 18:41:09 EST
On 9/22/26 12:46, Edgecombe, Rick P wrote:
> I was suggesting to make the new seamcall wrapper consistent in how it gets this
> data by referring to the global definition for the global key id instead of a
> parameter. Seems like it is against this feedback, can you give a quick take on
> that case too? I just think mixing global references and global values passed as
> arguments it too weird. Should we switch to passing everything as args even when
> we need to plumb it through several layers?
There's no one-size-fits-all solution.
It's really powerful if you can pack all of the code for a single
concept into a single small function. This pattern:
int foo(...)
{
static int __bar;
if (__bar)
return __bar;
__bar = whatever();
return __bar;
}
Because you can, at a single glance, get all of the context for foo()
that you need. When it gets set, who sets it. But it also only works for
static, write-once data.
As for passing things around through several layers, it's OK to do it if
it adds clarity to the code. If the entire point of a whole chain of
functions is to get a global variable set, doing:
foo(&global);
can make things clearer because you know *instantly* that only foo() and
things that call foo() can modify 'global'. It limits the scope of time
where 'global' can get modified.
Think of if foo() calls 10 other functions and they all randomly
reference 'global' directly. Figuring out how and when they call each
other and making sure there are no calls from outside can be really hard
to understand.
Passing 'global' around can make it really easy to understand.