[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZRwdj9mZz+Qt5FPP@ysun46-mobl.ccr.corp.intel.com>
Date: Tue, 3 Oct 2023 21:56:31 +0800
From: Yi Sun <yi.sun@...el.com>
To: Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>
CC: <kirill.shutemov@...ux.intel.com>, <linux-kernel@...r.kernel.org>,
<heng.su@...el.com>, <yi.sun@...ux.intel.com>,
Dongcheng Yan <dongcheng.yan@...el.com>
Subject: Re: [PATCH v3] x86/tdx: Dump TDX version During the TD Bootup
On 03.10.2023 06:26, Kuppuswamy Sathyanarayanan wrote:
>
>
>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?
Yes, that would be better for this case.
>> +
>> + 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?
>
I overlooked that. I will add it in the next version.
Thanks Sathya for your comments.
Thanks
--Yi Sun
Powered by blists - more mailing lists