Yes, that would be better for this case.
On 9/30/2023 9:11 AM, Yi Sun wrote:
+static int tdg_get_sysinfo(struct tdg_sys_info *td_sys)
+{
+ struct tdx_module_output out;
+ u64 ret;
+
+ if (!td_sys)
+ return -EINVAL;
+
+ ret = __tdx_module_call(TDX_SYS_RD, 0, TDX_SYS_VENDOR_ID_FID, 0, 0,
+ &out);
+ if (TDCALL_RETURN_CODE(ret) == TDCALL_INVALID_OPERAND)
+ goto version_1_0;
+ else if (ret)
+ return ret;
For this failure case, do you want to reset tdg_sys_info to some value like zero
or some constants to specify unknown?
I overlooked that. I will add it in the next version.+
+ td_sys->vendor_id = (u32)out.r8;
+
+ ret = __tdx_module_call(TDX_SYS_RD, 0, TDX_SYS_MAJOR_FID, 0, 0, &out);
+ if (ret)
+ return ret;
+
+ td_sys->major_version = (u16)out.r8;
+
+ ret = __tdx_module_call(TDX_SYS_RD, 0, TDX_SYS_MINOR_FID, 0, 0, &out);
+ if (ret)
+ return ret;
+
+ td_sys->minor_version = (u16)out.r8;
+
+ return 0;
+
+ /* TDX 1.0 does not have the TDCALL TDG.SYS.RD */
+version_1_0:
+ td_sys->vendor_id = TDX_VENDOR_INTEL;
+ td_sys->major_version = 1;
+ td_sys->minor_version = 0;
+
+ return 0;
+}
+
void __init tdx_early_init(void)
{
u64 cc_mask;
u32 eax, sig[3];
+ struct tdg_sys_info td_sys_info;
cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]);
@@ -820,5 +882,9 @@ void __init tdx_early_init(void)
*/
x86_cpuinit.parallel_bringup = false;
- pr_info("Guest detected\n");
+ tdg_get_sysinfo(&td_sys_info);
Why not check the return value before dumping the info?