diff mbox series

xen/arm: bootfdt: Ignore empty memory bank

Message ID 20200918171116.29005-1-julien@xen.org (mailing list archive)
State New, archived
Headers show
Series xen/arm: bootfdt: Ignore empty memory bank | expand

Commit Message

Julien Grall Sept. 18, 2020, 5:11 p.m. UTC
From: Julien Grall <jgrall@amazon.com>

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.

Reported-by: Daniel Wagner <Daniel.Wagner2@itk-engineering.de>
Signed-off-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/bootfdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bertrand Marquis Sept. 21, 2020, 12:24 p.m. UTC | #1
> On 18 Sep 2020, at 18:11, Julien Grall <julien@xen.org> wrote:
> 
> From: Julien Grall <jgrall@amazon.com>
> 
> 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.
> 
> Reported-by: Daniel Wagner <Daniel.Wagner2@itk-engineering.de>
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

> ---
> xen/arch/arm/bootfdt.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> index 08fb59f4e7a9..dcff512648a0 100644
> --- a/xen/arch/arm/bootfdt.c
> +++ b/xen/arch/arm/bootfdt.c
> @@ -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++;
> -- 
> 2.17.1
> 
>
Stefano Stabellini Sept. 21, 2020, 11:41 p.m. UTC | #2
On Mon, 21 Sep 2020, Bertrand Marquis wrote:
> > On 18 Sep 2020, at 18:11, Julien Grall <julien@xen.org> wrote:
> > 
> > From: Julien Grall <jgrall@amazon.com>
> > 
> > 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.
> > 
> > Reported-by: Daniel Wagner <Daniel.Wagner2@itk-engineering.de>
> > Signed-off-by: Julien Grall <jgrall@amazon.com>
> 
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> > ---
> > xen/arch/arm/bootfdt.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> > index 08fb59f4e7a9..dcff512648a0 100644
> > --- a/xen/arch/arm/bootfdt.c
> > +++ b/xen/arch/arm/bootfdt.c
> > @@ -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++;
> > -- 
> > 2.17.1
> > 
> > 
>
diff mbox series

Patch

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 08fb59f4e7a9..dcff512648a0 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -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++;