diff mbox

[RFC,06/29] xen/arm: Load dtb after dom0 kernel

Message ID ee9ab57233118e1023bb86ec32c13d6eea03e385.1367188423.git.julien.grall@linaro.org
State Changes Requested, archived
Headers show

Commit Message

Julien Grall April 28, 2013, 11:01 p.m. UTC
On some setup, the first linux page table is at 0x40004000. Xen will load
dom0 device tree at 0x4000100. In case of the device tree is big, linux will
corrupt the device tree.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/domain_build.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ian Campbell April 29, 2013, 3:07 p.m. UTC | #1
On Mon, 2013-04-29 at 00:01 +0100, Julien Grall wrote:
> On some setup, the first linux page table is at 0x40004000. Xen will load
> dom0 device tree at 0x4000100. In case of the device tree is big, linux will
> corrupt the device tree.

How big can a dtb be? To clash it'd need to be 15¾K?

> Signed-off-by: Julien Grall <julien.grall@linaro.org>


I suppose right after the kernel is as good as anywhere:
Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
>  xen/arch/arm/domain_build.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 3f50193..ad0ab35 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -407,8 +407,9 @@ int construct_dom0(struct domain *d)
>      /* The following loads use the domain's p2m */
>      p2m_load_VTTBR(d);
>  
> -    dtb_load(&kinfo);
> +    kinfo.dtb_paddr = kinfo.zimage.load_addr + kinfo.zimage.len;
>      kernel_load(&kinfo);
> +    dtb_load(&kinfo);
>  
>      discard_initial_modules();
>
Julien Grall April 29, 2013, 3:29 p.m. UTC | #2
On 04/29/2013 04:07 PM, Ian Campbell wrote:

> On Mon, 2013-04-29 at 00:01 +0100, Julien Grall wrote:
>> On some setup, the first linux page table is at 0x40004000. Xen will load
>> dom0 device tree at 0x4000100. In case of the device tree is big, linux will
>> corrupt the device tree.
> 
> How big can a dtb be? To clash it'd need to be 15¾K?

I can't find a maximum size. The field is encoded on 32 bits.

For instance the size of dtb is:
  - 12K for the versatile express
  - 20K for the Arndale board
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 3f50193..ad0ab35 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -407,8 +407,9 @@  int construct_dom0(struct domain *d)
     /* The following loads use the domain's p2m */
     p2m_load_VTTBR(d);
 
-    dtb_load(&kinfo);
+    kinfo.dtb_paddr = kinfo.zimage.load_addr + kinfo.zimage.len;
     kernel_load(&kinfo);
+    dtb_load(&kinfo);
 
     discard_initial_modules();