All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug in devicetree_for_each_node() in xen/arch/arm/bootfdt.c ?
@ 2015-06-22 23:02 Chris (Christopher) Brand
  2015-06-23  9:44 ` David Vrabel
  2015-06-23 10:08 ` Julien Grall
  0 siblings, 2 replies; 16+ messages in thread
From: Chris (Christopher) Brand @ 2015-06-22 23:02 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org; +Cc: David Vrabel, Ian Campbell


[-- Attachment #1.1: Type: text/plain, Size: 2920 bytes --]

I've been trying to figure out why Xen only reports 2GB on my ARM platform that actually has 3GB, and I think I've found a bug, but I'm not familiar enough with the Xen code to fix it.

The relevant parts of my dts are:
/dts-v1/;

/ {
     model = "Broadcom STB (7445d0)";
     compatible = "brcm,bcm7445d0", "brcm,brcmstb";
     #address-cells = <0x2>;
     #size-cells = <0x2>;
     interrupt-parent = <0x1>;

     memory {
           #address-cells = <0x1>;
           #size-cells = <0x1>;
           device_type = "memory";
           reg = <0x0 0x0 0x0 0x40000000 0x0 0x40000000 0x0 0x40000000>;

           region@10000000 {
                contiguous-region;
                reg = <0x10000000 0x1f800000>;
                linux,phandle = <0x2>;
                phandle = <0x2>;
           };

           region@30000000 {
                contiguous-region;
                reg = <0x30000000 0x10000000>;
                linux,phandle = <0x3>;
                phandle = <0x3>;
           };

           region@40000000 {
                contiguous-region;
                reg = <0x40000000 0x40000000>;
                linux,phandle = <0x4>;
                phandle = <0x4>;
           };

           region@80000000 {
                contiguous-region;
                reg = <0x80000000 0x40000000>;
                linux,phandle = <0x5>;
                phandle = <0x5>;
           };
     };

As you can see, it specifies 0 + 1GB + 1GB + 1GB. When I run "xl info" in Dom0, though, it reports "Total 2048".

Digging into the code, I found that in bootinfo.mem.nr_banks is 2 rather than the expected 3 (or 4?). That turned out to be because in process_memory_node(), address_cells and size_cells were both 2 and so the prop_len of 32 was resulting in "banks" being set to 2.

Looking at device_tree_for_each_node(), it looks like something is wrong because it contains this loop:
    for ( node = 0, depth = 0;
          node >=0 && depth >= 0;
          node = fdt_next_node(fdt, node, &depth) )
    {
                [...]
        ret = func(fdt, node, name, depth,
                   address_cells[depth-1], size_cells[depth-1], data);
which looks like it will read before the start of the array for the first node, when depth=0. My first instinct was to remove those two "-1"s, but the resulting code didn't run, so I figured I'd try to enlist some help :) Of course it's possible that my problem is unrelated to this, but reading before the start of the array definitely seems like a bug that should be fixed (although in practice those values are never used for node 0). Looking through the history, it seems to have been like that since the function was first introduced (http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9cf4a9a467171c8a2c3d97c2bfadb1bc8b15a3d6).

I'm happy to test out any patches.

Chris
(Not subscribed to the list)


[-- Attachment #1.2: Type: text/html, Size: 13988 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-07-16 15:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-22 23:02 Bug in devicetree_for_each_node() in xen/arch/arm/bootfdt.c ? Chris (Christopher) Brand
2015-06-23  9:44 ` David Vrabel
2015-06-23  9:57   ` Ian Campbell
2015-06-23 10:08     ` Ian Campbell
2015-06-23 10:10       ` Ian Campbell
2015-06-23 10:01   ` Julien Grall
2015-06-23 10:08 ` Julien Grall
2015-06-23 10:27   ` Ian Campbell
2015-06-23 10:32     ` Julien Grall
2015-06-23 10:43       ` Ian Campbell
2015-06-24 18:57   ` Chris (Christopher) Brand
2015-07-15 23:35   ` Chris (Christopher) Brand
2015-07-16  8:50     ` [PATCH] xen: arm: bootfdt: Avoid reading off the front of *_cells array Ian Campbell
2015-07-16 12:06       ` Julien Grall
2015-07-16 12:45         ` Ian Campbell
2015-07-16 15:52         ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.