Initial sparse fix series
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest0 of 32 patches 0 repliesNew
Patches in v1 No applies recorded yet
None of the 32 patches the cover letter announces are in this archive.
Reviews trailers per patch
| Patch | David Gibson |
|---|---|
| Series | A-b A-b A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [U-Boot] [PATCH 00/32] Initial sparse fix series
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*.
Quoted 7 lines · Kim Phillips
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()andfdt_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]
Quoted 1 line
Note that there are two libfdt dependencies:
[snipped #1, u-boot-fdt dependency, NBD]
Quoted 4 lines
2. potential upstream dtc change dependencies, due to having to attribute base device tree header types to
__be32ininclude/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]
Quoted 5 lines
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
Quoted 184 lines
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(-)include/fdt.h +17
-16@@ -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 ]; };include/fdt_support.h +2
-0@@ -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);include/libfdt.h +2
-2@@ -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)); }/** lib/libfdt/fdt.c +1
-1@@ -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;lib/libfdt/fdt_ro.c +1
-1@@ -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 lib/libfdt/fdt_rw.c +2
-2@@ -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;lib/libfdt/fdt_sw.c +2
-2@@ -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;lib/libfdt/fdt_wip.c +1
-1@@ -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 );