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

Dave Hansen
2022-02-24T17:05:01Z

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.