Re: [PATCH 21/25] KVM: x86: Introduce KVM_TDX_GET_CPUID

Tony Lindgren
2024-09-03T06:21:42Z

On Mon, Aug 19, 2024 at 10:59:49AM +0800, Tao Su wrote:
> On Mon, Aug 12, 2024 at 03:48:16PM -0700, Rick Edgecombe wrote:
> > From: Xiaoyao Li <xiaoyao.li@intel.com>
> > + /*
> > + * Work around missing support on old TDX modules, fetch
> > + * guest maxpa from gfn_direct_bits.
> > + */
> > + if (output_e->function == 0x80000008) {
> > + gpa_t gpa_bits = gfn_to_gpa(kvm_gfn_direct_bits(vcpu->kvm));
> > + unsigned int g_maxpa = __ffs(gpa_bits) + 1;
> > +
> > + output_e->eax &= ~0x00ff0000;
> > + output_e->eax |= g_maxpa << 16;
> > + }
>
> I suggest putting all guest_phys_bits related WA in a WA-only patch, which will
> be clearer.

The 80000008 workaround needs to be tidied up for sure, it's hard to follow.

> > --- a/arch/x86/kvm/vmx/tdx.h
> > +++ b/arch/x86/kvm/vmx/tdx.h
> > @@ -25,6 +25,11 @@ struct kvm_tdx {
> > bool finalized;
> >
> > u64 tsc_offset;
> > +
> > + /* For KVM_MAP_MEMORY and KVM_TDX_INIT_MEM_REGION. */
> > + atomic64_t nr_premapped;
>
> I don't see it is used in this patch set.

Yes that should have been in a later patch.

Regards,

Tony