diff mbox

[v2,0/3] Device tree cleanups

Message ID cover.1384156577.git.peter.crosthwaite@xilinx.com
State New
Headers show

Commit Message

Peter Crosthwaite Nov. 11, 2013, 8:14 a.m. UTC
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Fix the name stem of the devicetree API (P1 - s/qemu_devtree/qemu_fdt)
and cleanup error report (P3). Trivial patch P2 fixing an arugment name
along the way.

Tested using:

1: Alex's e500 test vector.
2: Xilinx Zynq (tests arm/boot.c).

I have testing using Zynq with Mem > 4gb and a bogus dts (size cells = 1)
to give that particular error path some exercise.

To give some exercise to the error paths, I hacked up my libfdt to throw
errors randomly:

-----
qemu-system-ppc: qemu_fdt_setprop: Couldn't set /memory/reg: FDT_ERR_BADOFFSET

Aborted
-----
qemu-system-ppc: qemu_fdt_setprop_string: Couldn't set /soc@e0000000/device_type = soc: FDT_ERR_NOSPACE

Aborted
-----
qemu-system-ppc: qemu_fdt_setprop_cell: Couldn't set /soc@e0000000/#address-cells = 0x000001: FDT_ERR_NOSPACE

Aborted
-----


Peter Crosthwaite (3):
  device_tree: s/qemu_devtree/qemu_fdt globally
  device_tree: qemu_fdt_setprop: Rename val_array arg
  device_tree: qemu_fdt_setprop: Fixup error reporting

 device_tree.c                | 230 +++++++++++++++++++++++++++--------------
 hw/arm/boot.c                |  51 ++++-----
 hw/arm/vexpress.c            |  23 +++--
 hw/microblaze/boot.c         |  17 ++-
 hw/ppc/e500.c                | 241 ++++++++++++++++++++++---------------------
 hw/ppc/e500.h                |   3 +-
 hw/ppc/e500plat.c            |   9 +-
 hw/ppc/mpc8544ds.c           |   9 +-
 hw/ppc/ppc440_bamboo.c       |  34 ++----
 hw/ppc/spapr_rtas.c          |  40 ++-----
 hw/ppc/virtex_ml507.c        |   5 +-
 include/sysemu/device_tree.h | 219 ++++++++++++++++++++++++++++++---------
 12 files changed, 519 insertions(+), 362 deletions(-)

Comments

Peter Crosthwaite Nov. 27, 2013, 1:10 p.m. UTC | #1
Ping!

On Mon, Nov 11, 2013 at 6:14 PM,  <peter.crosthwaite@xilinx.com> wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Fix the name stem of the devicetree API (P1 - s/qemu_devtree/qemu_fdt)
> and cleanup error report (P3). Trivial patch P2 fixing an arugment name
> along the way.
>
> Tested using:
>
> 1: Alex's e500 test vector.
> 2: Xilinx Zynq (tests arm/boot.c).
>
> I have testing using Zynq with Mem > 4gb and a bogus dts (size cells = 1)
> to give that particular error path some exercise.
>
> To give some exercise to the error paths, I hacked up my libfdt to throw
> errors randomly:
>
> --- a/libfdt/fdt_rw.c
> +++ b/libfdt/fdt_rw.c
> @@ -48,6 +48,8 @@
>   *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
>   *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>   */
> +
> +#include <stdlib.h>
>  #include "libfdt_env.h"
>
>  #include <fdt.h>
> @@ -279,6 +281,15 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
>
>     FDT_RW_CHECK_HEADER(fdt);
>
> +    static int seeded = 0;
> +    if (!seeded) {
> +        srand(time(NULL));
> +        seeded = 1;
> +    }
> +    if (!(rand() & 0x7)) {
> +        return -((rand() & 0x3) + 1);
> +    }
> +
>
> Some sample outputs from e500 boot (Using the above tainted libfdt):
>
> -----
> qemu-system-ppc: qemu_fdt_setprop: Couldn't set /memory/reg: FDT_ERR_BADOFFSET
>
> Aborted
> -----
> qemu-system-ppc: qemu_fdt_setprop_string: Couldn't set /soc@e0000000/device_type = soc: FDT_ERR_NOSPACE
>
> Aborted
> -----
> qemu-system-ppc: qemu_fdt_setprop_cell: Couldn't set /soc@e0000000/#address-cells = 0x000001: FDT_ERR_NOSPACE
>
> Aborted
> -----
>
>
> Peter Crosthwaite (3):
>   device_tree: s/qemu_devtree/qemu_fdt globally
>   device_tree: qemu_fdt_setprop: Rename val_array arg
>   device_tree: qemu_fdt_setprop: Fixup error reporting
>
>  device_tree.c                | 230 +++++++++++++++++++++++++++--------------
>  hw/arm/boot.c                |  51 ++++-----
>  hw/arm/vexpress.c            |  23 +++--
>  hw/microblaze/boot.c         |  17 ++-
>  hw/ppc/e500.c                | 241 ++++++++++++++++++++++---------------------
>  hw/ppc/e500.h                |   3 +-
>  hw/ppc/e500plat.c            |   9 +-
>  hw/ppc/mpc8544ds.c           |   9 +-
>  hw/ppc/ppc440_bamboo.c       |  34 ++----
>  hw/ppc/spapr_rtas.c          |  40 ++-----
>  hw/ppc/virtex_ml507.c        |   5 +-
>  include/sysemu/device_tree.h | 219 ++++++++++++++++++++++++++++++---------
>  12 files changed, 519 insertions(+), 362 deletions(-)
>
> --
> 1.8.3.rc1.44.gb387c77.dirty
>
diff mbox

Patch

--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -48,6 +48,8 @@ 
  *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
+#include <stdlib.h>
 #include "libfdt_env.h"

 #include <fdt.h>
@@ -279,6 +281,15 @@  int fdt_setprop(void *fdt, int nodeoffset, const char *name,

    FDT_RW_CHECK_HEADER(fdt);

+    static int seeded = 0;
+    if (!seeded) {
+        srand(time(NULL));
+        seeded = 1;
+    }
+    if (!(rand() & 0x7)) {
+        return -((rand() & 0x3) + 1);
+    }
+

Some sample outputs from e500 boot (Using the above tainted libfdt):