mirror of
https://github.com/qemu/qemu.git
synced 2026-04-05 21:50:33 +00:00
hw/core/loader: fix error handling for load_image_targphys callers
Use QEMU's Error API to handle load_image_targphys() failures consistently across callers. - Use &error_fatal for callers that previously passed NULL, ensuring the process exits early on failure instead of continuing in an invalid state. - No functional changes. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413 Signed-off-by: Trieu Huynh <vikingtc4@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-ID: <20260318141415.8538-2-vikingtc4@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
committed by
Philippe Mathieu-Daudé
parent
56bd07a859
commit
b06bb02721
@@ -190,7 +190,7 @@ static void clipper_init(MachineState *machine)
|
||||
/* Put the initrd image as high in memory as possible. */
|
||||
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
|
||||
load_image_targphys(initrd_filename, initrd_base,
|
||||
ram_size - initrd_base, NULL);
|
||||
ram_size - initrd_base, &error_fatal);
|
||||
|
||||
address_space_stq_le(&address_space_memory, param_offset + 0x100,
|
||||
initrd_base + 0xfffffc0000000000ULL,
|
||||
|
||||
@@ -527,7 +527,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
|
||||
}
|
||||
|
||||
load_image_targphys(initrd_filename, initrd_base, initrd_size,
|
||||
NULL);
|
||||
&error_fatal);
|
||||
cpu[0]->env.initrd_base = initrd_base;
|
||||
cpu[0]->env.initrd_end = initrd_base + initrd_size;
|
||||
}
|
||||
|
||||
@@ -1326,9 +1326,16 @@ static void next_cube_init(MachineState *machine)
|
||||
memory_region_init_alias(&m->rom2, NULL, "next.rom2", &m->rom, 0x0,
|
||||
0x20000);
|
||||
memory_region_add_subregion(sysmem, 0x0, &m->rom2);
|
||||
if (load_image_targphys(bios_name, 0x01000000, 0x20000, NULL) < 8) {
|
||||
Error *local_err = NULL;
|
||||
if (load_image_targphys(bios_name, 0x01000000, 0x20000, &local_err) < 8) {
|
||||
if (!qtest_enabled()) {
|
||||
error_report("Failed to load firmware '%s'.", bios_name);
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
} else {
|
||||
error_report("Firmware image '%s' is too short.", bios_name);
|
||||
}
|
||||
} else {
|
||||
error_free(local_err);
|
||||
}
|
||||
} else {
|
||||
uint8_t *ptr;
|
||||
|
||||
@@ -633,7 +633,7 @@ static void q800_machine_init(MachineState *machine)
|
||||
|
||||
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
|
||||
load_image_targphys(initrd_filename, initrd_base,
|
||||
ram_size - initrd_base, NULL);
|
||||
ram_size - initrd_base, &error_fatal);
|
||||
BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base,
|
||||
initrd_size);
|
||||
} else {
|
||||
|
||||
@@ -292,7 +292,7 @@ static void virt_init(MachineState *machine)
|
||||
|
||||
initrd_base = (ram_size - initrd_size) & TARGET_PAGE_MASK;
|
||||
load_image_targphys(initrd_filename, initrd_base,
|
||||
ram_size - initrd_base, NULL);
|
||||
ram_size - initrd_base, &error_fatal);
|
||||
BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base,
|
||||
initrd_size);
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "hw/core/loader.h"
|
||||
#include "elf.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
#include "boot.h"
|
||||
|
||||
@@ -171,7 +172,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian,
|
||||
/* Not an ELF image nor an u-boot image, try a RAW image. */
|
||||
if (kernel_size < 0) {
|
||||
kernel_size = load_image_targphys(kernel_filename, ddr_base,
|
||||
ramsize, NULL);
|
||||
ramsize, &error_fatal);
|
||||
boot_info.bootstrap_pc = ddr_base;
|
||||
high = (ddr_base + kernel_size + 3) & ~3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user