Hi all!

I was trying to implement falcon boot on TI AM62x EVM with the kernel image on
SD card's filesystem but the following check in `_spl_load` at
`include/spl_load.h:95` fails to -EIO as per the latest commit [89d3333]:

        return read < spl_image->size ? -EIO : 0;

The check seems to be comparing the image size gathered from the header
(spl_image->size) with the number of bytes read form the loader.

>From spl_load.h:

        ret = spl_parse_image_header(spl_image, bootdev, header);
        if (ret)
                return ret;

        base_offset = spl_image->offset;
        /* Only NOR sets this flag. */
        if (IS_ENABLED(CONFIG_SPL_NOR_SUPPORT) &&
            spl_image->flags & SPL_COPY_PAYLOAD_ONLY)
                base_offset += sizeof(*header);
        image_offset = ALIGN_DOWN(base_offset, spl_get_bl_len(info));
        overhead = base_offset - image_offset;
        size = ALIGN(spl_image->size + overhead, spl_get_bl_len(info));

        read = info->read(info, offset + image_offset, size,
                          map_sysmem(spl_image->load_addr - overhead, size));

        if (read < 0)
                return read;

        return read < spl_image->size ? -EIO : 0;

During kernel build process the header size is computed including the BSS
whereas it's removed when creating the uncompressed image. Therefore the size
of the uncompressed image on filesystem will be smaller than the size specified
in the header. Which leads to failure of the above check.

>From linux kernel's `arch/arm64/kernel/image.h:63`:

        #define HEAD_SYMBOLS                                            \
                DEFINE_IMAGE_LE64(_kernel_size_le, _end - _text);       \
                DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS);

Disabling the check leads to a successful boot directly to the kernel.
Therefore it seems like the check is non functional as the size in the kernel
header does not correspond with the file size of the kernel image.

Regards,
Anshul

Reply via email to