Skip to contentSkip to conversation

xen/arm: grant-table: Correct the prototype of the arch helpers

PATCH In review Julien Grall 4 participants 6 messages Jun 29, 2023 – Jul 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: grant-table: Correct the prototype of the arch helpers

From: Julien Grall <[email protected]>

Both the stub and the x86 prototypes for replace_grant_host_mapping() and create_grant_host_mapping() will define the first parameter (and third for the former) as uint64_t. Yet Arm will define it as 'unsigned long'.

While there are no differences for 64-bit, for 32-bit it means that the address should be truncated as 32-bit guest could support up to 40-bit addresses.

So replace 'unsigned long' with 'uint64_t' for the first parameter (and third parameter for replace_grant_host_mapping()).

---

---
 xen/arch/arm/include/asm/grant_table.h | 6 +++---
 xen/arch/arm/mm.c                      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/include/asm/grant_table.h +3 -3
index f2d115b97d8b..d3c518a926b9 100644
@@ -36,10 +36,10 @@ static inline bool gnttab_release_host_mappings(const struct domain *d)
     return true;
 }
 
-int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                               unsigned int flags, unsigned int cache_flags);
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int flags);
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags);
 
 /*
  * The region used by Xen on the memory will never be mapped in DOM0
xen/arch/arm/mm.c +3 -3
index 0a3e1f3b64b6..53773368d036 100644
@@ -1579,7 +1579,7 @@ void put_page_type(struct page_info *page)
     return;
 }
 
-int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                               unsigned int flags, unsigned int cache_flags)
 {
     int rc;
@@ -1600,8 +1600,8 @@ int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
         return GNTST_okay;
 }
 
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int flags)
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags)
 {
     gfn_t gfn = gaddr_to_gfn(gpaddr);
     struct domain *d = current->domain;
Signature · 1 line
2.40.1
#1 lore raw

Sorry I forgot to CC Bertrand and Stefano.

Quoted 65 lines · Julien Grall

From: Julien Grall <[email protected]>

Both the stub and the x86 prototypes for replace_grant_host_mapping() and create_grant_host_mapping() will define the first parameter (and third for the former) as uint64_t. Yet Arm will define it as 'unsigned long'.

While there are no differences for 64-bit, for 32-bit it means that the address should be truncated as 32-bit guest could support up to 40-bit addresses.

So replace 'unsigned long' with 'uint64_t' for the first parameter (and third parameter for replace_grant_host_mapping()).

---

---
  xen/arch/arm/include/asm/grant_table.h | 6 +++---
  xen/arch/arm/mm.c                      | 6 +++---
  2 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/include/asm/grant_table.h +3 -3
index f2d115b97d8b..d3c518a926b9 100644
@@ -36,10 +36,10 @@ static inline bool gnttab_release_host_mappings(const struct domain *d)
      return true;
  }
 
-int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                                unsigned int flags, unsigned int cache_flags);
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int flags);
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags);
 
  /*
   * The region used by Xen on the memory will never be mapped in DOM0
xen/arch/arm/mm.c +3 -3
index 0a3e1f3b64b6..53773368d036 100644
@@ -1579,7 +1579,7 @@ void put_page_type(struct page_info *page)
      return;
  }
 
-int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                                unsigned int flags, unsigned int cache_flags)
  {
      int rc;
@@ -1600,8 +1600,8 @@ int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
          return GNTST_okay;
  }
 
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int flags)
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags)
  {
      gfn_t gfn = gaddr_to_gfn(gpaddr);
      struct domain *d = current->domain;
Signature · 1 line
Julien Grall
#2 lore raw
Quoted 19 lines · Julien Grall

Sorry I forgot to CC Bertrand and Stefano.

Quoted 15 lines · Julien Grall

From: Julien Grall <[email protected]>

Both the stub and the x86 prototypes for replace_grant_host_mapping() and create_grant_host_mapping() will define the first parameter (and third for the former) as uint64_t. Yet Arm will define it as 'unsigned long'.

While there are no differences for 64-bit, for 32-bit it means that the address should be truncated as 32-bit guest could support up to 40-bit addresses.

So replace 'unsigned long' with 'uint64_t' for the first parameter (and third parameter for replace_grant_host_mapping()).

Quoted 57 lines
Quoted 53 lines

---

---
  xen/arch/arm/include/asm/grant_table.h | 6 +++---
  xen/arch/arm/mm.c                      | 6 +++---
  2 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/include/asm/grant_table.h +3 -2
index f2d115b97d8b..d3c518a926b9 100644
@@ -36,10 +36,10 @@ static inline bool gnttab_release_host_mappings(const
 struct domain *d)
      return true;
  }
  -int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                                unsigned int flags, unsigned int
 cache_flags);
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int
 flags);
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags);
    /*
   * The region used by Xen on the memory will never be mapped in DOM0
xen/arch/arm/mm.c +3 -1
index 0a3e1f3b64b6..53773368d036 100644
@@ -1579,7 +1579,7 @@ void put_page_type(struct page_info *page)
      return;
  }
  -int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                                unsigned int flags, unsigned int
 cache_flags)
  {
      int rc;
@@ -1600,8 +1600,8 @@ int create_grant_host_mapping(unsigned long gpaddr,
 mfn_t frame,
          return GNTST_okay;
  }
  -int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int
 flags)
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags)
  {
      gfn_t gfn = gaddr_to_gfn(gpaddr);
      struct domain *d = current->domain;
Signature · 1 line
Julien Grall
Reviewed-by Tested-by on v1 1/1
#3 lore raw
In reply to Julien Grall

Hi Julien,

Quoted 11 lines

-----Original Message-----
Subject: [PATCH] xen/arm: grant-table: Correct the prototype of the arch helpers

From: Julien Grall <[email protected]>

Both the stub and the x86 prototypes for replace_grant_host_mapping() and create_grant_host_mapping() will define the first parameter (and third for the former) as uint64_t. Yet Arm will define it as 'unsigned long'.

Quoted 8 lines

While there are no differences for 64-bit, for 32-bit it means that the address should be truncated as 32-bit guest could support up to 40-bit addresses.

So replace 'unsigned long' with 'uint64_t' for the first parameter (and third parameter for replace_grant_host_mapping()).

Kind regards,
Henry

Reviewed-by on v1 1/1
#4 lore raw
In reply to Julien Grall

Hi Julien,

Quoted 9 lines · Julien Grall

From: Julien Grall <[email protected]>

Both the stub and the x86 prototypes for replace_grant_host_mapping() and create_grant_host_mapping() will define the first parameter (and third for the former) as uint64_t. Yet Arm will define it as 'unsigned long'.

Quoted 8 lines

While there are no differences for 64-bit, for 32-bit it means that the address should be truncated as 32-bit guest could support up to 40-bit addresses.

So replace 'unsigned long' with 'uint64_t' for the first parameter (and third parameter for replace_grant_host_mapping()).

Cheers
Bertrand

Quoted 54 lines

---

---
xen/arch/arm/include/asm/grant_table.h | 6 +++---
xen/arch/arm/mm.c | 6 +++---

2 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/include/asm/grant_table.h +3 -3
index f2d115b97d8b..d3c518a926b9 100644
@@ -36,10 +36,10 @@ static inline bool gnttab_release_host_mappings(const struct domain *d)
    return true;
 }
 
-int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                              unsigned int flags, unsigned int cache_flags);
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int flags);
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags);
 
 /*
 * The region used by Xen on the memory will never be mapped in DOM0
xen/arch/arm/mm.c +3 -3
index 0a3e1f3b64b6..53773368d036 100644
@@ -1579,7 +1579,7 @@ void put_page_type(struct page_info *page)
    return;
 }
 
-int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
+int create_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
                              unsigned int flags, unsigned int cache_flags)
 {
    int rc;
@@ -1600,8 +1600,8 @@ int create_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
        return GNTST_okay;
 }
 
-int replace_grant_host_mapping(unsigned long gpaddr, mfn_t frame,
-                               unsigned long new_gpaddr, unsigned int flags)
+int replace_grant_host_mapping(uint64_t gpaddr, mfn_t frame,
+                               uint64_t new_gpaddr, unsigned int flags)
 {
    gfn_t gfn = gaddr_to_gfn(gpaddr);
    struct domain *d = current->domain;
Signature · 1 line
2.40.1
#5 lore raw

Hi Bertrand,

Quoted 13 lines · Bertrand Marquis
Quoted 13 lines · Julien Grall

From: Julien Grall <[email protected]>

Both the stub and the x86 prototypes for replace_grant_host_mapping() and create_grant_host_mapping() will define the first parameter (and third for the former) as uint64_t. Yet Arm will define it as 'unsigned long'.

While there are no differences for 64-bit, for 32-bit it means that the address should be truncated as 32-bit guest could support up to 40-bit addresses.

Quoted 6 lines
Quoted 4 lines

So replace 'unsigned long' with 'uint64_t' for the first parameter (and third parameter for replace_grant_host_mapping()).

Thanks. It is now committed.

Cheers,

Signature · 1 line
Julien Grall