Re: [PATCHv4 04/30] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions

From: Kirill A. Shutemov
Date: Thu Feb 24 2022 - 18:29:11 EST


On Thu, Feb 24, 2022 at 09:01:42AM -0800, Dave Hansen wrote:
> On 2/24/22 07:56, Kirill A. Shutemov wrote:
> > + tdcall
> > +
> > + /*
> > + * TDVMCALL leaf does not suppose to fail. If it fails something
> > + * is horribly wrong with TDX module. Stop the world.
> > + */
> > + testq %rax, %rax
> > + jne .Lpanic
>
> This should be:
>
> "A TDVMCALL is not supposed to fail."
>
> I also wish this was mentioning something about the difference between a
> failure and return code.
>
> /*
> * %rax==0 indicates a failure of the TDVMCALL mechanism itself
> * and that something has gone horribly wrong with the TDX
> * module.
> *
> * The return status of the hypercall operation is separate
> * (in %r10). Hypercall errors are a part of normal operation
> * and are handled by callers.
> */
>
> I've been confused by this exact thing multiple times over the months
> that I've been looking at this code. I think it deserves a good comment.

Sure. The updated patch is below.