Skip to content

Commit b923826

Browse files
wanghaibin-mousechazy
authored andcommitted
KVM: arm/arm64: vgic-its: Fix return value for device table restore
If ITT only contains invalid entries, vgic_its_restore_itt returns 1 and this is considered as an an error in vgic_its_restore_dte. Also in case the device table only contains invalid entries, the table restore fails and this is not correct. This patch fixes those 2 issues: - vgic_its_restore_itt now returns <= 0 values. If all ITEs are invalid, this is considered as successful. - vgic_its_restore_device_tables also returns <= 0 values. We also simplify the returned value computation in handle_l1_dte. Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com> Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
1 parent f9b269f commit b923826

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

virt/kvm/arm/vgic/vgic-its.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,14 @@ static int vgic_its_save_itt(struct vgic_its *its, struct its_device *device)
19361936
return 0;
19371937
}
19381938

1939+
/**
1940+
* vgic_its_restore_itt - restore the ITT of a device
1941+
*
1942+
* @its: its handle
1943+
* @dev: device handle
1944+
*
1945+
* Return 0 on success, < 0 on error
1946+
*/
19391947
static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev)
19401948
{
19411949
const struct vgic_its_abi *abi = vgic_its_get_abi(its);
@@ -1947,6 +1955,10 @@ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev)
19471955
ret = scan_its_table(its, base, max_size, ite_esz, 0,
19481956
vgic_its_restore_ite, dev);
19491957

1958+
/* scan_its_table returns +1 if all ITEs are invalid */
1959+
if (ret > 0)
1960+
ret = 0;
1961+
19501962
return ret;
19511963
}
19521964

@@ -2103,10 +2115,7 @@ static int handle_l1_dte(struct vgic_its *its, u32 id, void *addr,
21032115
ret = scan_its_table(its, gpa, SZ_64K, dte_esz,
21042116
l2_start_id, vgic_its_restore_dte, NULL);
21052117

2106-
if (ret <= 0)
2107-
return ret;
2108-
2109-
return 1;
2118+
return ret;
21102119
}
21112120

21122121
/**
@@ -2136,8 +2145,9 @@ static int vgic_its_restore_device_tables(struct vgic_its *its)
21362145
vgic_its_restore_dte, NULL);
21372146
}
21382147

2148+
/* scan_its_table returns +1 if all entries are invalid */
21392149
if (ret > 0)
2140-
ret = -EINVAL;
2150+
ret = 0;
21412151

21422152
return ret;
21432153
}

0 commit comments

Comments
 (0)