static int vhost_verify_ring_mappings(struct vhost_dev *dev,

                                      uint64_t start_addr,

                                      uint64_t size)

{

    int i, j;

    int r = 0;

    const char *part_name[] = {

        "descriptor table",

        "available ring",

        "used ring"

    };



    for (i = 0; i < dev->nvqs; ++i) {

        struct vhost_virtqueue *vq = dev->vqs + i;



        j = 0;

        r = vhost_verify_ring_part_mapping(vq->desc, vq->desc_phys,

                                           vq->desc_size, start_addr, size);

        if (!r) {

            break;

        }



        j++;

        r = vhost_verify_ring_part_mapping(vq->avail, vq->avail_phys,

                                           vq->avail_size, start_addr, size);

        if (!r) {

            break;

        }



        j++;

        r = vhost_verify_ring_part_mapping(vq->used, vq->used_phys,

                                           vq->used_size, start_addr, size);

        if (!r) {

            break;

        }

    }



    if (r == -ENOMEM) {

        error_report("Unable to map %s for ring %d", part_name[j], i);

    } else if (r == -EBUSY) {

        error_report("%s relocated for ring %d", part_name[j], i);

    }

    return r;

}

static int vhost_verify_ring_mappings(struct vhost_dev *dev,

                                      uint64_t start_addr,

                                      uint64_t size)

{

    int i, j;

    int r = 0;

    const char *part_name[] = {

        "descriptor table",

        "available ring",

        "used ring"

    };



    for (i = 0; i < dev->nvqs; ++i) {

        struct vhost_virtqueue *vq = dev->vqs + i;



        j = 0;

        r = vhost_verify_ring_part_mapping(vq->desc, vq->desc_phys,

                                           vq->desc_size, start_addr, size);

        if (!r) {

            break;

        }



        j++;

        r = vhost_verify_ring_part_mapping(vq->avail, vq->avail_phys,

                                           vq->avail_size, start_addr, size);

        if (!r) {

            break;

        }



        j++;

        r = vhost_verify_ring_part_mapping(vq->used, vq->used_phys,

                                           vq->used_size, start_addr, size);

        if (!r) {

            break;

        }

    }



    if (r == -ENOMEM) {

        error_report("Unable to map %s for ring %d", part_name[j], i);

    } else if (r == -EBUSY) {

        error_report("%s relocated for ring %d", part_name[j], i);

    }

    return r;

}

static int FUNC_0(struct vhost_dev *VAR_0,

                                      uint64_t VAR_1,

                                      uint64_t VAR_2)

{

    int VAR_3, VAR_4;

    int VAR_5 = 0;

    const char *VAR_6[] = {

        "descriptor table",

        "available ring",

        "used ring"

    };



    for (VAR_3 = 0; VAR_3 < VAR_0->nvqs; ++VAR_3) {

        struct vhost_virtqueue *VAR_7 = VAR_0->vqs + VAR_3;



        VAR_4 = 0;

        VAR_5 = vhost_verify_ring_part_mapping(VAR_7->desc, VAR_7->desc_phys,

                                           VAR_7->desc_size, VAR_1, VAR_2);

        if (!VAR_5) {

            break;

        }



        VAR_4++;

        VAR_5 = vhost_verify_ring_part_mapping(VAR_7->avail, VAR_7->avail_phys,

                                           VAR_7->avail_size, VAR_1, VAR_2);

        if (!VAR_5) {

            break;

        }



        VAR_4++;

        VAR_5 = vhost_verify_ring_part_mapping(VAR_7->used, VAR_7->used_phys,

                                           VAR_7->used_size, VAR_1, VAR_2);

        if (!VAR_5) {

            break;

        }

    }



    if (VAR_5 == -ENOMEM) {

        error_report("Unable to map %s for ring %d", VAR_6[VAR_4], VAR_3);

    } else if (VAR_5 == -EBUSY) {

        error_report("%s relocated for ring %d", VAR_6[VAR_4], VAR_3);

    }

    return VAR_5;

}

static int FUNC_0(struct vhost_dev *VAR_0,
uint64_t VAR_1,
uint64_t VAR_2)
{ int VAR_3, VAR_4; int VAR_5 = 0; const char *VAR_6[] = { "descriptor table",
"available ring",
"used ring"
}; for (VAR_3 = 0; VAR_3 < VAR_0->nvqs; ++VAR_3) { struct vhost_virtqueue *VAR_7 = VAR_0->vqs + VAR_3; VAR_4 = 0; VAR_5 = vhost_verify_ring_part_mapping(VAR_7->desc, VAR_7->desc_phys,
VAR_7->desc_size, VAR_1, VAR_2); if (!VAR_5) { break; } VAR_4++; VAR_5 = vhost_verify_ring_part_mapping(VAR_7->avail, VAR_7->avail_phys,
VAR_7->avail_size, VAR_1, VAR_2); if (!VAR_5) { break; } VAR_4++; VAR_5 = vhost_verify_ring_part_mapping(VAR_7->used, VAR_7->used_phys,
VAR_7->used_size, VAR_1, VAR_2); if (!VAR_5) { break; } } if (VAR_5 == -ENOMEM) { error_report("Unable to map %s for ring %d", VAR_6[VAR_4], VAR_3); } else if (VAR_5 == -EBUSY) { error_report("%s relocated for ring %d", VAR_6[VAR_4], VAR_3); } return VAR_5; }