Re: [PATCH v3 02/16] x86/tdx: Add helpers to check return status codes

Edgecombe, Rick P
2025-09-25T23:27:24Z

On Fri, 2025-09-19 at 01:26 +0000, Huang, Kai wrote:
> > +#include <asm/trapnr.h>
> > +
> >   /* Upper 32 bit of the TDX error code encodes the status */
> > -#define TDX_SEAMCALL_STATUS_MASK 0xFFFFFFFF00000000ULL
> > +#define
> > TDX_STATUS_MASK 0xFFFFFFFF00000000ULL
>
> Nit: the whitespace/tab change here is a bit odd?

I don't see it. It keeps the alignment (that also matches the below hunk) with
the name length change. Check it in an editor.

>
> >
> >   /*
> >    * TDX SEAMCALL Status Codes
> > @@ -52,4 +54,54 @@
> >   #define TDX_OPERAND_ID_SEPT 0x92
> >   #define TDX_OPERAND_ID_TD_EPOCH 0xa9
> >
> > +#ifndef __ASSEMBLER__
> > +#include <linux/bits.h>
> > +#include <linux/types.h>
> > +
> > +static inline u64 TDX_STATUS(u64 err)
> > +{
> > + return err & TDX_STATUS_MASK;
> > +}
> >
> [...]
>
> > +static inline bool IS_TDX_SW_ERROR(u64 err)
> > +{
> > + return (err & TDX_SW_ERROR) == TDX_SW_ERROR;
> > +}
> > +
> >
>
> [...]
>
> > +#define DEFINE_TDX_ERRNO_HELPER(error) \
> > + static inline bool IS_##error(u64 err) \
> > + { \
> > + return TDX_STATUS(err) == error; \
> > + }
>
> Given:
>
> +#define TDX_ERROR _BITULL(63)
> +#define TDX_SW_ERROR (TDX_ERROR | GENMASK_ULL(47, 40))
>
> I think IS_TDX_SW_ERROR() can also use the DEFINE_TDX_ERRNO_HELPER() ?

Good point.