Re: [PATCH v11 021/113] KVM: TDX: Refuse to unplug the last cpu on the package

From: Isaku Yamahata
Date: Mon Feb 27 2023 - 16:48:20 EST


On Mon, Jan 16, 2023 at 10:23:16AM +0000,
"Huang, Kai" <kai.huang@xxxxxxxxx> wrote:

> On Thu, 2023-01-12 at 08:31 -0800, isaku.yamahata@xxxxxxxxx wrote:
> > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> >
> > In order to reclaim TDX HKID, (i.e. when deleting guest TD), needs to call
> > TDH.PHYMEM.PAGE.WBINVD on all packages. If we have used TDX HKID, refuse
> > to offline the last online cpu. Add arch callback for cpu offline.
>
> I think it is worth to talk about suspend staff, i.e. why we only refuse to
> offline the last cpu when there's active TD, but not choose to offline the last
> cpu when TDX is enabled in KVM. People may not be able to understand
> immediately the reason behind this design.

Updated the comment.

> Btw, I certainly don't want to speak for Sean, but it seems this was suggested
> by Sean? If so, add a 'Suggested-by' tag?

Added suggested-by.

> >
> > Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> > ---
> >
>
> [snip]
>
> > +
> > +int tdx_offline_cpu(void)
> > +{
> > + int curr_cpu = smp_processor_id();
> > + cpumask_var_t packages;
> > + int ret = 0;
> > + int i;
> > +
> > + if (!atomic_read(&nr_configured_hkid))
> > + return 0;
>
> As mentioned above, I think it also worth to add some comment here. When people
> are trying to understand some code, I think mostly they are just going to look
> at the code itself, but won't use 'git blame' to dig out the entire changelog to
> understand some code.

Makes sense. Added a comment.
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>