NVIDIA: SAUCE: hw/vfio: thread vf-token through iommufd bind - #38
NVIDIA: SAUCE: hw/vfio: thread vf-token through iommufd bind#38tdavenvidia wants to merge 1 commit into
Conversation
|
Please help review. |
BaseOS Kernel ReviewWarning
|
|
Were you seeing -EINVAL returned? Codex states it should be -EACCES instead: Nits:
|
shamiali2008
left a comment
There was a problem hiding this comment.
I think you can use VFIOPCIDevice *vdev = vfio_pci_from_vfio_device(vbasedev);
Also should we add a check for guarding mdev here? I think a PCI mdev is still type VFIO_DEVICE_TYPE_PCI. Something like below;
VFIOPCIDevice *vdev = vfio_pci_from_vfio_device(vbasedev);
...
if ( !vbasedev->mdev && vdev && !qemu_uuid_is_null(&vdev->vf_token)) {
.....
}
I do have a concern that this patch will cause a regression on mainline kernels < 6.17 where support for vf_token was not there. As Matt mentioned the return error value you mentioned in commit log may change as well based on kernel version I think. The regression concern may not be that relevant for downstream but if you plan to send this to upstream, please check that.
|
I pushed the changes that addresses you review comments, please take a look. With an older host kernel that does not support VF token binding, a QEMU launch using vf-token will fail during the device bind. The host kernel may report an error in the kernel log, but that diagnostic is internal to the kernel and does not require any additional handling/mention in QEMU. |
332e462 to
20ab74a
Compare
|
Thanks Tushar, no further issues from me.
|
Yeah. QEMU previously never used vf-token in IOMMUFD cases. So if someone has a <6.17 host kernel and used vf-token in their command line(or libvirt), it used to work. But if they do a QEMU binary update their VM launch will now fail. For eg: On a 6.14.0-1015-nvidia-64k host kernel: Not 100% sure this falls under "regression" or not. But something to be aware while upstream. |
|
I don't think that boro review on vfio_pci_from_vfio_device() stands as it is already used in the same file. Anyway please double check. Acked-by: Shameer Kolothum [email protected] |
BORO review
That is correct. I saw same. The "regression" in this commit means that while kernel iommufd path "re-added" the vf-token, the qemu left without it, causing VM launch fail with vf-token passed! |
I agree. the same function is used in this file. |
A VF fails to bind through the iommufd/cdev backend when its PF is bound to vfio-pci and requires a matching VF token. QEMU currently initializes struct vfio_device_bind_iommufd without the token flag or token UUID. Pass the existing vf-token device property to the IOMMUFD bind ioctl for PCI devices. Signed-off-by: Tushar Dave <[email protected]>
20ab74a to
59ef90a
Compare
|
I updated commit description - should have not call this regression. Take a look. |
MitchellAugustin
left a comment
There was a problem hiding this comment.
Thanks @tdavenvidia @nvmochs !
This patch looks correct to me. However, it seems like it is probably generally applicable beyond NVIDIA hardware. Has it also been submitted upstream? If so, please include a Link: to the upstream mailing list thread in the commit so we can track the provenance here.
|
LGTM, and ran a successful test build. +1 on @MitchellAugustin's comment.
|
I will be sending this upstream. |
A VF fails to bind through the iommufd/cdev backend when its PF is bound to vfio-pci and requires a matching VF token.
QEMU currently initializes struct vfio_device_bind_iommufd without the token flag or token UUID.
Pass the existing vf-token device property to the IOMMUFD bind ioctl for PCI devices.