qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/arm/boot: Explain why load_elf_hdr() error is ignored
@ 2024-09-03 14:41 Philippe Mathieu-Daudé
  2024-09-03 16:39 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-03 14:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Changbin Du, qemu-arm, Philippe Mathieu-Daudé

If the file is not an ELF file, arm_setup_direct_kernel_boot()
falls back to try it as a uimage or an AArch64 Image file or as
last resort a bare raw binary. We can discard load_elf_hdr()
error and silently return.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/boot.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index d480a7da02..45d0c6b9f2 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -799,14 +799,18 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,
     } elf_header;
     int data_swab = 0;
     bool big_endian;
-    ssize_t ret = -1;
+    ssize_t ret;
     Error *err = NULL;
 
 
     load_elf_hdr(info->kernel_filename, &elf_header, &elf_is64, &err);
     if (err) {
+        /*
+         * If the file is not an ELF file we silently return.
+         * The caller will fall back to try other formats.
+         */
         error_free(err);
-        return ret;
+        return -1;
     }
 
     if (elf_is64) {
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hw/arm/boot: Explain why load_elf_hdr() error is ignored
  2024-09-03 14:41 [PATCH] hw/arm/boot: Explain why load_elf_hdr() error is ignored Philippe Mathieu-Daudé
@ 2024-09-03 16:39 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2024-09-03 16:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Changbin Du, qemu-arm

On Tue, 3 Sept 2024 at 15:41, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> If the file is not an ELF file, arm_setup_direct_kernel_boot()
> falls back to try it as a uimage or an AArch64 Image file or as
> last resort a bare raw binary. We can discard load_elf_hdr()
> error and silently return.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-03 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 14:41 [PATCH] hw/arm/boot: Explain why load_elf_hdr() error is ignored Philippe Mathieu-Daudé
2024-09-03 16:39 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).