Re: [PATCH v5 05/12] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions

Borislav Petkov
2021-08-20T15:16:24Z

On Wed, Aug 04, 2021 at 11:13:22AM -0700, Kuppuswamy Sathyanarayanan wrote:
> +SYM_FUNC_START(__tdx_hypercall)
> + FRAME_BEGIN
> +
> + /* Move argument 7 from caller stack to RAX */
> + movq ARG7_SP_OFFSET(%rsp), %rax
> +
> + /* Check if caller provided an output struct */
> + test %rax, %rax
> + /* If out pointer is NULL, return -EINVAL */
> + jz 1f
> +
> + /* Save callee-s ved GPRs as mandated by the x86_64 ABI */

That should be "callee-saved" ofc. "s ved" is not a word. :-)

...

> + /*
> + * Zero out registers exposed to the VMM to avoid
> + * speculative execution with VMM-controlled values.
> + * This needs to include all registers present in
> + * TDVMCALL_EXPOSE_REGS_MASK (except R12-R15).
> + * R12-R15 context will be restored.
> + */
> + xor %r10d, %r10d
> + xor %r11d, %r11d
> +
> + /* Restore state of R9 register */
> + pop %r9
> +
> + /* Restore callee-s ved GPRs as mandated by the x86_64 ABI */

Here too.

Otherwise, LGTM. Thanks for documenting the ABI - looks good.

--
Regards/Gruss,
Boris.