mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yi Sun <yi.sun@intel.com>
To: Kuppuswamy Sathyanarayanan  <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: <kirill.shutemov@linux.intel.com>, <linux-kernel@vger.kernel.org>,
	<heng.su@intel.com>, <yi.sun@linux.intel.com>,
	Dongcheng Yan <dongcheng.yan@intel.com>
Subject: Re: [PATCH v3] x86/tdx: Dump TDX version During the TD Bootup
Date: Tue, 3 Oct 2023 21:56:31 +0800	[thread overview]
Message-ID: <ZRwdj9mZz+Qt5FPP@ysun46-mobl.ccr.corp.intel.com> (raw)
In-Reply-To: <483ee0eb-cc14-44a4-9c3b-77a6d0860359@linux.intel.com>

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

  reply	other threads:[~2023-10-03 13:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30 16:11 Yi Sun
2023-10-02 10:38 ` kirill.shutemov
2023-10-02 11:02   ` Huang, Kai
2023-10-03 13:26 ` Kuppuswamy Sathyanarayanan
2023-10-03 13:56   ` Yi Sun [this message]
2023-10-03 14:01     ` Kuppuswamy Sathyanarayanan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRwdj9mZz+Qt5FPP@ysun46-mobl.ccr.corp.intel.com \
    --to=yi.sun@intel.com \
    --cc=dongcheng.yan@intel.com \
    --cc=heng.su@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=yi.sun@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®