Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfio: Add support for VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2

Currently, existing VFIO_MIG_GET_PRECOPY_INFO implementations don't
assign info.flags before copy_to_user().

Because they copy the struct in from userspace first, this effectively
echoes userspace-provided flags back as output, preventing the field
from being used to report new reliable data from the drivers.

Add support for a new device feature named
VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2.

On SET, enables the v2 pre_copy_info behaviour, where the
vfio_precopy_info.flags is a valid output field.

Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/20260317161753.18964-3-yishaih@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Yishai Hadas and committed by
Alex Williamson
50ff3f40 d7140b5d

+22
+21
drivers/vfio/vfio_main.c
··· 553 553 vfio_df_iommufd_unbind(df); 554 554 else 555 555 vfio_device_group_unuse_iommu(device); 556 + device->precopy_info_v2 = 0; 556 557 module_put(device->dev->driver->owner); 557 558 } 558 559 ··· 965 964 return 0; 966 965 } 967 966 967 + static int 968 + vfio_ioctl_device_feature_migration_precopy_info_v2(struct vfio_device *device, 969 + u32 flags, size_t argsz) 970 + { 971 + int ret; 972 + 973 + if (!(device->migration_flags & VFIO_MIGRATION_PRE_COPY)) 974 + return -EINVAL; 975 + 976 + ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_SET, 0); 977 + if (ret != 1) 978 + return ret; 979 + 980 + device->precopy_info_v2 = 1; 981 + return 0; 982 + } 983 + 968 984 static int vfio_ioctl_device_feature_migration(struct vfio_device *device, 969 985 u32 flags, void __user *arg, 970 986 size_t argsz) ··· 1269 1251 return vfio_ioctl_device_feature_migration_data_size( 1270 1252 device, feature.flags, arg->data, 1271 1253 feature.argsz - minsz); 1254 + case VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2: 1255 + return vfio_ioctl_device_feature_migration_precopy_info_v2( 1256 + device, feature.flags, feature.argsz - minsz); 1272 1257 default: 1273 1258 if (unlikely(!device->ops->device_feature)) 1274 1259 return -ENOTTY;
+1
include/linux/vfio.h
··· 52 52 struct vfio_device_set *dev_set; 53 53 struct list_head dev_set_list; 54 54 unsigned int migration_flags; 55 + u8 precopy_info_v2; 55 56 struct kvm *kvm; 56 57 57 58 /* Members below here are private, not for driver use */