Re: [PATCH v3 4/5] x86/tdx: tdx_mcall_get_report0: Return -EBUSY on TDCALL_OPERAND_BUSY error

From: Xing, Cedric
Date: Fri Apr 11 2025 - 13:38:47 EST


On 4/9/2025 12:13 AM, Dan Williams wrote:
Cedric Xing wrote:
Return `-EBUSY` from tdx_mcall_get_report0() when `TDG.MR.REPORT` returns
`TDCALL_OPERAND_BUSY`. This enables the caller to retry obtaining a
TDREPORT later if another VCPU is extending an RTMR concurrently.

Can this not be prevented by proper locking? Otherwise this type of
collision sounds like a kernel bug, not something that should escape to
userspace.

Yes, -EBUSY should never happen with proper locking, which however is implemented in the upper layer.

Similarly, -EINVAL will also indicate a kernel bug but is left for the upper layer to handle.

I.e. userspace can not reasonably know when it is safe to retry, so take
locks to ensure forward progress.
tdx-guest does WARN() on errors. There are no other users of this function currently. Returning an error, however, will allow different error handling in the future (e.g., retry instead of WARN on -EBUSY).