Skip to content

Commit f85efa9

Browse files
stefano-garzarellamstsirkin
authored andcommitted
vringh: fix range used in iotlb_translate()
vhost_iotlb_itree_first() requires `start` and `last` parameters to search for a mapping that overlaps the range. In iotlb_translate() we cyclically call vhost_iotlb_itree_first(), incrementing `addr` by the amount already translated, so rightly we move the `start` parameter passed to vhost_iotlb_itree_first(), but we should hold the `last` parameter constant. Let's fix it by saving the `last` parameter value before incrementing `addr` in the loop. Fixes: 9ad9c49 ("vringh: IOTLB support") Acked-by: Jason Wang <[email protected]> Signed-off-by: Stefano Garzarella <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 7a4efe1 commit f85efa9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/vhost/vringh.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ static int iotlb_translate(const struct vringh *vrh,
11021102
struct vhost_iotlb_map *map;
11031103
struct vhost_iotlb *iotlb = vrh->iotlb;
11041104
int ret = 0;
1105-
u64 s = 0;
1105+
u64 s = 0, last = addr + len - 1;
11061106

11071107
spin_lock(vrh->iotlb_lock);
11081108

@@ -1114,8 +1114,7 @@ static int iotlb_translate(const struct vringh *vrh,
11141114
break;
11151115
}
11161116

1117-
map = vhost_iotlb_itree_first(iotlb, addr,
1118-
addr + len - 1);
1117+
map = vhost_iotlb_itree_first(iotlb, addr, last);
11191118
if (!map || map->start > addr) {
11201119
ret = -EINVAL;
11211120
break;

0 commit comments

Comments
 (0)