Message ID | 1376687156-6737-5-git-send-email-julien.grall@linaro.org |
---|---|
State | Superseded, archived |
Headers | show |
On Fri, 2013-08-16 at 22:05 +0100, Julien Grall wrote: > The Flat Device Tree is given by the bootloader. Xen doesn't need to modify it. > > Signed-off-by: Julien Grall <julien.grall@linaro.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> > @@ -363,8 +364,9 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) > * > * TODO: handle other payloads too. > */ > - device_tree_flattened = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); > - copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size, BUFFERABLE); > + fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); > + copy_from_paddr(fdt, dtb_paddr, dtb_size, BUFFERABLE); > + device_tree_flattened = fdt; Not related to this patch but I wonder if we ought to alloc_boot_pages (order_of(dtb_size)) or at least BUG_ON(dtb_size > PAGE_SIZE). Ian.
On 08/22/2013 02:05 PM, Ian Campbell wrote: > On Fri, 2013-08-16 at 22:05 +0100, Julien Grall wrote: >> The Flat Device Tree is given by the bootloader. Xen doesn't need to modify it. >> >> Signed-off-by: Julien Grall <julien.grall@linaro.org> > > Acked-by: Ian Campbell <ian.campbell@citrix.com> > >> @@ -363,8 +364,9 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) >> * >> * TODO: handle other payloads too. >> */ >> - device_tree_flattened = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); >> - copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size, BUFFERABLE); >> + fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); >> + copy_from_paddr(fdt, dtb_paddr, dtb_size, BUFFERABLE); >> + device_tree_flattened = fdt; > > Not related to this patch but I wonder if we ought to alloc_boot_pages > (order_of(dtb_size)) or at least BUG_ON(dtb_size > PAGE_SIZE). The last solution can't work. The size of device tree is about 32K, so greater than one page.
On Thu, 2013-08-22 at 14:35 +0100, Julien Grall wrote: > On 08/22/2013 02:05 PM, Ian Campbell wrote: > > On Fri, 2013-08-16 at 22:05 +0100, Julien Grall wrote: > >> The Flat Device Tree is given by the bootloader. Xen doesn't need to modify it. > >> > >> Signed-off-by: Julien Grall <julien.grall@linaro.org> > > > > Acked-by: Ian Campbell <ian.campbell@citrix.com> > > > >> @@ -363,8 +364,9 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) > >> * > >> * TODO: handle other payloads too. > >> */ > >> - device_tree_flattened = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); > >> - copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size, BUFFERABLE); > >> + fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); > >> + copy_from_paddr(fdt, dtb_paddr, dtb_size, BUFFERABLE); > >> + device_tree_flattened = fdt; > > > > Not related to this patch but I wonder if we ought to alloc_boot_pages > > (order_of(dtb_size)) or at least BUG_ON(dtb_size > PAGE_SIZE). > > The last solution can't work. The size of device tree is about 32K, so > greater than one page. I was being thick, I thought the "1" was the allocation size, missing the fact that "dtb_pages" was right there staring me in the face. (FTR 1 is the alignment...) Ian
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 01492bb..a324c3b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -475,7 +475,7 @@ static int map_devices_from_device_tree(struct domain *d) static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) { - void *fdt; + const void *fdt; int new_size; int ret; paddr_t end; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 1ec5e38..c9534fd 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -289,6 +289,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) unsigned long dtb_pages; unsigned long boot_mfn_start, boot_mfn_end; int i = 0; + void *fdt; /* TODO: Handle non-contiguous memory bank */ if ( !early_info.mem.nr_banks ) @@ -363,8 +364,9 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) * * TODO: handle other payloads too. */ - device_tree_flattened = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); - copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size, BUFFERABLE); + fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1)); + copy_from_paddr(fdt, dtb_paddr, dtb_size, BUFFERABLE); + device_tree_flattened = fdt; /* Add non-xenheap memory */ s = ram_start; diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 51f23eb..b96ae33 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -26,7 +26,7 @@ #include <asm/early_printk.h> struct dt_early_info __initdata early_info; -void *device_tree_flattened; +const void *device_tree_flattened; dt_irq_xlate_func dt_irq_xlate; /* Host device tree */ struct dt_device_node *dt_host; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 5a2a5c6..7cd9e19 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -158,7 +158,7 @@ typedef int (*device_tree_node_func)(const void *fdt, void *data); extern struct dt_early_info early_info; -extern void *device_tree_flattened; +extern const void *device_tree_flattened; size_t __init device_tree_early_init(const void *fdt);
The Flat Device Tree is given by the bootloader. Xen doesn't need to modify it. Signed-off-by: Julien Grall <julien.grall@linaro.org> --- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/setup.c | 6 ++++-- xen/common/device_tree.c | 2 +- xen/include/xen/device_tree.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-)