RE: [PATCH v2 04/21] x86/virt/tdx: Add skeleton for detecting and initializing TDX on demand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Huang, Kai <kai.huang@xxxxxxxxx>
> Sent: Monday, March 28, 2022 9:58 AM
> 
> On Wed, 2022-03-23 at 19:49 +1300, Tian, Kevin wrote:
> > > From: Kai Huang <kai.huang@xxxxxxxxx>
> > > Sent: Sunday, March 13, 2022 6:50 PM
> > > +static bool seamrr_enabled(void)
> > > +{
> > > +     /*
> > > +      * To detect any BIOS misconfiguration among cores, all logical
> > > +      * cpus must have been brought up at least once.  This is true
> > > +      * unless 'maxcpus' kernel command line is used to limit the
> > > +      * number of cpus to be brought up during boot time.  However
> > > +      * 'maxcpus' is basically an invalid operation mode due to the
> > > +      * MCE broadcast problem, and it should not be used on a TDX
> > > +      * capable machine.  Just do paranoid check here and WARN()
> > > +      * if not the case.
> > > +      */
> > > +     if (WARN_ON_ONCE(!cpumask_equal(&cpus_booted_once_mask,
> > > +                                     cpu_present_mask)))
> > > +             return false;
> > > +
> >
> > cpu_present_mask doesn't always represent BIOS-enabled CPUs as it
> > can be further restricted by 'nr_cpus' and 'possible_cpus'. From this
> > angle above check doesn't capture all misconfigured boot options
> > which is incompatible with TDX. Then is such partial check still useful
> > or better to just document those restrictions and let TDX module
> > capture any violation later as what you explained in __init_tdx()?
> >
> > Thanks
> > Kevin
> 
> The purpose of checking cpus_booted_once_mask aganist
> cpu_present_mask is NOT to
> check whether all BIOS-enabled CPUs are brought up at least once.  Instead,
> the
> purpose is to check whether all cpus that kernel can use are brought up at
> least
> once (TDX-capable machine doesn't support ACPI CPU hotplug and all cpus
> are
> marked as enabled in MADT table, therefore cpu_present_mask is used
> instead of
> cpu_possible_mask).  This is used to make sure SEAMRR has been detected
> on all
> cpus that kernel can use.
> 
> Checking whether "all BIOS-enabled cpus are up" is not done here (neither in
> this series as we discussed it seems there's no appropriate variable to
> represent it).  And we just let TDH.SYS.CONFIG to fail if TDH.SYS.LP.INIT is not
> done on all BIOS-enabled CPUs.
> 

TDX requires all BIOS-enabled CPUs to execute certain SEAMCALLs for TDX
initialization. 

cpu_present_mask does not always represent BIOS-enabled CPUs due
to those boot options. Then why do we care whether CPUs in this mask
(if only representing a subset of BIOS-enabled CPUs) are at least brought
up once? It will fail at TDH.SYS.CONFIG anyway.

btw your comment said that 'maxcpus' is basically an invalid mode
due to MCE broadcase problem. I didn't find any code to block it when
MCE is enabled, thus wonder the rationale behind and whether that
rationale can be brought to this series (i.e. no check against those
conflicting boot options and just let SEAMCALL itself to detect and fail).

@Thomas, any guidance here?

Thanks
Kevin




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux