On Tue, Apr 09, 2024, Paolo Bonzini wrote: > On Tue, Apr 9, 2024 at 3:21 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > > > I'm a little late to this conversation, so hopefully not just complicating > > > things. But why not deduce has_private_mem and has_protected_state from the > > > vm_type during runtime? Like if kvm.arch.vm_type was instead a bit mask with > > > the bit position of the KVM_X86_*_VM set, kvm_arch_has_private_mem() could > > > bitwise-and with a compile time mask of vm_types that have primate memory. > > > This also prevents it from ever transitioning through non-nonsensical states > > > like vm_type == KVM_X86_TDX_VM, but !has_private_memory, so would be a little > > > more robust. > > > > LOL, time is a circle, or something like that. Paolo actually did this in v2[*], > > and I objected, vociferously. > > To be fair, Rick is asking for something much less hideous - just set > > kvm->arch.vm_type = (1 << vm_type); > > and then define kvm_has_*(kvm) as !!(kvm->arch.vm_type & SOME_BIT_MASK). > > And indeed it makes sense as an alternative. Ah, yeah, I'd be fine with that. > It also feels a little bit more restrictive and the benefit is small, so I > think I'm going to go with this version. +1