Re: [PATCH v13 005/113] KVM: TDX: Add placeholders for TDX VM/vcpu structure

From: Huang, Kai
Date: Thu Mar 16 2023 - 17:42:36 EST


On Thu, 2023-03-16 at 08:41 -0700, Isaku Yamahata wrote:
> On Wed, Mar 15, 2023 at 10:42:09AM +0000,
> "Huang, Kai" <kai.huang@xxxxxxxxx> wrote:
>
> > On Sun, 2023-03-12 at 10:55 -0700, isaku.yamahata@xxxxxxxxx wrote:
> > > +
> > > +static inline bool is_td(struct kvm *kvm)
> > > +{
> > > + return kvm->arch.vm_type == KVM_X86_PROTECTED_VM;
> > > +}
> > > +
> >
> > KVM_X86_PROTECTED_VM is defined in the next patch, which means this patch cannot
> > compile.

Oh I see your patch only added this type to tools/.../asm/kvm.h

--- a/tools/arch/x86/include/uapi/asm/kvm.h
+++ b/tools/arch/x86/include/uapi/asm/kvm.h
@@ -559,4 +559,7 @@ struct kvm_pmu_event_filter {
#define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
#define KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */

+#define KVM_X86_DEFAULT_VM 0
+#define KVM_X86_PROTECTED_VM 1
+

So this one has already been in UPM series.

But I thought Sean had a comment saying we should not add such definition to
header file under tools/:

Even it needs to be added, it should be in the relevant patch in UPM series, but
not here.

> >
> > Also, why KVM_X86_PROTECTED_VM == TDX VM?
>
> This part needs to be resolved.
> Use KVM_X86_PROTECTED_VM as TDX VM or new type KVM_X86_TDX_VM or other way
> to specify VM type.
> Given pKVM is coming, dedicated VM type seems better. I'll switch it to
> KVM_X86_TDX_VM next respin.
> --
> Isaku Yamahata <isaku.yamahata@xxxxxxxxx>

I'll leave to Sean and Paolo.