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

From: Dave Hansen
Date: Thu Apr 28 2022 - 19:53:50 EST


On 4/28/22 16:44, Kai Huang wrote:
>> Just like the SME test, it doesn't even need to be precise. It just
>> needs to be 100% accurate in that it is *ALWAYS* set for any system that
>> might have dirtied cache aliases.
>>
>> I'm not sure why you are so fixated on SEAMRR specifically for this.
> I see. I think I can simply use MTRR.SEAMRR bit check. If CPU supports SEAMRR,
> then basically it supports MKTME.
>
> Is this look good for you?

Sure, fine, as long as it comes with a coherent description that
explains why the check is good enough.

>>> "During initializing the TDX module, one step requires some SEAMCALL must be
>>> done on all logical cpus enabled by BIOS, otherwise a later step will fail.
>>> Disable CPU hotplug during the initialization process to prevent any CPU going
>>> offline during initializing the TDX module. Note it is caller's responsibility
>>> to guarantee all BIOS-enabled CPUs are in cpu_present_mask and all present CPUs
>>> are online."
>> But, what if a CPU went offline just before this lock was taken? What
>> if the caller make sure all present CPUs are online, makes the call,
>> then a CPU is taken offline. The lock wouldn't do any good.
>>
>> What purpose does the lock serve?
> I thought cpus_read_lock() can prevent any CPU from going offline, no?

It doesn't prevent squat before the lock is taken, though.