static void xen_remap_bucket(MapCacheEntry *entry,

                             hwaddr size,

                             hwaddr address_index)

{

    uint8_t *vaddr_base;

    xen_pfn_t *pfns;

    int *err;

    unsigned int i;

    hwaddr nb_pfn = size >> XC_PAGE_SHIFT;



    trace_xen_remap_bucket(address_index);



    pfns = g_malloc0(nb_pfn * sizeof (xen_pfn_t));

    err = g_malloc0(nb_pfn * sizeof (int));



    if (entry->vaddr_base != NULL) {

        if (munmap(entry->vaddr_base, entry->size) != 0) {

            perror("unmap fails");

            exit(-1);

        }

    }

    g_free(entry->valid_mapping);

    entry->valid_mapping = NULL;



    for (i = 0; i < nb_pfn; i++) {

        pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;

    }



    vaddr_base = xc_map_foreign_bulk(xen_xc, xen_domid, PROT_READ|PROT_WRITE,

                                     pfns, err, nb_pfn);

    if (vaddr_base == NULL) {

        perror("xc_map_foreign_bulk");

        exit(-1);

    }



    entry->vaddr_base = vaddr_base;

    entry->paddr_index = address_index;

    entry->size = size;

    entry->valid_mapping = (unsigned long *) g_malloc0(sizeof(unsigned long) *

            BITS_TO_LONGS(size >> XC_PAGE_SHIFT));



    bitmap_zero(entry->valid_mapping, nb_pfn);

    for (i = 0; i < nb_pfn; i++) {

        if (!err[i]) {

            bitmap_set(entry->valid_mapping, i, 1);

        }

    }



    g_free(pfns);

    g_free(err);

}

static void xen_remap_bucket(MapCacheEntry *entry,

                             hwaddr size,

                             hwaddr address_index)

{

    uint8_t *vaddr_base;

    xen_pfn_t *pfns;

    int *err;

    unsigned int i;

    hwaddr nb_pfn = size >> XC_PAGE_SHIFT;



    trace_xen_remap_bucket(address_index);



    pfns = g_malloc0(nb_pfn * sizeof (xen_pfn_t));

    err = g_malloc0(nb_pfn * sizeof (int));



    if (entry->vaddr_base != NULL) {

        if (munmap(entry->vaddr_base, entry->size) != 0) {

            perror("unmap fails");

            exit(-1);

        }

    }

    g_free(entry->valid_mapping);

    entry->valid_mapping = NULL;



    for (i = 0; i < nb_pfn; i++) {

        pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;

    }



    vaddr_base = xc_map_foreign_bulk(xen_xc, xen_domid, PROT_READ|PROT_WRITE,

                                     pfns, err, nb_pfn);

    if (vaddr_base == NULL) {

        perror("xc_map_foreign_bulk");

        exit(-1);

    }



    entry->vaddr_base = vaddr_base;

    entry->paddr_index = address_index;

    entry->size = size;

    entry->valid_mapping = (unsigned long *) g_malloc0(sizeof(unsigned long) *

            BITS_TO_LONGS(size >> XC_PAGE_SHIFT));



    bitmap_zero(entry->valid_mapping, nb_pfn);

    for (i = 0; i < nb_pfn; i++) {

        if (!err[i]) {

            bitmap_set(entry->valid_mapping, i, 1);

        }

    }



    g_free(pfns);

    g_free(err);

}

    vaddr_base = xc_map_foreign_bulk(xen_xc, xen_domid, PROT_READ|PROT_WRITE,                                      pfns, err, nb_pfn);         perror("xc_map_foreign_bulk");
static void FUNC_0(MapCacheEntry *VAR_0,

                             hwaddr VAR_1,

                             hwaddr VAR_2)

{

    uint8_t *vaddr_base;

    xen_pfn_t *pfns;

    int *VAR_3;

    unsigned int VAR_4;

    hwaddr nb_pfn = VAR_1 >> XC_PAGE_SHIFT;



    trace_xen_remap_bucket(VAR_2);



    pfns = g_malloc0(nb_pfn * sizeof (xen_pfn_t));

    VAR_3 = g_malloc0(nb_pfn * sizeof (int));



    if (VAR_0->vaddr_base != NULL) {

        if (munmap(VAR_0->vaddr_base, VAR_0->VAR_1) != 0) {

            perror("unmap fails");

            exit(-1);

        }

    }

    g_free(VAR_0->valid_mapping);

    VAR_0->valid_mapping = NULL;



    for (VAR_4 = 0; VAR_4 < nb_pfn; VAR_4++) {

        pfns[VAR_4] = (VAR_2 << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + VAR_4;

    }



    vaddr_base = xc_map_foreign_bulk(xen_xc, xen_domid, PROT_READ|PROT_WRITE,

                                     pfns, VAR_3, nb_pfn);

    if (vaddr_base == NULL) {

        perror("xc_map_foreign_bulk");

        exit(-1);

    }



    VAR_0->vaddr_base = vaddr_base;

    VAR_0->paddr_index = VAR_2;

    VAR_0->VAR_1 = VAR_1;

    VAR_0->valid_mapping = (unsigned long *) g_malloc0(sizeof(unsigned long) *

            BITS_TO_LONGS(VAR_1 >> XC_PAGE_SHIFT));



    bitmap_zero(VAR_0->valid_mapping, nb_pfn);

    for (VAR_4 = 0; VAR_4 < nb_pfn; VAR_4++) {

        if (!VAR_3[VAR_4]) {

            bitmap_set(VAR_0->valid_mapping, VAR_4, 1);

        }

    }



    g_free(pfns);

    g_free(VAR_3);

}

static void FUNC_0(MapCacheEntry *VAR_0,
hwaddr VAR_1,
hwaddr VAR_2)
{ uint8_t *vaddr_base; xen_pfn_t *pfns; int *VAR_3; unsigned int VAR_4; hwaddr nb_pfn = VAR_1 >> XC_PAGE_SHIFT; trace_xen_remap_bucket(VAR_2); pfns = g_malloc0(nb_pfn * sizeof (xen_pfn_t)); VAR_3 = g_malloc0(nb_pfn * sizeof (int)); if (VAR_0->vaddr_base != NULL) { if (munmap(VAR_0->vaddr_base, VAR_0->VAR_1) != 0) { perror("unmap fails"); exit(-1); } } g_free(VAR_0->valid_mapping); VAR_0->valid_mapping = NULL; for (VAR_4 = 0; VAR_4 < nb_pfn; VAR_4++) { pfns[VAR_4] = (VAR_2 << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + VAR_4; } vaddr_base = xc_map_foreign_bulk(xen_xc, xen_domid, PROT_READ|PROT_WRITE,
pfns, VAR_3, nb_pfn); if (vaddr_base == NULL) { perror("xc_map_foreign_bulk"); exit(-1); } VAR_0->vaddr_base = vaddr_base; VAR_0->paddr_index = VAR_2; VAR_0->VAR_1 = VAR_1; VAR_0->valid_mapping = (unsigned long *) g_malloc0(sizeof(unsigned long) *
BITS_TO_LONGS(VAR_1 >> XC_PAGE_SHIFT)); bitmap_zero(VAR_0->valid_mapping, nb_pfn); for (VAR_4 = 0; VAR_4 < nb_pfn; VAR_4++) { if (!VAR_3[VAR_4]) { bitmap_set(VAR_0->valid_mapping, VAR_4, 1); } } g_free(pfns); g_free(VAR_3); }