Re: [PATCHv2 01/12] x86/tdx: Consolidate TDX error handling
From: Sean Christopherson
Date: Thu Jun 26 2025 - 11:51:57 EST
On Thu, Jun 26, 2025, Dave Hansen wrote:
> On 6/26/25 02:25, kirill.shutemov@xxxxxxxxxxxxxxx wrote:
> >> Can we turn them into macros that make it super obvious they are checking if the
> >> error code *is* xyz? E.g.
> >>
> >> #define IS_TDX_ERR_OPERAND_BUSY
> >> #define IS_TDX_ERR_OPERAND_INVALID
> >> #define IS_TDX_ERR_NO_ENTROPY
> >> #define IS_TDX_ERR_SW_ERROR
> >>>> As is, it's not at all clear that things like tdx_success() are
> >> simply checks, as opposed to commands.
> > I remember Dave explicitly asked for inline functions over macros
> > where possible.
> >
> > Can we keep them as functions, but give the naming scheme you
> > proposing (but lowercase)?
I don't care about function versus macro, but I'd prefer uppercase. As Linus
pointed out[*], upper vs. lower case is about the usage and semantics as much as
it's about whether or not the thingie is literally a macro vs. function.
[*] https://lore.kernel.org/all/CAHk-=whGWM50Qq3Dgha8ByU7t_dqvrCk3JFBSw2+X0KUAWuT1g@xxxxxxxxxxxxxx
> Macros versus function isn't super important. I think Sean was asking if
> we could do:
>
> if (err == IS_TDX_ERR_OPERAND_BUSY)
> ...
>
> instead of:
>
> if (tdx_operand_busy(err))
> ...
No, I was thinking:
if (IS_TDX_ERR_OPERAND_BUSY(err))
e.g. to so that it looks like IS_ERR(), which is a familiar pattern.