RE: [PATCH v1] KVM: x86: add KVM_CAP_DEVICE_CTRL

From: Wang, Wei W
Date: Mon Dec 19 2022 - 20:46:27 EST


On Tuesday, December 20, 2022 4:36 AM, Sean Christopherson wrote:
> > Yes, it looks better to move it to the generic check, but I'm not sure
> > if it would be necessary to do the per-device check here either via
> > CONFIG_KVM_VFIO (for example, if more non-arch-specific usages are
> > added, we would end up with lots of such #ifdef to be added, which
> > doesn't seem nice) or kvm_device_ops_table.
> >
> > I think fundamentally KVM_CAP_DEVICE_CTRL is used to check if the
> > generic kvm_device framework (e.g. KVM_CREATE_DEVICE) is supported by
> > KVM (older KVM before 2013 doesn't have it). The per-device type
> > (KVM_DEV_TYPE_VFIO, KVM_DEV_TYPE_ARM_PV_TIME etc.) support can be
> > checked via KVM_CREATE_DEVICE, which reports -ENODEV if the device
> > type doesn't have an entry in kvm_device_ops_table.
>
> If that's how we want to retroactively define things, then KVM should
> unconditionally return 1/true for KVM_CAP_DEVICE_CTRL since
> KVM_CREATE_DEVICE is provided by generic code.

Yes. Also, since we have KVM_DEV_TYPE_VFIO the generic use case, it should be better
to move the CAP check to the generic kvm_vm_ioctl_check_extension_generic.