RE: [PATCH 4/6] x86/hyperv: Add hv_isolation_type_tdx() to detect TDX guests

From: Dexuan Cui
Date: Wed Nov 23 2022 - 14:13:51 EST


> From: Sathyanarayanan Kuppuswamy
> <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
>
> On 11/21/22 11:51 AM, Dexuan Cui wrote:
> > No logic change to SNP/VBS guests.
>
> Add some info on how and where you are going to use this function.

Will do.

> > +DEFINE_STATIC_KEY_FALSE(isolation_type_tdx);
> > +
> > +bool hv_isolation_type_tdx(void)
> > +{
> > + return static_branch_unlikely(&isolation_type_tdx);
> > +}
>
> Does it need #ifdef CONFIG_INTEL_TDX_GUEST? If not TDX, you can
> live with weak reference.

Will add the #ifdef.

> > - if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) {
> > - if (hv_get_isolation_type() != HV_ISOLATION_TYPE_NONE)
> > + if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT) ||
> > + IS_ENABLED(CONFIG_INTEL_TDX_GUEST)) {
> > +
> > + switch (hv_get_isolation_type()) {
> > + case HV_ISOLATION_TYPE_VBS:
> > + case HV_ISOLATION_TYPE_SNP:
> > cc_set_vendor(CC_VENDOR_HYPERV);
> > + break;
> > +
> > + case HV_ISOLATION_TYPE_TDX:
> > + static_branch_enable(&isolation_type_tdx);
> > + break;
> > +
>
> It is not clear why you need special handling for TDX?

It's being discussed in another thread:
https://lwn.net/ml/linux-kernel/BYAPR21MB16886FF8B35F51964A515CD5D70C9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/

I'll wait for Michael Kelley's v4 and rebase my patches accordingly.