Skip to contentSkip to conversation

xen/arm: bootfdt: Ignore empty memory bank

PATCH In review Julien Grall 3 participants 3 messages Sep 18, 2020 – Sep 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: bootfdt: Ignore empty memory bank

From: Julien Grall <[email protected]>

At the moment, Xen will stop processing the Device Tree if a memory bank is empty (size == 0).

Unfortunately, some of the Device Tree (such as on Colibri imx8qxp) may contain such a bank. This means Xen will not be able to boot properly.

Relax the check to just ignore the banks. FWIW this also seems to be the behavior adopted by Linux.

---
 xen/arch/arm/bootfdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/bootfdt.c +2 -1
index 08fb59f4e7a9..dcff512648a0 100644
@@ -163,8 +163,9 @@ static int __init process_memory_node(const void *fdt, int node,
     for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
     {
         device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+        /* Some DT may describe empty bank, ignore them */
         if ( !size )
-            return -EINVAL;
+            continue;
         mem->bank[mem->nr_banks].start = start;
         mem->bank[mem->nr_banks].size = size;
         mem->nr_banks++;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Julien Grall

From: Julien Grall <[email protected]>

At the moment, Xen will stop processing the Device Tree if a memory bank is empty (size == 0).

Unfortunately, some of the Device Tree (such as on Colibri imx8qxp) may contain such a bank. This means Xen will not be able to boot properly.

Quoted 5 lines

Relax the check to just ignore the banks. FWIW this also seems to be the behavior adopted by Linux.

Quoted 23 lines

---
xen/arch/arm/bootfdt.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/bootfdt.c +2 -1
index 08fb59f4e7a9..dcff512648a0 100644
@@ -163,8 +163,9 @@ static int __init process_memory_node(const void *fdt, int node,
    for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
    {
        device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+        /* Some DT may describe empty bank, ignore them */
        if ( !size )
-            return -EINVAL;
+            continue;
        mem->bank[mem->nr_banks].start = start;
        mem->bank[mem->nr_banks].size = size;
        mem->nr_banks++;
Signature · 1 line
2.17.1
#2 lore raw
Quoted 11 lines · Bertrand Marquis
Quoted 11 lines · Julien Grall

From: Julien Grall <[email protected]>

At the moment, Xen will stop processing the Device Tree if a memory bank is empty (size == 0).

Unfortunately, some of the Device Tree (such as on Colibri imx8qxp) may contain such a bank. This means Xen will not be able to boot properly.

Quoted 7 lines
Quoted 5 lines

Relax the check to just ignore the banks. FWIW this also seems to be the behavior adopted by Linux.

Quoted 24 lines
Quoted 23 lines

---
xen/arch/arm/bootfdt.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/bootfdt.c +2 -1
index 08fb59f4e7a9..dcff512648a0 100644
@@ -163,8 +163,9 @@ static int __init process_memory_node(const void *fdt, int node,
    for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
    {
        device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+        /* Some DT may describe empty bank, ignore them */
        if ( !size )
-            return -EINVAL;
+            continue;
        mem->bank[mem->nr_banks].start = start;
        mem->bank[mem->nr_banks].size = size;
        mem->nr_banks++;
Signature · 1 line
2.17.1