From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Yi Sun <yi.sun@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 07:01:44 -0700 [thread overview]
Message-ID: <1019158c-a854-4e29-b9ec-961fb878bab3@linux.intel.com> (raw)
In-Reply-To: <ZRwdj9mZz+Qt5FPP@ysun46-mobl.ccr.corp.intel.com>
On 10/3/2023 6:56 AM, Yi Sun wrote:
> 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.
if you plan to zero out the td_sys_info value in error case, I think it
is better to make the tdg_get_sysinfo as void
>
> Thanks
> --Yi Sun
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
prev parent reply other threads:[~2023-10-03 14:01 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
2023-10-03 14:01 ` Kuppuswamy Sathyanarayanan [this message]
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=1019158c-a854-4e29-b9ec-961fb878bab3@linux.intel.com \
--to=sathyanarayanan.kuppuswamy@linux.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=yi.sun@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®