diff mbox

libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range()

Message ID 1508258793-5690-4-git-send-email-bhupinder.thakur@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Bhupinder Thakur Oct. 17, 2017, 4:46 p.m. UTC
Currently the data type of mfn paramter passed to xc_map_foreign_range() is unsigned
long. This could be problem for 32-bit arm architectures where the lengh of long is
32 bits while mfn happens to be a 64-bit value.

To avoid truncating a 64-bit value, the type of mfn is changed from "unsigned long" to
xen_pfn_t. Also the parameter name "mfn" is changed to "pfn" which is a more accurate
indication of what this parameter represents.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

 tools/libxc/include/xenctrl_compat.h | 2 +-
 tools/libxc/xc_foreign_memory.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Wei Liu Oct. 18, 2017, 11:52 a.m. UTC | #1
I appear to receive this series out of order.

This one appears in my inbox later then "xenconsole: Change the type of
ring_ref to xen_pfn_t in console_create_ring", which at a glance depends
on this one.

Please resend this series with proper numbering.

On Tue, Oct 17, 2017 at 10:16:32PM +0530, Bhupinder Thakur wrote:
> Currently the data type of mfn paramter passed to xc_map_foreign_range() is unsigned
> long. This could be problem for 32-bit arm architectures where the lengh of long is
> 32 bits while mfn happens to be a 64-bit value.
> 
> To avoid truncating a 64-bit value, the type of mfn is changed from "unsigned long" to
> xen_pfn_t. Also the parameter name "mfn" is changed to "pfn" which is a more accurate
> indication of what this parameter represents.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> 
>  tools/libxc/include/xenctrl_compat.h | 2 +-
>  tools/libxc/xc_foreign_memory.c      | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libxc/include/xenctrl_compat.h
> index a655e47..5ee72bf 100644
> --- a/tools/libxc/include/xenctrl_compat.h
> +++ b/tools/libxc/include/xenctrl_compat.h
> @@ -26,7 +26,7 @@
>   */
>  void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
>                              int size, int prot,
> -                            unsigned long mfn );
> +                            xen_pfn_t pfn);
>  
>  void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
>                             const xen_pfn_t *arr, int num );
> diff --git a/tools/libxc/xc_foreign_memory.c b/tools/libxc/xc_foreign_memory.c
> index 4053d26..c1f114a 100644
> --- a/tools/libxc/xc_foreign_memory.c
> +++ b/tools/libxc/xc_foreign_memory.c
> @@ -33,7 +33,7 @@ void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
>  
>  void *xc_map_foreign_range(xc_interface *xch,
>                             uint32_t dom, int size, int prot,
> -                           unsigned long mfn)
> +                           xen_pfn_t pfn)
>  {
>      xen_pfn_t *arr;
>      int num;
> @@ -46,7 +46,7 @@ void *xc_map_foreign_range(xc_interface *xch,
>          return NULL;
>  
>      for ( i = 0; i < num; i++ )
> -        arr[i] = mfn + i;
> +        arr[i] = pfn + i;
>  
>      ret = xc_map_foreign_pages(xch, dom, prot, arr, num);
>      free(arr);
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libxc/include/xenctrl_compat.h
index a655e47..5ee72bf 100644
--- a/tools/libxc/include/xenctrl_compat.h
+++ b/tools/libxc/include/xenctrl_compat.h
@@ -26,7 +26,7 @@ 
  */
 void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
                             int size, int prot,
-                            unsigned long mfn );
+                            xen_pfn_t pfn);
 
 void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
                            const xen_pfn_t *arr, int num );
diff --git a/tools/libxc/xc_foreign_memory.c b/tools/libxc/xc_foreign_memory.c
index 4053d26..c1f114a 100644
--- a/tools/libxc/xc_foreign_memory.c
+++ b/tools/libxc/xc_foreign_memory.c
@@ -33,7 +33,7 @@  void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
 
 void *xc_map_foreign_range(xc_interface *xch,
                            uint32_t dom, int size, int prot,
-                           unsigned long mfn)
+                           xen_pfn_t pfn)
 {
     xen_pfn_t *arr;
     int num;
@@ -46,7 +46,7 @@  void *xc_map_foreign_range(xc_interface *xch,
         return NULL;
 
     for ( i = 0; i < num; i++ )
-        arr[i] = mfn + i;
+        arr[i] = pfn + i;
 
     ret = xc_map_foreign_pages(xch, dom, prot, arr, num);
     free(arr);