[U-Boot] [PATCH v6 0/2] Enable FIT image to be loaded beyond 32-bit space

Originally the set was trying to fix compiling warnings on 32-bit host by converting ulong to phys_addr_t for image address handling. But it used a lot of casting and was ugly. Another approach was taken by ignoring 32-bit hosts and only support this feature on 64-bit capable hosts.
This patchset is tested by compiling for selected powerpc, arm, armv8 and sandbox target. It is verified on selected platforms, including p1021rdb (e500v2) p4080ds (e500mc) t4240qds (e6500) ls1021aqds (armv7) ls2080ardb (armv8) with 32- and 64-git address images
Changes in v6: Drop patches which convert ulong to phys_addr_t Revert to use original ulong Revert back to use original "ulong" instead of "phys_addr_t" Abort getting image addresses if address is too long for "ulong"
Changes in v5: New patch split from fixing load and entry address patch Split the common function into another patch. Revise commit subject. Update commit message as suggested by Simon. Updated cover letter with testing report.
Changes in v4: Separate ulong to phys_addr_t change to another patch.
Changes in v3: Define PRIpa for host and target in common/image-fit.c so printf works properly for 32-, 64-bit targets and host tools.
Changes in v2: Make a common function for both load and entry addresses. Simplify calculation of addresses in a similar way as fdtdec_get_number() fdtdec_get_number() is not used, or too many files need to be included and/or twisted for host tool Continue to use %08llx for print format for load and entry addresses because %pa does not always work for host tool (mkimage)
York Sun (2): common: image-fit: Use a common function to get address common: image-fit: Fix load and entry addresses in FIT image
common/image-fit.c | 54 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 23 deletions(-)

