Skip to contentSkip to conversation

xen/arm: domain_build: Avoid implicit conversion from ULL to UL

PATCH In review Julien Grall 3 participants 8 messages Sep 29, 2019 – Oct 1, 2019

lore
Share & tools
lore
#0 lore raw

cover xen/arm: domain_build: Avoid implicit conversion from ULL to UL

Hi all,

This small patch series is here to avoid an implicit conversion from ULL to UL when building with Arm32 (see patch #1). This patch is candidate for Xen 4.13.

The second patch is only a coding style fix. So could be deferred to next.

Cheers,

Cc Juergen Gross <[email protected]>

Julien Grall (2):
xen/arm: domain_build: Avoid implicit conversion from ULL to UL xen/arm: domain_build: Indent correctly parameters of
alloc_bank_memory()

 xen/arch/arm/domain_build.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 1/2 xen/arm: domain_build: Avoid implicit conversion from ULL to UL

Clang 8.0 will fail to build domain_build.c on Arm32 because of the following error:

domain_build.c:448:21: error: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 1090921693184 to 0 [-Werror,-Wconstant-conversion]

    bank_size = MIN(GUEST_RAM1_SIZE, kinfo->unassigned_mem);

Arm32 is able to support more than 4GB of physical memory, so it would be theorically possible to create domian with more the 4GB of RAM. Therefore, the size of a bank may not fit in 32-bit.

This can be resolved by switch the variable bank_size and the parameter tot_size to "paddr_t".

---

Cc Juergen Gross <[email protected]>

I am not aware of any users trying to allocate more than 4GB VM for 32-bit (there more it is in the dom0less path). Nonetheless, it would be best to fix it as soon as possible.

Only built test it.

---
 xen/arch/arm/domain_build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +2 -2
index 337a89e518..b791e4b512 100644
@@ -377,7 +377,7 @@ static void __init allocate_memory_11(struct domain *d,
 static bool __init allocate_bank_memory(struct domain *d,
                                        struct kernel_info *kinfo,
                                        gfn_t sgfn,
-                                       unsigned long tot_size)
+                                       paddr_t tot_size)
 {
     int res;
     struct page_info *pg;
@@ -433,7 +433,7 @@ static bool __init allocate_bank_memory(struct domain *d,
 static void __init allocate_memory(struct domain *d, struct kernel_info *kinfo)
 {
     unsigned int i;
-    unsigned long bank_size;
+    paddr_t bank_size;
 
     printk(XENLOG_INFO "Allocating mappings totalling %ldMB for %pd:\n",
            /* Don't want format this as PRIpaddr (16 digit hex) */
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
Quoted 7 lines · Julien Grall

Clang 8.0 will fail to build domain_build.c on Arm32 because of the following error:

domain_build.c:448:21: error: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 1090921693184 to 0 [-Werror,-Wconstant-conversion]

     bank_size = MIN(GUEST_RAM1_SIZE, kinfo->unassigned_mem);
Quoted 8 lines

Arm32 is able to support more than 4GB of physical memory, so it would be theorically possible to create domian with more the 4GB of RAM. Therefore, the size of a bank may not fit in 32-bit.

This can be resolved by switch the variable bank_size and the parameter tot_size to "paddr_t".

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/2
#3 lore raw
In reply to Julien Grall
Quoted 9 lines · Julien Grall

Clang 8.0 will fail to build domain_build.c on Arm32 because of the following error:

domain_build.c:448:21: error: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 1090921693184 to 0 [-Werror,-Wconstant-conversion]

    bank_size = MIN(GUEST_RAM1_SIZE, kinfo->unassigned_mem);

Arm32 is able to support more than 4GB of physical memory, so it would be theorically possible to create domian with more the 4GB of RAM.

^ domain

Other than the typo:

Quoted 45 lines

Therefore, the size of a bank may not fit in 32-bit.

This can be resolved by switch the variable bank_size and the parameter tot_size to "paddr_t".

---

Cc Juergen Gross <[email protected]>

I am not aware of any users trying to allocate more than 4GB VM for 32-bit (there more it is in the dom0less path). Nonetheless, it would be best to fix it as soon as possible.

Only built test it.

---
 xen/arch/arm/domain_build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +2 -2
index 337a89e518..b791e4b512 100644
@@ -377,7 +377,7 @@ static void __init allocate_memory_11(struct domain *d,
 static bool __init allocate_bank_memory(struct domain *d,
                                        struct kernel_info *kinfo,
                                        gfn_t sgfn,
-                                       unsigned long tot_size)
+                                       paddr_t tot_size)
 {
     int res;
     struct page_info *pg;
@@ -433,7 +433,7 @@ static bool __init allocate_bank_memory(struct domain *d,
 static void __init allocate_memory(struct domain *d, struct kernel_info *kinfo)
 {
     unsigned int i;
-    unsigned long bank_size;
+    paddr_t bank_size;
 
     printk(XENLOG_INFO "Allocating mappings totalling %ldMB for %pd:\n",
            /* Don't want format this as PRIpaddr (16 digit hex) */
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

PATCH 2/2 xen/arm: domain_build: Indent correctly parameters of alloc_bank_memory()

In reply to Julien Grall
---
 xen/arch/arm/domain_build.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +3 -3
index b791e4b512..268e074af7 100644
@@ -375,9 +375,9 @@ static void __init allocate_memory_11(struct domain *d,
 }
 
 static bool __init allocate_bank_memory(struct domain *d,
-                                       struct kernel_info *kinfo,
-                                       gfn_t sgfn,
-                                       paddr_t tot_size)
+                                        struct kernel_info *kinfo,
+                                        gfn_t sgfn,
+                                        paddr_t tot_size)
 {
     int res;
     struct page_info *pg;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 2/2
#5 lore raw

Re: [Xen-devel] [PATCH for-4.13 2/2] xen/arm: domain_build: Indent correctly parameters of alloc_bank_memory()

Quoted 1 line · Julien Grall
Quoted 24 lines
---
 xen/arch/arm/domain_build.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +3 -3
index b791e4b512..268e074af7 100644
@@ -375,9 +375,9 @@ static void __init allocate_memory_11(struct domain *d,
 }
 
 static bool __init allocate_bank_memory(struct domain *d,
-                                       struct kernel_info *kinfo,
-                                       gfn_t sgfn,
-                                       paddr_t tot_size)
+                                        struct kernel_info *kinfo,
+                                        gfn_t sgfn,
+                                        paddr_t tot_size)
 {
     int res;
     struct page_info *pg;
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Re: [Xen-devel] [PATCH for-4.13 2/2] xen/arm: domain_build: Indent correctly parameters of alloc_bank_memory()

+Juergen

Quoted 30 lines · Stefano Stabellini
Quoted 1 line · Julien Grall
Quoted 24 lines
---
  xen/arch/arm/domain_build.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +3 -3
index b791e4b512..268e074af7 100644
@@ -375,9 +375,9 @@ static void __init allocate_memory_11(struct domain *d,
  }
 
  static bool __init allocate_bank_memory(struct domain *d,
-                                       struct kernel_info *kinfo,
-                                       gfn_t sgfn,
-                                       paddr_t tot_size)
+                                        struct kernel_info *kinfo,
+                                        gfn_t sgfn,
+                                        paddr_t tot_size)
  {
      int res;
      struct page_info *pg;
Signature · 1 line
2.11.0
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#7 lore raw

Re: [Xen-devel] [PATCH for-4.13 2/2] xen/arm: domain_build: Indent correctly parameters of alloc_bank_memory()

Quoted 7 lines · Julien Grall

+Juergen

Quoted 4 lines · Stefano Stabellini
Quoted 1 line · Julien Grall

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel