[PATCH v3] hw/arm/boot: Report error msg if loading elf/dtb failed

Changbin Du via posted 1 patch 2 months, 3 weeks ago
hw/arm/boot.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH v3] hw/arm/boot: Report error msg if loading elf/dtb failed
Posted by Changbin Du via 2 months, 3 weeks ago
Print errors before exit. Do not exit silently.

Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Changbin Du <changbin.du@huawei.com>

---
v3: use load_elf_strerror() to format errno.
v2: remove msg for arm_load_dtb.
---
 hw/arm/boot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index d480a7da02cf..6c895e05cbc0 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -839,6 +839,8 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,
                       1, data_swab, as);
     if (ret <= 0) {
         /* The header loaded but the image didn't */
+        error_report("Couldn't load elf '%s': %s",
+                     info->kernel_filename, load_elf_strerror(ret));
         exit(1);
     }
 
-- 
2.34.1


Re: [PATCH v3] hw/arm/boot: Report error msg if loading elf/dtb failed
Posted by Philippe Mathieu-Daudé 2 months, 3 weeks ago
On 3/9/24 15:39, Changbin Du wrote:
> Print errors before exit. Do not exit silently.
> 
> Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Changbin Du <changbin.du@huawei.com>
> 
> ---
> v3: use load_elf_strerror() to format errno.
> v2: remove msg for arm_load_dtb.
> ---
>   hw/arm/boot.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index d480a7da02cf..6c895e05cbc0 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -839,6 +839,8 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,
>                         1, data_swab, as);
>       if (ret <= 0) {
>           /* The header loaded but the image didn't */
> +        error_report("Couldn't load elf '%s': %s",
> +                     info->kernel_filename, load_elf_strerror(ret));
>           exit(1);
>       }
>   

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Thanks!

Re: [PATCH v3] hw/arm/boot: Report error msg if loading elf/dtb failed
Posted by Peter Maydell 2 months, 3 weeks ago
On Tue, 3 Sept 2024 at 14:52, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 3/9/24 15:39, Changbin Du wrote:
> > Print errors before exit. Do not exit silently.
> >
> > Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> > Signed-off-by: Changbin Du <changbin.du@huawei.com>
> >
> > ---
> > v3: use load_elf_strerror() to format errno.
> > v2: remove msg for arm_load_dtb.
> > ---
> >   hw/arm/boot.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> > index d480a7da02cf..6c895e05cbc0 100644
> > --- a/hw/arm/boot.c
> > +++ b/hw/arm/boot.c
> > @@ -839,6 +839,8 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,
> >                         1, data_swab, as);
> >       if (ret <= 0) {
> >           /* The header loaded but the image didn't */
> > +        error_report("Couldn't load elf '%s': %s",
> > +                     info->kernel_filename, load_elf_strerror(ret));
> >           exit(1);
> >       }
> >
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



Applied to target-arm.next, thanks.

-- PMM