RE: [PATCH v14 011/113] KVM: TDX: Add C wrapper functions for SEAMCALLs to the TDX module

From: Wang, Wei W
Date: Wed Jun 14 2023 - 07:46:07 EST


On Friday, June 9, 2023 4:11 AM, Isaku Yamahata wrote:
> How about this comment?
>
> if (unlikely(ret == TDX_SEAMCALL_UD)) {

Where is the TDX_SEAMCALL_UD error code documented in the spec?
I failed to find it.

> /*
> * TDX requires VMXON or #UD.

TDX requires #UD? Seems a bit ambiguous.

> In the case of reboot or kexec,
> * kvm shutdown notifier, kvm_shutdown(), makes VMX off
> (VMXOFF)
> * while TDs can be still running to invoke SEAMCALL. It
> * results in superfluous errors or warnings.
> * If rebooting, return 0 to suppress superfluous messages.
> * If not rebooting, panic by kvm_spurious_fault().
> */
> kvm_spurious_fault();

I would put it this way:
SEAMCALLs fail with TDX_SEAMCALL_UD returned when VMX is off.
This can happen when host gets rebooted or live updated. In this case,
the instruction execution is actually ignored as KVM is shut down, so
the error code is suppressed. Other than this, the error is unexpected
and the execution can't continue as the TDX features reply on VMX to
be on.