static unsigned virtqueue_read_next_desc(VirtIODevice *vdev, VRingDesc *desc,

                                         hwaddr desc_pa, unsigned int max)

{

    unsigned int next;



    /* If this descriptor says it doesn't chain, we're done. */

    if (!(desc->flags & VRING_DESC_F_NEXT)) {

        return max;

    }



    /* Check they're not leading us off end of descriptors. */

    next = desc->next;

    /* Make sure compiler knows to grab that: we don't want it changing! */

    smp_wmb();



    if (next >= max) {

        error_report("Desc next is %u", next);

        exit(1);

    }



    vring_desc_read(vdev, desc, desc_pa, next);

    return next;

}

static unsigned virtqueue_read_next_desc(VirtIODevice *vdev, VRingDesc *desc,

                                         hwaddr desc_pa, unsigned int max)

{

    unsigned int next;



    

    if (!(desc->flags & VRING_DESC_F_NEXT)) {

        return max;

    }



    

    next = desc->next;

    

    smp_wmb();



    if (next >= max) {

        error_report("Desc next is %u", next);

        exit(1);

    }



    vring_desc_read(vdev, desc, desc_pa, next);

    return next;

}

static unsigned FUNC_0(VirtIODevice *VAR_0, VRingDesc *VAR_1,

                                         hwaddr VAR_2, unsigned int VAR_3)

{

    unsigned int VAR_4;



    

    if (!(VAR_1->flags & VRING_DESC_F_NEXT)) {

        return VAR_3;

    }



    

    VAR_4 = VAR_1->VAR_4;

    

    smp_wmb();



    if (VAR_4 >= VAR_3) {

        error_report("Desc VAR_4 is %u", VAR_4);

        exit(1);

    }



    vring_desc_read(VAR_0, VAR_1, VAR_2, VAR_4);

    return VAR_4;

}

static unsigned FUNC_0(VirtIODevice *VAR_0, VRingDesc *VAR_1,
hwaddr VAR_2, unsigned int VAR_3)
{ unsigned int VAR_4; if (!(VAR_1->flags & VRING_DESC_F_NEXT)) { return VAR_3; } VAR_4 = VAR_1->VAR_4; smp_wmb(); if (VAR_4 >= VAR_3) { error_report("Desc VAR_4 is %u", VAR_4); exit(1); } vring_desc_read(VAR_0, VAR_1, VAR_2, VAR_4); return VAR_4; }