[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory



>>> On 08.05.15 at 16:34, <roger.pau@xxxxxxxxxx> wrote:
> +void vfree(void *va)
> +{
> +    unsigned int i, pages = vm_size(va);
> +
> +    if ( pages == 0 )
> +        return;
> +
> +    for ( i = 0; i < pages; i++ )
> +        free_domheap_pages(vmap_to_page(va + i * PAGE_SIZE), 1);
> +
> +    vunmap(va);
> +}

There actually is another problem here: You must not free the
pages before having torn down the mapping. An option (to
avoid the need for a memory allocation) might be to zap the
present bits (or whatever their equivalent on ARM) in a first
pass (making sure to flush TLBs), free, and then vunmap().

And you would of course better use the single page shortcut
macros of the domheap allocation/free functions.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.