Skip to content

Commit be12ad4

Browse files
shamiali2008Alex Williamson
authored andcommitted
hisi_acc_vfio_pci: Update migration data pointer correctly on saving/resume
When the optional PRE_COPY support was added to speed up the device compatibility check, it failed to update the saving/resuming data pointers based on the fd offset. This results in migration data corruption and when the device gets started on the destination the following error is reported in some cases, [ 478.907684] arm-smmu-v3 arm-smmu-v3.2.auto: event 0x10 received: [ 478.913691] arm-smmu-v3 arm-smmu-v3.2.auto: 0x0000310200000010 [ 478.919603] arm-smmu-v3 arm-smmu-v3.2.auto: 0x000002088000007f [ 478.925515] arm-smmu-v3 arm-smmu-v3.2.auto: 0x0000000000000000 [ 478.931425] arm-smmu-v3 arm-smmu-v3.2.auto: 0x0000000000000000 [ 478.947552] hisi_zip 0000:31:00.0: qm_axi_rresp [error status=0x1] found [ 478.955930] hisi_zip 0000:31:00.0: qm_db_timeout [error status=0x400] found [ 478.955944] hisi_zip 0000:31:00.0: qm sq doorbell timeout in function 2 Fixes: d9a871e ("hisi_acc_vfio_pci: Introduce support for PRE_COPY state transitions") Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20231120091406.780-1-shameerali.kolothum.thodi@huawei.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent daca194 commit be12ad4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu
694694
size_t len, loff_t *pos)
695695
{
696696
struct hisi_acc_vf_migration_file *migf = filp->private_data;
697+
u8 *vf_data = (u8 *)&migf->vf_data;
697698
loff_t requested_length;
698699
ssize_t done = 0;
699700
int ret;
@@ -715,7 +716,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu
715716
goto out_unlock;
716717
}
717718

718-
ret = copy_from_user(&migf->vf_data, buf, len);
719+
ret = copy_from_user(vf_data + *pos, buf, len);
719720
if (ret) {
720721
done = -EFAULT;
721722
goto out_unlock;
@@ -835,7 +836,9 @@ static ssize_t hisi_acc_vf_save_read(struct file *filp, char __user *buf, size_t
835836

836837
len = min_t(size_t, migf->total_length - *pos, len);
837838
if (len) {
838-
ret = copy_to_user(buf, &migf->vf_data, len);
839+
u8 *vf_data = (u8 *)&migf->vf_data;
840+
841+
ret = copy_to_user(buf, vf_data + *pos, len);
839842
if (ret) {
840843
done = -EFAULT;
841844
goto out_unlock;

0 commit comments

Comments
 (0)