Re: [PATCH v14 06/23] x86/virt/tdx: Add SEAMCALL error printing for module initialization

From: Kuppuswamy Sathyanarayanan
Date: Wed Oct 18 2023 - 10:30:27 EST




On 10/17/2023 3:14 AM, Kai Huang wrote:
> The SEAMCALLs involved during the TDX module initialization are not
> expected to fail. In fact, they are not expected to return any non-zero
> code (except the "running out of entropy error", which can be handled
> internally already).
>
> Add yet another set of SEAMCALL wrappers, which treats all non-zero
> return code as error, to support printing SEAMCALL error upon failure
> for module initialization. Note the TDX module initialization doesn't
> use the _saved_ret() variant thus no wrapper is added for it.
>
> SEAMCALL assembly can also return kernel-defined error codes for three
> special cases: 1) TDX isn't enabled by the BIOS; 2) TDX module isn't
> loaded; 3) CPU isn't in VMX operation. Whether they can legally happen
> depends on the caller, so leave to the caller to print error message
> when desired.
>
> Also convert the SEAMCALL error codes to the kernel error codes in the
> new wrappers so that each SEAMCALL caller doesn't have to repeat the
> conversion.
>
> Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx>
> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> ---
>
> v13 -> v14:
> - Use real functions to replace macros. (Dave)
> - Moved printing error message for special error code to the caller
> (internal)
> - Added Kirill's tag
>
> v12 -> v13:
> - New implementation due to TDCALL assembly series.
>
> ---

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>

--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer