vhost-vdpa: Expose ASID group change after DRIVER_OK via backend feature
Subsystems (6)
Dragos Tatulea
maintainerPATCH 1/1 vhost-vdpa: Expose ASID group change after DRIVER_OK via backend feature
The commit in the fixes tag blocked VHOST_VDPA_SET_GROUP_ASID operations once DRIVER_OK is set. That is too strict for devices which can safely handle this during live migration flows.
Bring back this behavior under a new vhost backend feature flag. The feature is supported by mlx5 and vdpa_sim devices.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 ++- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- drivers/vhost/vdpa.c | 13 +++++++++++-- include/uapi/linux/vhost_types.h | 4 ++++ 4 files changed, 19 insertions(+), 4 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -1
@@ -2906,7 +2906,8 @@ static void unregister_link_notifier(struct mlx5_vdpa_net *ndev)static u64 mlx5_vdpa_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int mlx5_vdpa_set_driver_features (struct vdpa_device *vdev,u64 features)
drivers/vdpa/vdpa_sim/vdpa_sim.c +2 -1
@@ -428,7 +428,8 @@ static u64 vdpasim_get_device_features(struct vdpa_device *vdpa)static u64 vdpasim_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int vdpasim_set_driver_features (struct vdpa_device *vdpa,u64 features)
drivers/vhost/vdpa.c +11 -2
@@ -682,7 +682,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,return -EFAULT ;if (idx >= vdpa->ngroups || s.num >= vdpa->nas)return -EINVAL ; -if (ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) +if ((ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) && + !vhost_backend_has_feature (vq,VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))return -EBUSY ;if (!ops->set_group_asid)return -EOPNOTSUPP ;
@@ -791,7 +792,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST ) |BIT_ULL (VHOST_BACKEND_F_SUSPEND ) |BIT_ULL (VHOST_BACKEND_F_RESUME ) | - BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK))) +BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | + BIT_ULL(VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK))) return -EOPNOTSUPP;if ((features &BIT_ULL (VHOST_BACKEND_F_SUSPEND )) && !vhost_vdpa_can_suspend (v))
@@ -805,6 +807,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,if ((features &BIT_ULL (VHOST_BACKEND_F_DESC_ASID )) && !vhost_vdpa_has_desc_group (v))return -EOPNOTSUPP ; +if (features &BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK )) { +if (!(features &BIT_ULL (VHOST_BACKEND_F_IOTLB_ASID ))) +return -EINVAL ; +if (!(vhost_vdpa_get_backend_features (v) & +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))) +return -EOPNOTSUPP ; + }if ((features &BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST )) && !vhost_vdpa_has_persistent_map (v))return -EOPNOTSUPP ;
include/uapi/linux/vhost_types.h +4 -0
@@ -197,5 +197,9 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_DESC_ASID 0x7/* IOTLB don't flush memory mapping across device reset */ #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 +/* Device supports changing the group ASID after DRIVER_OK. +* Requires VHOST_BACKEND_F_IOTLB_ASID. +*/ +#define VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK 0x9#endif
Signature · 1 line
2.54.0
Dragos Tatulea
maintainerQuoted 11 lines · Dragos Tatulea
The commit in the fixes tag blocked
VHOST_VDPA_SET_GROUP_ASIDoperations onceDRIVER_OKis set. That is too strict for devices which can safely handle this during live migration flows.Bring back this behavior under a new vhost backend feature flag. The feature is supported by mlx5 and
vdpa_simdevices.Fixes 3543b04a4ea3 ("vhost: forbid change vq groups ASID if DRIVER_OK is set")Signed-off-by Dragos Tatulea <[email protected]>Reviewed-by Shahar Shitrit <[email protected]>---
Gentle ping.
Thanks,
Dragos
Quoted 11 lines · Dragos Tatulea
The commit in the fixes tag blocked
VHOST_VDPA_SET_GROUP_ASIDoperations onceDRIVER_OKis set. That is too strict for devices which can safely handle this during live migration flows.Bring back this behavior under a new vhost backend feature flag. The feature is supported by mlx5 and
vdpa_simdevices.Fixes 3543b04a4ea3 ("vhost: forbid change vq groups ASID if DRIVER_OK is set")Signed-off-by Dragos Tatulea <[email protected]>Reviewed-by Shahar Shitrit <[email protected]>
Quoted 60 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 ++- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- drivers/vhost/vdpa.c | 13 +++++++++++-- include/uapi/linux/vhost_types.h | 4 ++++ 4 files changed, 19 insertions(+), 4 deletions(-)drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-1@@ -2906,7 +2906,8 @@ static void unregister_link_notifier(struct mlx5_vdpa_net *ndev)static u64 mlx5_vdpa_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int mlx5_vdpa_set_driver_features (struct vdpa_device *vdev,u64 features)drivers/vdpa/vdpa_sim/vdpa_sim.c +2
-1@@ -428,7 +428,8 @@ static u64 vdpasim_get_device_features(struct vdpa_device *vdpa)static u64 vdpasim_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int vdpasim_set_driver_features (struct vdpa_device *vdpa,u64 features)drivers/vhost/vdpa.c +4
-2@@ -682,7 +682,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,return -EFAULT ;if (idx >= vdpa->ngroups || s.num >= vdpa->nas)return -EINVAL ; -if (ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) +if ((ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) && + !vhost_backend_has_feature (vq,VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))return -EBUSY ;if (!ops->set_group_asid)return -EOPNOTSUPP ;@@ -791,7 +792,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST ) |BIT_ULL (VHOST_BACKEND_F_SUSPEND ) |BIT_ULL (VHOST_BACKEND_F_RESUME ) | - BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK))) +BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | + BIT_ULL(VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK))) return -EOPNOTSUPP;if ((features &BIT_ULL (VHOST_BACKEND_F_SUSPEND )) && !vhost_vdpa_can_suspend (v))
drivers/vhost/vdpa.c static long vhost_vdpa_unlocked_ioctl(struct file *filep, · line 809
Quoted 3 lines
drivers/vhost/vdpa.c +0
-0@@ -805,6 +807,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,if ((features &BIT_ULL (VHOST_BACKEND_F_DESC_ASID )) && !vhost_vdpa_has_desc_group (v))return -EOPNOTSUPP ;
Ouch to me here. By reading the errno manual:
Nit: By reading errno(3):
ENOTSUP - Operation not supported (POSIX.1-2001). EOPNOTSUPP - Operation not supported on socket (POSIX.1-2001).
I picked the wrong constant even if they share the same errno value (by the same page of the manual). MST, is it worth changing it?
Quoted 27 lines
drivers/vhost/vdpa.c +7
-0+if (features &BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK )) { +if (!(features &BIT_ULL (VHOST_BACKEND_F_IOTLB_ASID ))) +return -EINVAL ; +if (!(vhost_vdpa_get_backend_features (v) & +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))) +return -EOPNOTSUPP ; + }if ((features &BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST )) && !vhost_vdpa_has_persistent_map (v))return -EOPNOTSUPP ;include/uapi/linux/vhost_types.h +4
-1@@ -197,5 +197,9 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_DESC_ASID 0x7/* IOTLB don't flush memory mapping across device reset */ #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 +/* Device supports changing the group ASID after DRIVER_OK. +* Requires VHOST_BACKEND_F_IOTLB_ASID. +*/ +#define VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK 0x9#endif --2.54.0
Dragos Tatulea
maintainerQuoted 111 lines · Eugenio Perez Martin
Quoted 11 lines · Dragos Tatulea
The commit in the fixes tag blocked
VHOST_VDPA_SET_GROUP_ASIDoperations onceDRIVER_OKis set. That is too strict for devices which can safely handle this during live migration flows.Bring back this behavior under a new vhost backend feature flag. The feature is supported by mlx5 and
vdpa_simdevices.Fixes 3543b04a4ea3 ("vhost: forbid change vq groups ASID if DRIVER_OK is set")Signed-off-by Dragos Tatulea <[email protected]>Reviewed-by Shahar Shitrit <[email protected]>Acked-by Eugenio Pérez <[email protected]>Quoted 60 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 ++- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- drivers/vhost/vdpa.c | 13 +++++++++++-- include/uapi/linux/vhost_types.h | 4 ++++ 4 files changed, 19 insertions(+), 4 deletions(-)drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-1@@ -2906,7 +2906,8 @@ static void unregister_link_notifier(struct mlx5_vdpa_net *ndev)static u64 mlx5_vdpa_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int mlx5_vdpa_set_driver_features (struct vdpa_device *vdev,u64 features)drivers/vdpa/vdpa_sim/vdpa_sim.c +2
-1@@ -428,7 +428,8 @@ static u64 vdpasim_get_device_features(struct vdpa_device *vdpa)static u64 vdpasim_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int vdpasim_set_driver_features (struct vdpa_device *vdpa,u64 features)drivers/vhost/vdpa.c +4
-2@@ -682,7 +682,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,return -EFAULT ;if (idx >= vdpa->ngroups || s.num >= vdpa->nas)return -EINVAL ; -if (ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) +if ((ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) && + !vhost_backend_has_feature (vq,VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))return -EBUSY ;if (!ops->set_group_asid)return -EOPNOTSUPP ;@@ -791,7 +792,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST ) |BIT_ULL (VHOST_BACKEND_F_SUSPEND ) |BIT_ULL (VHOST_BACKEND_F_RESUME ) | - BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK))) +BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | + BIT_ULL(VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK))) return -EOPNOTSUPP;if ((features &BIT_ULL (VHOST_BACKEND_F_SUSPEND )) && !vhost_vdpa_can_suspend (v))drivers/vhost/vdpa.c static long vhost_vdpa_unlocked_ioctl(struct file *filep, · line 809
Quoted 3 lines
drivers/vhost/vdpa.c +0
-0@@ -805,6 +807,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,if ((features &BIT_ULL (VHOST_BACKEND_F_DESC_ASID )) && !vhost_vdpa_has_desc_group (v))return -EOPNOTSUPP ;Ouch to me here. By reading the errno manual:
Nit: By reading errno(3):
ENOTSUP - Operation not supported (POSIX.1-2001). EOPNOTSUPP - Operation not supported on socket (POSIX.1-2001).I picked the wrong constant even if they share the same errno value (by the same page of the manual). MST, is it worth changing it?
Quoted 23 lines
drivers/vhost/vdpa.c +7
-0+if (features &BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK )) { +if (!(features &BIT_ULL (VHOST_BACKEND_F_IOTLB_ASID ))) +return -EINVAL ; +if (!(vhost_vdpa_get_backend_features (v) & +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))) +return -EOPNOTSUPP ; + }if ((features &BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST )) && !vhost_vdpa_has_persistent_map (v))return -EOPNOTSUPP ;include/uapi/linux/vhost_types.h +4
-0@@ -197,5 +197,9 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_DESC_ASID 0x7/* IOTLB don't flush memory mapping across device reset */ #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 +/* Device supports changing the group ASID after DRIVER_OK. +* Requires VHOST_BACKEND_F_IOTLB_ASID. +*/ +#define VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK 0x9
Quoted 5 lines
Quoted 4 lines
include/uapi/linux/vhost_types.h +0
-1#endif --2.54.0
Gentle ping. Is this patch missing anything?
Thanks,
Dragos
Dragos Tatulea
maintainerQuoted 114 lines · Dragos Tatulea
Quoted 111 lines · Eugenio Perez Martin
Quoted 11 lines · Dragos Tatulea
The commit in the fixes tag blocked
VHOST_VDPA_SET_GROUP_ASIDoperations onceDRIVER_OKis set. That is too strict for devices which can safely handle this during live migration flows.Bring back this behavior under a new vhost backend feature flag. The feature is supported by mlx5 and
vdpa_simdevices.Fixes 3543b04a4ea3 ("vhost: forbid change vq groups ASID if DRIVER_OK is set")Signed-off-by Dragos Tatulea <[email protected]>Reviewed-by Shahar Shitrit <[email protected]>Acked-by Eugenio Pérez <[email protected]>Quoted 60 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 ++- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- drivers/vhost/vdpa.c | 13 +++++++++++-- include/uapi/linux/vhost_types.h | 4 ++++ 4 files changed, 19 insertions(+), 4 deletions(-)drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-1@@ -2906,7 +2906,8 @@ static void unregister_link_notifier(struct mlx5_vdpa_net *ndev)static u64 mlx5_vdpa_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int mlx5_vdpa_set_driver_features (struct vdpa_device *vdev,u64 features)drivers/vdpa/vdpa_sim/vdpa_sim.c +2
-1@@ -428,7 +428,8 @@ static u64 vdpasim_get_device_features(struct vdpa_device *vdpa)static u64 vdpasim_get_backend_features (const struct vdpa_device *vdpa) { -return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ); +return BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ); }static int vdpasim_set_driver_features (struct vdpa_device *vdpa,u64 features)drivers/vhost/vdpa.c +4
-2@@ -682,7 +682,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,return -EFAULT ;if (idx >= vdpa->ngroups || s.num >= vdpa->nas)return -EINVAL ; -if (ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) +if ((ops->get_status (vdpa) &VIRTIO_CONFIG_S_DRIVER_OK ) && + !vhost_backend_has_feature (vq,VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))return -EBUSY ;if (!ops->set_group_asid)return -EOPNOTSUPP ;@@ -791,7 +792,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST ) |BIT_ULL (VHOST_BACKEND_F_SUSPEND ) |BIT_ULL (VHOST_BACKEND_F_RESUME ) | - BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK))) +BIT_ULL (VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK ) | + BIT_ULL(VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK))) return -EOPNOTSUPP;if ((features &BIT_ULL (VHOST_BACKEND_F_SUSPEND )) && !vhost_vdpa_can_suspend (v))drivers/vhost/vdpa.c static long vhost_vdpa_unlocked_ioctl(struct file *filep, · line 809
Quoted 3 lines
drivers/vhost/vdpa.c +0
-0@@ -805,6 +807,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,if ((features &BIT_ULL (VHOST_BACKEND_F_DESC_ASID )) && !vhost_vdpa_has_desc_group (v))return -EOPNOTSUPP ;Ouch to me here. By reading the errno manual:
Nit: By reading errno(3):
ENOTSUP - Operation not supported (POSIX.1-2001). EOPNOTSUPP - Operation not supported on socket (POSIX.1-2001).I picked the wrong constant even if they share the same errno value (by the same page of the manual). MST, is it worth changing it?
Quoted 23 lines
drivers/vhost/vdpa.c +7
-0+if (features &BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK )) { +if (!(features &BIT_ULL (VHOST_BACKEND_F_IOTLB_ASID ))) +return -EINVAL ; +if (!(vhost_vdpa_get_backend_features (v) & +BIT_ULL (VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK ))) +return -EOPNOTSUPP ; + }if ((features &BIT_ULL (VHOST_BACKEND_F_IOTLB_PERSIST )) && !vhost_vdpa_has_persistent_map (v))return -EOPNOTSUPP ;include/uapi/linux/vhost_types.h +4
-0@@ -197,5 +197,9 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_DESC_ASID 0x7/* IOTLB don't flush memory mapping across device reset */ #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 +/* Device supports changing the group ASID after DRIVER_OK. +* Requires VHOST_BACKEND_F_IOTLB_ASID. +*/ +#define VHOST_BACKEND_F_GROUP_ASID_AFTER_DRIVER_OK 0x9
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
include/uapi/linux/vhost_types.h +0
-1#endif --2.54.0
Gentle ping. Is this patch missing anything?
One more ping.
Thanks,
Dragos