Skip to content

Commit

Permalink
tools/lguest: handle indirect partway through chain.
Browse files Browse the repository at this point in the history
Linux doesn't generate these, but it's perfectly valid according to
a close reading of the spec.  I opened virtio spec bug VIRTIO-134 to
make this clearer there, too.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Feb 13, 2015
1 parent c97eb67 commit 3afe3e0
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tools/lguest/lguest.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,20 +769,21 @@ static unsigned wait_for_vq_desc(struct virtqueue *vq,
* that: no rmb() required.
*/

/*
* If this is an indirect entry, then this buffer contains a descriptor
* table which we handle as if it's any normal descriptor chain.
*/
if (desc[i].flags & VRING_DESC_F_INDIRECT) {
if (desc[i].len % sizeof(struct vring_desc))
errx(1, "Invalid size for indirect buffer table");
do {
/*
* If this is an indirect entry, then this buffer contains a
* descriptor table which we handle as if it's any normal
* descriptor chain.
*/
if (desc[i].flags & VRING_DESC_F_INDIRECT) {
if (desc[i].len % sizeof(struct vring_desc))
errx(1, "Invalid size for indirect buffer table");

max = desc[i].len / sizeof(struct vring_desc);
desc = check_pointer(desc[i].addr, desc[i].len);
i = 0;
}
max = desc[i].len / sizeof(struct vring_desc);
desc = check_pointer(desc[i].addr, desc[i].len);
i = 0;
}

do {
/* Grab the first descriptor, and check it's OK. */
iov[*out_num + *in_num].iov_len = desc[i].len;
iov[*out_num + *in_num].iov_base
Expand Down

0 comments on commit 3afe3e0

Please sign in to comment.