2022-05-07 17:47:24

by Isaku Yamahata

[permalink] [raw]
Subject: Re: [RFC PATCH v6 011/104] KVM: TDX: Initialize TDX module when loading kvm_intel.ko

On Fri, May 06, 2022 at 09:57:09PM +0800,
Xiaoyao Li <[email protected]> wrote:

> On 5/6/2022 2:14 AM, [email protected] wrote:
> > +int __init tdx_module_setup(void)
> > +{
> > + const struct tdsysinfo_struct *tdsysinfo;
> > + int ret = 0;
> > +
> > + BUILD_BUG_ON(sizeof(*tdsysinfo) != 1024);
> > + BUILD_BUG_ON(TDX_MAX_NR_CPUID_CONFIGS != 37);
> > +
> > + ret = tdx_detect();
> > + if (ret) {
> > + pr_info("Failed to detect TDX module.\n");
> > + return ret;
> > + }
> > +
> > + ret = tdx_init();
> > + if (ret) {
> > + pr_info("Failed to initialize TDX module.\n");
> > + return ret;
> > + }
> > +
> > + tdsysinfo = tdx_get_sysinfo();
> > + if (tdx_caps.nr_cpuid_configs > TDX_MAX_NR_CPUID_CONFIGS)
> > + return -EIO;
>
> It needs to check tdsysinfo->num_cpuid_config against
> TDX_MAX_NR_CPUID_CONFIG
>
> or move the check down after tdx_caps is initialized.

Thanks for catching it. I'll replace it with tdsysinfo->num_cpuid_config.

--
Isaku Yamahata <[email protected]>