From: Jerry Van Baren <gvb.uboot@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 00/32] Initial sparse fix series
Date: Wed, 17 Oct 2012 20:19:23 -0400 [thread overview]
Message-ID: <507F4B0B.1020401@gmail.com> (raw)
In-Reply-To: <1350433728-24120-1-git-send-email-kim.phillips@freescale.com>
Hi David, Jon,
Kim Phillips created a series of patches to change variable declarations
that are big endian to be __be32/__be64. Since the device tree is
defined to be big endian, he created a patch to mark the appropriate
libfdt entities as __be*.
On 10/16/2012 08:28 PM, Kim Phillips wrote:
> This 32-patch series only begins to address making u-boot source more
> 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> and endianness mismatches and generally improve code quality. E.g., in this
> initial dose whose main purpose is to reduce the output volume to workable
> levels, a couple of endianness bugs are found and fixed in
> of_bus_default_translate() and fdt_get_base_address(). See [PATCH 14/32]
> common/fdt_support.c: sparse fixes.
Upside: This is very good for identifying endian errors early.
Downside: It could break/complicate non-linux uses of libfdt.
What are your thoughts on this quest?
[snip]
> Note that there are two libfdt dependencies:
[snipped #1, u-boot-fdt dependency, NBD]
> 2. potential upstream dtc change dependencies, due to having to attribute base
> device tree header types to __be32 in include/libfdt. See patch 19/32
> "include/fdt.h: sparse fixes". It is unknown whether such changes would
> be welcome to dtc (but there's a way to find out :).
[snip]
> Build-tested in both endians :). Please help test.
>
> Thanks,
>
> Kim
Below is the actual patch for reference (it was in a separate email).
The impact in terms of changed lines is pretty small. I'm not sure how
this impacts non-linux / non-gcc systems since the sparse checker comes
from a linux background and uses gcc extensions.
Possibly this could be handled a definition:
#ifndef _LINUX_TYPES_H
typedef uint32_t __be32
typedef uint64_t __be64
#endif
> include/fdt.h | 33 +++++++++++++++++----------------
> include/fdt_support.h | 2 ++
> include/libfdt.h | 4 ++--
> lib/libfdt/fdt.c | 2 +-
> lib/libfdt/fdt_ro.c | 2 +-
> lib/libfdt/fdt_rw.c | 4 ++--
> lib/libfdt/fdt_sw.c | 4 ++--
> lib/libfdt/fdt_wip.c | 2 +-
> 8 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/include/fdt.h b/include/fdt.h
> index c51212e..1b7f044 100644
> --- a/include/fdt.h
> +++ b/include/fdt.h
> @@ -2,40 +2,41 @@
> #define _FDT_H
>
> #ifndef __ASSEMBLY__
> +#include <asm/byteorder.h>
>
> struct fdt_header {
> - uint32_t magic; /* magic word FDT_MAGIC */
> - uint32_t totalsize; /* total size of DT block */
> - uint32_t off_dt_struct; /* offset to structure */
> - uint32_t off_dt_strings; /* offset to strings */
> - uint32_t off_mem_rsvmap; /* offset to memory reserve map */
> - uint32_t version; /* format version */
> - uint32_t last_comp_version; /* last compatible version */
> + __be32 magic; /* magic word FDT_MAGIC */
> + __be32 totalsize; /* total size of DT block */
> + __be32 off_dt_struct; /* offset to structure */
> + __be32 off_dt_strings; /* offset to strings */
> + __be32 off_mem_rsvmap; /* offset to memory reserve map */
> + __be32 version; /* format version */
> + __be32 last_comp_version; /* last compatible version */
>
> /* version 2 fields below */
> - uint32_t boot_cpuid_phys; /* Which physical CPU id we're
> + __be32 boot_cpuid_phys; /* Which physical CPU id we're
> booting on */
> /* version 3 fields below */
> - uint32_t size_dt_strings; /* size of the strings block */
> + __be32 size_dt_strings; /* size of the strings block */
>
> /* version 17 fields below */
> - uint32_t size_dt_struct; /* size of the structure block */
> + __be32 size_dt_struct; /* size of the structure block */
> };
>
> struct fdt_reserve_entry {
> - uint64_t address;
> - uint64_t size;
> + __be64 address;
> + __be64 size;
> };
>
> struct fdt_node_header {
> - uint32_t tag;
> + __be32 tag;
> char name[0];
> };
>
> struct fdt_property {
> - uint32_t tag;
> - uint32_t len;
> - uint32_t nameoff;
> + __be32 tag;
> + __be32 len;
> + __be32 nameoff;
> char data[0];
> };
>
> diff --git a/include/fdt_support.h b/include/fdt_support.h
> index 2e18d82..399b73f 100644
> --- a/include/fdt_support.h
> +++ b/include/fdt_support.h
> @@ -81,7 +81,9 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose);
> #ifdef CONFIG_OF_BOARD_SETUP
> void ft_board_setup(void *blob, bd_t *bd);
> void ft_cpu_setup(void *blob, bd_t *bd);
> +void ft_fixup_num_cores(void *blob);
> void ft_pci_setup(void *blob, bd_t *bd);
> +void ft_srio_setup(void *blob);
> #endif
>
> void set_working_fdt_addr(void *addr);
> diff --git a/include/libfdt.h b/include/libfdt.h
> index 4589c5f..ab98d23 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -1153,8 +1153,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
> static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
> uint32_t val)
> {
> - val = cpu_to_fdt32(val);
> - return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
> + __be32 tmp = cpu_to_fdt32(val);
> + return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
> }
>
> /**
> diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
> index 4157b21..5a82c60 100644
> --- a/lib/libfdt/fdt.c
> +++ b/lib/libfdt/fdt.c
> @@ -96,7 +96,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
>
> uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
> {
> - const uint32_t *tagp, *lenp;
> + const __be32 *tagp, *lenp;
> uint32_t tag;
> int offset = startoffset;
> const char *p;
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 1933010..4e3d87a 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -326,7 +326,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
>
> uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
> {
> - const uint32_t *php;
> + const __be32 *php;
> int len;
>
> /* FIXME: This is a bit sub-optimal, since we potentially scan
> diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
> index 5ed23d6..688b817 100644
> --- a/lib/libfdt/fdt_rw.c
> +++ b/lib/libfdt/fdt_rw.c
> @@ -343,7 +343,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
> int nodelen;
> int err;
> uint32_t tag;
> - uint32_t *endtag;
> + __be32 *endtag;
>
> FDT_RW_CHECK_HEADER(fdt);
>
> @@ -370,7 +370,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
> nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
> memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
> memcpy(nh->name, name, namelen);
> - endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
> + endtag = (__be32 *)((char *)nh + nodelen - FDT_TAGSIZE);
> *endtag = cpu_to_fdt32(FDT_END_NODE);
>
> return offset;
> diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c
> index 55ebebf..5ce91ba 100644
> --- a/lib/libfdt/fdt_sw.c
> +++ b/lib/libfdt/fdt_sw.c
> @@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
>
> int fdt_end_node(void *fdt)
> {
> - uint32_t *en;
> + __be32 *en;
>
> FDT_SW_CHECK_HEADER(fdt);
>
> @@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
> int fdt_finish(void *fdt)
> {
> char *p = (char *)fdt;
> - uint32_t *end;
> + __be32 *end;
> int oldstroffset, newstroffset;
> uint32_t tag;
> int offset, nextoffset;
> diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
> index e373677..dc1e14c 100644
> --- a/lib/libfdt/fdt_wip.c
> +++ b/lib/libfdt/fdt_wip.c
> @@ -78,7 +78,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
>
> static void _fdt_nop_region(void *start, int len)
> {
> - uint32_t *p;
> + __be32 *p;
>
> for (p = start; (char *)p < ((char *)start + len); p++)
> *p = cpu_to_fdt32(FDT_NOP);
next prev parent reply other threads:[~2012-10-18 0:19 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
2012-10-25 17:37 ` Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined Kim Phillips
2012-10-24 21:31 ` Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 03/32] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 04/32] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 05/32] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 06/32] arch/powerpc/lib/bootm.c: fix noinline attribute Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 07/32] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
2012-10-18 16:55 ` Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 09/32] include/common.h: sparse fix Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 10/32] include/command.h: " Kim Phillips
2012-10-25 16:35 ` Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 11/32] include/image.h: sparse fixes Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 12/32] common/cmd_*.c: " Kim Phillips
2012-10-24 23:49 ` Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 13/32] common/misc: " Kim Phillips
2012-10-25 17:32 ` Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 14/32] common/fdt_support.c: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 15/32] net/: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 16/32] drivers/net/: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 17/32] lib/zlib: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 18/32] lib/vsprintf.c: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 19/32] include/fdt.h: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 20/32] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 21/32] arch/powerpc/cpu/mpc85xx/fdt.c: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 22/32] powerpc/mpc85xx: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 23/32] powerpc/mpc83xx: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 24/32] drivers/block/: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 25/32] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 26/32] drivers/input/input.c: sparse fix Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: " Kim Phillips
2012-10-17 3:57 ` Heiko Schocher
2012-10-26 3:29 ` [U-Boot] [U-Boot,27/32] " Tom Rini
2012-10-17 0:28 ` [U-Boot] [PATCH 28/32] drivers/mmc/mmc.c: sparse fixes Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 29/32] drivers/mmc/fsl_esdhc.c: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 30/32] drivers/mtd/cfi_flash.c: " Kim Phillips
2012-10-17 0:28 ` [U-Boot] [PATCH 31/32] drivers/mtd/nand: " Kim Phillips
2012-10-22 19:18 ` Scott Wood
2012-10-17 0:28 ` [U-Boot] [PATCH 32/32] drivers/serial/serial_ns16550.c: " Kim Phillips
2012-10-26 3:30 ` [U-Boot] [U-Boot, " Tom Rini
2012-10-18 0:19 ` Jerry Van Baren [this message]
2012-10-18 12:11 ` [U-Boot] [PATCH 00/32] Initial sparse fix series David Gibson
2012-10-18 22:30 ` Kim Phillips
2012-10-19 0:43 ` David Gibson
2012-10-30 21:57 ` [U-Boot] [PATCH] libfdt: introduce fdt type annotation for use by endian checkers Kim Phillips
2012-10-30 22:24 ` Stephen Warren
2012-10-30 22:27 ` Kim Phillips
2012-11-06 7:48 ` David Gibson
2012-11-14 0:34 ` [U-Boot] [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation " Kim Phillips
2012-11-14 14:42 ` Jon Loeliger
2012-11-15 0:59 ` [U-Boot] [PATCH v2 1/4] dtc/tests: don't include fdt.h prior to libfdt.h Kim Phillips
2012-11-15 0:59 ` [U-Boot] [PATCH v2 2/4] dtc/fdtdump: include libfdt_env.h prior to fdt.h Kim Phillips
2012-11-15 0:59 ` [U-Boot] [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers Kim Phillips
2012-11-15 4:43 ` David Gibson
2012-11-15 5:12 ` Kim Phillips
2012-11-19 2:30 ` David Gibson
2012-11-28 23:33 ` [U-Boot] [PATCH v4 " Kim Phillips
2012-12-03 4:05 ` David Gibson
2013-01-06 21:52 ` Jon Loeliger
2012-11-15 0:59 ` [U-Boot] [PATCH v2 4/4] dtc/libfdt: uintXX_t to fdtXX_t conversion Kim Phillips
2012-10-18 16:53 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Tom Rini
2012-10-24 21:21 ` Tom Rini
2012-10-24 22:47 ` Kim Phillips
2012-10-25 17:46 ` Tom Rini
2012-10-25 18:59 ` Kim Phillips
2012-10-25 19:28 ` Tom Rini
2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 01/25] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 02/25] include/linux/compat.h: fix warning: preprocessor token {__iomem, __user} redefined Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 03/25] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 04/25] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 05/25] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 06/25] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 07/25] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 08/25] include/image.h: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 09/25] common/cmd_*.c: " Kim Phillips
2012-11-08 10:48 ` Wolfgang Denk
2012-11-09 1:04 ` Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 10/25] common/misc: " Kim Phillips
2012-11-05 21:30 ` Henrik Nordström
2012-11-06 1:51 ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
2012-11-06 5:44 ` Henrik Nordström
2012-11-07 21:39 ` Simon Glass
2012-11-07 22:23 ` Anatolij Gustschin
2012-11-08 11:02 ` Anatolij Gustschin
2012-11-08 11:23 ` Wolfgang Denk
2012-11-08 10:41 ` Wolfgang Denk
2012-11-08 11:52 ` [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60 Anatolij Gustschin
2012-11-08 12:42 ` Anatolij Gustschin
2012-11-10 11:21 ` Albert ARIBAUD
2012-11-10 11:41 ` Anatolij Gustschin
2012-12-14 4:13 ` Rommel Custodio
2012-12-14 7:51 ` Anatolij Gustschin
2012-10-29 23:34 ` [U-Boot] [PATCH v2 11/25] net/: sparse fixes Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 12/25] drivers/net/: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 13/25] lib/zlib: " Kim Phillips
2012-11-08 11:20 ` Wolfgang Denk
2012-11-09 1:06 ` Kim Phillips
2012-11-21 16:37 ` Tom Rini
2012-10-29 23:34 ` [U-Boot] [PATCH v2 14/25] lib/vsprintf.c: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 15/25] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 16/25] powerpc/mpc85xx: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 17/25] powerpc/mpc83xx: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 18/25] drivers/block/: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 19/25] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix Kim Phillips
2012-10-31 5:51 ` Simon Glass
2012-10-29 23:34 ` [U-Boot] [PATCH v2 21/25] drivers/mmc/mmc.c: sparse fixes Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 22/25] drivers/mmc/fsl_esdhc.c: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 23/25] drivers/mtd/cfi_flash.c: " Kim Phillips
2012-10-29 23:34 ` [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: " Kim Phillips
2012-10-30 0:43 ` Scott Wood
2012-10-29 23:34 ` [U-Boot] [PATCH v2 25/25] drivers/serial/serial_ns16550.c: " Kim Phillips
2012-11-04 18:30 ` [U-Boot] [PATCH v2 00/32] Initial sparse fix series Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=507F4B0B.1020401@gmail.com \
--to=gvb.uboot@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox