Messages in this thread | ![/](/images/icornerl.gif) | | Date | Tue, 9 Apr 2024 08:26:28 -0700 | Subject | Re: [PATCH v5 07/17] KVM: x86: add fields to struct kvm_arch for CoCo features | From | Sean Christopherson <> |
| |
On Tue, Apr 09, 2024, Paolo Bonzini wrote: > On Tue, Apr 9, 2024 at 3:21 AM Sean Christopherson <seanjc@googlecom> 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
| ![\](/images/icornerr.gif) |