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

Re: [Xen-devel] [PATCH XEN v5 14/23] tools: foreignmemory: provide xenforeignmemory_unmap.



On 09/11/15 12:00, Ian Campbell wrote:
> diff --git a/tools/libs/foreignmemory/linux.c 
> b/tools/libs/foreignmemory/linux.c
> index 01cd42e..86a5a97 100644
> --- a/tools/libs/foreignmemory/linux.c
> +++ b/tools/libs/foreignmemory/linux.c
> @@ -276,6 +276,12 @@ void *xenforeignmemory_map(xenforeignmemory_handle *fmem,
>      return addr;
>  }
>  
> +int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
> +                           void *addr, unsigned int num)
> +{
> +    return munmap(addr, (unsigned long)num << PAGE_SHIFT);

This should be size_t to match the type expected by munmap()

> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/tools/libs/foreignmemory/minios.c 
> b/tools/libs/foreignmemory/minios.c
> index 981d801..dbb152f 100644
> --- a/tools/libs/foreignmemory/minios.c
> +++ b/tools/libs/foreignmemory/minios.c
> @@ -51,6 +51,12 @@ void *xenforeignmemory_map(xenforeignmemory_handle *fmem,
>      return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot);
>  }
>  
> +int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
> +                           void *addr, unsigned int num)
> +{
> +     return munmap(addr, num << PAGE_SHIFT);

This num (and freebsd/netbsd/solaris) needs upcasting before
multiplication, to avoid loosing the top 12 bits on 64bit platforms.

~Andrew

_______________________________________________
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®.