RE: [RFC v2-fix-v2 1/1] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions

From: Luck, Tony
Date: Thu May 27 2021 - 11:25:23 EST


> Guests communicate with VMMs with hypercalls. Historically, these
> are implemented using instructions that are known to cause VMEXITs
> like vmcall, vmlaunch, etc. However, with TDX, VMEXITs no longer
> expose guest state to the host.  This prevents the old hypercall
> mechanisms from working. So to communicate with VMM, TDX
> specification defines a new instruction called "tdcall".

You use all caps TDCALL everywhere else in this commit message.
Looks odd to have quoted lower case here.

> In a TDX based VM, since VMM is an untrusted entity, a intermediary
> layer (TDX module) exists between host and guest to facilitate the
> secure communication. TDX guests communicate with the TDX module and
> with the VMM using a new instruction: TDCALL.

Seems both repeat what was in the first paragraph, but also fail to
explain how this TDCALL is different from that first TDCALL.

> Implement common helper functions to communicate with the TDX Module
> and VMM (using TDCALL instruction).
>   
> __tdx_hypercall() - request services from the VMM.
> __tdx_module_call()  - communicate with the TDX Module.

Looking at the code, the hypercall can return an error if TDCALL fails,
but module_call forces a panic with UD2 on error. This difference isn't
explained anywhere.

-Tony