
The load-only property in a configuration node indicates that there is not necessarily a kernel or firmware image in the configuration. Handle this case and return an error code. Fix the 'NOEXEC' typo while here. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/image-fit.c | 63 ++++++++++++++++++++++++++++++++---------------- include/image.h | 9 ++++--- 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/boot/image-fit.c b/boot/image-fit.c index cc6aa6afd36..224205b48f2 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -2118,6 +2118,18 @@ static int select_from_config(const void *fit, struct bootm_headers *images, noffset = fit_conf_get_prop_node(fit, cfg_noffset, prop_name, image_ph_phase(ph_type)); + if (noffset < 0) { + /* + * see if this is a load-only configuration, in which case we + * allow the image to be missing. Note that the configuration + * was verified above, so that other images can be loaded. + * + * Return a special error message to indicate this. + */ + if (fdt_getprop(fit, cfg_noffset, FIT_LOAD_ONLY_PROP, NULL)) + return -ENOPKG; + } + *fit_unamep = fit_get_name(fit, noffset, NULL); return noffset; @@ -2178,6 +2190,11 @@ static int select_image(const void *fit, struct bootm_headers *images, } if (noffset < 0) { + if (noffset == -ENOPKG) { + printf(" Detected load-only image: skipping '%s'\n", + prop_name); + return -ENOPKG; + } printf("Could not find subimage node type '%s'\n", prop_name); bootstage_error(bootstage_id + BOOTSTAGE_SUB_SUBNODE); return -ENOENT; @@ -2494,32 +2511,36 @@ int fit_image_load(struct bootm_headers *images, ulong addr, noffset = select_image(fit, images, &fit_uname, fit_uname_config, prop_name, ph_type, bootstage_id, &fit_base_uname_config); - if (noffset < 0) - return noffset; + if (noffset >= 0) { - ret = check_allowed(fit, noffset, images, image_type, arch, - bootstage_id); - if (ret) - return ret; + ret = check_allowed(fit, noffset, images, image_type, arch, + bootstage_id); + if (ret) + return ret; - ret = obtain_data(fit, noffset, prop_name, bootstage_id, &buf, &len); - if (ret) - return ret; + ret = obtain_data(fit, noffset, prop_name, bootstage_id, &buf, &len); + if (ret) + return ret; - ret = handle_load_op(fit, noffset, prop_name, buf, len, image_type, - load_op, bootstage_id, &load); - if (ret) - return ret; + ret = handle_load_op(fit, noffset, prop_name, buf, len, image_type, + load_op, bootstage_id, &load); + if (ret) + return ret; - upl_add_image(fit, noffset, load, len); + upl_add_image(fit, noffset, load, len); - *datap = load; - *lenp = len; - if (fit_unamep) - *fit_unamep = (char *)fit_uname; - if (fit_uname_configp) - *fit_uname_configp = (char *)(fit_uname_config ? : - fit_base_uname_config); + *datap = load; + *lenp = len; + } + + /* note that fit_uname will always be NULL if noffset == -ENOPKG */ + if (noffset >= 0 || noffset == -ENOPKG) { + if (fit_unamep) + *fit_unamep = (char *)fit_uname; + if (fit_uname_configp) + *fit_uname_configp = (char *)(fit_uname_config ? : + fit_base_uname_config); + } return noffset; } diff --git a/include/image.h b/include/image.h index 1b8764d9906..254d1731b96 100644 --- a/include/image.h +++ b/include/image.h @@ -812,10 +812,11 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr, * @param addr Address of FIT in memory * @param fit_unamep On entry this is the requested image name * (e.g. "kernel") or NULL to use the default. On exit - * points to the selected image name + * points to the selected image name on success * @param fit_uname_configp On entry this is the requested configuration * name (e.g. "conf-1") or NULL to use the default. On - * exit points to the selected configuration name. + * exit points to the selected configuration name, on + * success or if -ENOPKG is returned * @param arch Expected architecture (IH_ARCH_...) * @param image_ph_type Required image type (IH_TYPE_...). If this is * IH_TYPE_KERNEL then we allow IH_TYPE_KERNEL_NOLOAD @@ -833,7 +834,8 @@ int boot_get_fdt_fit(struct bootm_headers *images, ulong addr, * -EACCES - hash, signature or decryptions failure * -EBADF - invalid OS or image type, or cannot get image load-address * -EXDEV - memory overwritten / overlap - * -NOEXEC - image decompression error, or invalid FDT + * -ENOEXEC - image decompression error, or invalid FDT + * -ENOPKG - image is missing, but this is a load-only image */ int fit_image_load(struct bootm_headers *images, ulong addr, const char **fit_unamep, const char **fit_uname_configp, @@ -1189,6 +1191,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, #define FIT_FIRMWARE_PROP "firmware" #define FIT_STANDALONE_PROP "standalone" #define FIT_SCRIPT_PROP "script" +#define FIT_LOAD_ONLY_PROP "load-only" #define FIT_MAX_HASH_LEN HASH_MAX_DIGEST_SIZE -- 2.43.0