FIT image supports load address and entry address. Getting these addresses can use a common function.
Signed-off-by: York Sun york.sun@nxp.com
---
Changes in v6: Drop patches which convert ulong to phys_addr_t Revert to use original ulong
Changes in v5: New patch split from fixing load and entry address patch
Changes in v4: None Changes in v3: None Changes in v2: None
common/image-fit.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/common/image-fit.c b/common/image-fit.c index fbd9e0d..7ce3e35 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -433,7 +433,7 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)
if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) || (type == IH_TYPE_RAMDISK)) { - fit_image_get_entry(fit, image_noffset, &entry); + ret = fit_image_get_entry(fit, image_noffset, &entry); printf("%s Entry Point: ", p); if (ret) printf("unavailable\n"); @@ -675,6 +675,22 @@ int fit_image_get_comp(const void *fit, int noffset, uint8_t *comp) return 0; }
+static int fit_image_get_address(const void *fit, int noffset, char *name, + ulong *load) +{ + int len; + const uint32_t *data; + + data = fdt_getprop(fit, noffset, name, &len); + if (data == NULL) { + fit_get_debug(fit, noffset, name, len); + return -1; + } + + *load = uimage_to_cpu(*data); + + return 0; +} /** * fit_image_get_load() - get load addr property for given component image node * @fit: pointer to the FIT format image header @@ -690,17 +706,7 @@ int fit_image_get_comp(const void *fit, int noffset, uint8_t *comp) */ int fit_image_get_load(const void *fit, int noffset, ulong *load) { - int len; - const uint32_t *data; - - data = fdt_getprop(fit, noffset, FIT_LOAD_PROP, &len); - if (data == NULL) { - fit_get_debug(fit, noffset, FIT_LOAD_PROP, len); - return -1; - } - - *load = uimage_to_cpu(*data); - return 0; + return fit_image_get_address(fit, noffset, FIT_LOAD_PROP, load); }
/** @@ -722,17 +728,7 @@ int fit_image_get_load(const void *fit, int noffset, ulong *load) */ int fit_image_get_entry(const void *fit, int noffset, ulong *entry) { - int len; - const uint32_t *data; - - data = fdt_getprop(fit, noffset, FIT_ENTRY_PROP, &len); - if (data == NULL) { - fit_get_debug(fit, noffset, FIT_ENTRY_PROP, len); - return -1; - } - - *entry = uimage_to_cpu(*data); - return 0; + return fit_image_get_address(fit, noffset, FIT_ENTRY_PROP, entry); }
/**

On 29 February 2016 at 16:48, York Sun york.sun@nxp.com wrote:
FIT image supports load address and entry address. Getting these addresses can use a common function.
Signed-off-by: York Sun york.sun@nxp.com
Changes in v6: Drop patches which convert ulong to phys_addr_t Revert to use original ulong
Changes in v5: New patch split from fixing load and entry address patch
Changes in v4: None Changes in v3: None Changes in v2: None
common/image-fit.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Feb 29, 2016 at 03:48:40PM -0800, York Sun wrote:
FIT image supports load address and entry address. Getting these addresses can use a common function.
Signed-off-by: York Sun york.sun@nxp.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

FIT image supports more than 32 bits in addresses by using #address-cell field. Fixing 64-bit support by using this field.
Signed-off-by: York Sun york.sun@nxp.com
---
Changes in v6: Revert back to use original "ulong" instead of "phys_addr_t" Abort getting image addresses if address is too long for "ulong"
Changes in v5: Split the common function into another patch. Revise commit subject. Update commit message as suggested by Simon. Updated cover letter with testing report.
Changes in v4: Separate ulong to phys_addr_t change to another patch.
Changes in v3: Define PRIpa for host and target in common/image-fit.c so printf works properly for 32-, 64-bit targets and host tools.
Changes in v2: Make a common function for both load and entry addresses. Simplify calculation of addresses in a similar way as fdtdec_get_number() fdtdec_get_number() is not used, or too many files need to be included and/or twisted for host tool Continue to use %08llx for print format for load and entry addresses because %pa does not always work for host tool (mkimage)
common/image-fit.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/common/image-fit.c b/common/image-fit.c index 7ce3e35..b5f7c4c 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -678,16 +678,28 @@ int fit_image_get_comp(const void *fit, int noffset, uint8_t *comp) static int fit_image_get_address(const void *fit, int noffset, char *name, ulong *load) { - int len; - const uint32_t *data; + int len, cell_len; + const fdt32_t *cell; + uint64_t load64 = 0;
- data = fdt_getprop(fit, noffset, name, &len); - if (data == NULL) { + cell = fdt_getprop(fit, noffset, name, &len); + if (cell == NULL) { fit_get_debug(fit, noffset, name, len); return -1; }
- *load = uimage_to_cpu(*data); + if (len > sizeof(ulong)) { + printf("Unsupported %s address size\n", name); + return -1; + } + + cell_len = len >> 2; + /* Use load64 to avoid compiling warning for 32-bit target */ + while (cell_len--) { + load64 = (load64 << 32) | uimage_to_cpu(*cell); + cell++; + } + *load = (ulong)load64;
return 0; }

On 29 February 2016 at 16:48, York Sun york.sun@nxp.com wrote:
FIT image supports more than 32 bits in addresses by using #address-cell field. Fixing 64-bit support by using this field.
Signed-off-by: York Sun york.sun@nxp.com
Changes in v6: Revert back to use original "ulong" instead of "phys_addr_t" Abort getting image addresses if address is too long for "ulong"
Changes in v5: Split the common function into another patch. Revise commit subject. Update commit message as suggested by Simon. Updated cover letter with testing report.
Changes in v4: Separate ulong to phys_addr_t change to another patch.
Changes in v3: Define PRIpa for host and target in common/image-fit.c so printf works properly for 32-, 64-bit targets and host tools.
Changes in v2: Make a common function for both load and entry addresses. Simplify calculation of addresses in a similar way as fdtdec_get_number() fdtdec_get_number() is not used, or too many files need to be included and/or twisted for host tool Continue to use %08llx for print format for load and entry addresses because %pa does not always work for host tool (mkimage)
common/image-fit.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Feb 29, 2016 at 03:48:41PM -0800, York Sun wrote:
FIT image supports more than 32 bits in addresses by using #address-cell field. Fixing 64-bit support by using this field.
Signed-off-by: York Sun york.sun@nxp.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (3)
-
Simon Glass
-
Tom Rini
-
York Sun