Merge tag 'hw-misc-20251028' of https://github.com/philmd/qemu into staging

Misc HW patches

Various fixes and cleanups:
- Set FPCR exception flag bits for HPPA non-trapped exceptions
- Convert VirtIONet::vlans from pointer to array
  and remove VMSTATE_BUFFER_POINTER_UNSAFE()
- Remove redundant QOM typedef when OBJECT_DECLARE_SIMPLE_TYPE() is used
- Have various QDev / SysBus helpers take a const device argument
- Improve errors when loaders parse images
- Remove IntelIOMMUState::dma_translation leftover
- Remove most target_[u]long uses in hw/riscv/
- Fix DS1225Y MemoryRegion owner
- Simplification refactors on Raven PCI Host Bridge

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmkAdQ8ACgkQ4+MsLN6t
# wN5ochAAihqZQaRpLWeIt+EQMUAdkJwsg8ctLAz9vJE9leZZh10j1Uw2Y0b5EDKy
# k3vwJUz0gDYnbbq33+FNBVv7Iq4bIvyundqX4odi4AOvRysJRBwkVQ+LeUo+Dyh3
# of1eKDX6psJTo4Jy1ooOkkUq0vWpJPrGZYyzR7bsPDgpuqNOfF6+mwMQkYDXa2uw
# vCJIOnzl+IIHxpnT+XVVXJsO05LUzkAru38jkjQZ1BcWj07ggSs70U7jcOhtvkpC
# x0hXcKNj+uHjoupoX8LMOb6M+D06oL6ZyW51++Cnqu/cAvQqP/VQtb7b4AAKj3G9
# yOMFZPyd4IObf7bxC4Zi/TYLYD43DrSppT4eU5zqYrzKSD6v0fdENkhqJuLTiLTa
# cd4nhWJto+EdZBogp+jVW6ekLoC5CMqNT8HiqdGvDLMp45oSmlYPC030l4gBQdo8
# 4SUWLIRZULybObv+uF3heeaemahWIXOFpclCpITcLqa+VkXlboc0JH2PjbETvAQU
# DBxSJ65izr4795rRhX5yoy2aBfiTFlYxIbpwztEzesdnAHw1N6gQ0J3WraxWSjAh
# Y6IzXBAYLjZNTx5pongcuZT3cX7Cn+0zwaK/ajRcZhIvukDL/bT7GK25akcYIgBR
# XS//Ccm79vs85o1zTBVLQzw343Bvtp4LfRLtrXjdLC+06pEixvo=
# =5G1o
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 28 Oct 2025 08:47:27 AM CET
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20251028' of https://github.com/philmd/qemu: (23 commits)
  hw/riscv: Widen OpenSBI dynamic info struct
  hw/riscv: Use generic hwaddr for firmware addresses
  hw/i386/intel_iommu: Remove an unused state field
  nw/nvram/ds1225y: Fix nvram MemoryRegion owner
  hw/ppc: Pass error_fatal to load_image_targphys()
  hw/core/loader: Pass errp to load_image_targphys_as()
  hw/core/loader: add check for zero size in load_image_targphys_as
  hw/core/loader: improve error handling in image loading functions
  hw/core/loader: capture Error from load_image_targphys
  hw/core/loader: Use qemu_open() instead of open() in get_image_size()
  hw/int/loongarch: Include missing 'system/memory.h' header
  hw/uefi: Include missing 'system/memory.h' header
  hw/sysbus: Have various helpers take a const SysBusDevice argument
  hw/qdev: Have qdev_get_gpio_out_connector() take const DeviceState arg
  hw/pci-host/raven: Simplify PCI bus creation
  hw/pci-host/raven: Use DEFINE_TYPES macro
  hw/pci-host/raven: Simplify host bridge type declaration
  hw/pci-host/raven: Simplify PCI facing part
  hw/pci-host/raven: Simplify creating PCI facing part
  migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson
2025-10-28 11:48:05 +01:00
97 changed files with 321 additions and 434 deletions
-1
View File
@@ -68,7 +68,6 @@ typedef struct CryptoDevBackendLKCFSession {
QCryptoAkCipherOptions akcipher_opts;
} CryptoDevBackendLKCFSession;
typedef struct CryptoDevBackendLKCF CryptoDevBackendLKCF;
typedef struct CryptoDevLKCFTask CryptoDevLKCFTask;
struct CryptoDevLKCFTask {
CryptoDevBackendLKCFSession *sess;
+2 -2
View File
@@ -182,7 +182,7 @@ static void clipper_init(MachineState *machine)
long initrd_base;
int64_t initrd_size;
initrd_size = get_image_size(initrd_filename);
initrd_size = get_image_size(initrd_filename, NULL);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
initrd_filename);
@@ -192,7 +192,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);
ram_size - initrd_base, NULL);
address_space_stq(&address_space_memory, param_offset + 0x100,
initrd_base + 0xfffffc0000000000ULL,
+1 -1
View File
@@ -611,7 +611,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename,
NULL, ELFDATA2LSB, EM_ARM, 1, 0, as);
if (image_size < 0) {
image_size = load_image_targphys_as(kernel_filename, mem_base,
mem_size, as);
mem_size, as, NULL);
}
if (image_size < 0) {
error_report("Could not load kernel '%s'", kernel_filename);
+3 -2
View File
@@ -964,7 +964,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
/* 32-bit ARM */
entry = info->loader_start + KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys_as(info->kernel_filename, entry,
ram_end - KERNEL_LOAD_ADDR, as);
ram_end - KERNEL_LOAD_ADDR, as,
NULL);
is_linux = 1;
if (kernel_size >= 0) {
image_low_addr = entry;
@@ -1025,7 +1026,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
info->initrd_start,
ram_end -
info->initrd_start,
as);
as, NULL);
}
if (initrd_size < 0) {
error_report("could not load initrd '%s'",
+1 -1
View File
@@ -97,7 +97,7 @@ static void digic_load_rom(DigicState *s, hwaddr addr,
exit(1);
}
rom_size = load_image_targphys(fn, addr, max_size);
rom_size = load_image_targphys(fn, addr, max_size, NULL);
if (rom_size < 0 || rom_size > max_size) {
error_report("Couldn't load rom image '%s'.", filename);
exit(1);
+2 -1
View File
@@ -235,7 +235,8 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
if (machine->firmware != NULL) {
sysboot_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
if (sysboot_filename != NULL) {
if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000) < 0) {
if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000,
NULL) < 0) {
error_report("Unable to load %s", machine->firmware);
exit(1);
}
+1 -1
View File
@@ -230,7 +230,7 @@ static void setup_boot(MachineState *machine, ARMCPU *cpu,
? FIRMWARE_ADDR_2 : FIRMWARE_ADDR_3;
/* load the firmware image (typically kernel.img) */
r = load_image_targphys(machine->firmware, firmware_addr,
ram_size - firmware_addr);
ram_size - firmware_addr, NULL);
if (r < 0) {
error_report("Failed to load firmware from %s", machine->firmware);
exit(1);
+1 -1
View File
@@ -578,7 +578,7 @@ static void vexpress_common_init(MachineState *machine)
exit(1);
}
image_size = load_image_targphys(fn, map[VE_NORFLASH0],
VEXPRESS_FLASH_SIZE);
VEXPRESS_FLASH_SIZE, NULL);
g_free(fn);
if (image_size < 0) {
error_report("Could not load ROM image '%s'", machine->firmware);
+4 -5
View File
@@ -93,7 +93,10 @@
#define ISR_RXRDY(CH) (((CH) & 1) ? BIT(5) : BIT(1))
#define ISR_BREAK(CH) (((CH) & 1) ? BIT(6) : BIT(2))
typedef struct IPOctalState IPOctalState;
#define TYPE_IPOCTAL "ipoctal232"
OBJECT_DECLARE_SIMPLE_TYPE(IPOctalState, IPOCTAL)
typedef struct SCC2698Channel SCC2698Channel;
typedef struct SCC2698Block SCC2698Block;
@@ -122,10 +125,6 @@ struct IPOctalState {
uint8_t irq_vector;
};
#define TYPE_IPOCTAL "ipoctal232"
OBJECT_DECLARE_SIMPLE_TYPE(IPOctalState, IPOCTAL)
static const VMStateDescription vmstate_scc2698_channel = {
.name = "scc2698_channel",
.version_id = 1,
-1
View File
@@ -56,7 +56,6 @@ struct XenConsole {
CharBackend chr;
int backlog;
};
typedef struct XenConsole XenConsole;
#define TYPE_XEN_CONSOLE_DEVICE "xen-console"
OBJECT_DECLARE_SIMPLE_TYPE(XenConsole, XEN_CONSOLE_DEVICE)
+3 -2
View File
@@ -148,13 +148,14 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
if (size < 0 || s->force_raw) {
/* Default to the maximum size being the machine's ram size */
size = load_image_targphys_as(s->file, s->addr, current_machine->ram_size, as);
size = load_image_targphys_as(s->file, s->addr,
current_machine->ram_size, as, errp);
} else {
s->addr = entry;
}
if (size < 0) {
error_setg(errp, "Cannot load specified image %s", s->file);
error_prepend(errp, "Cannot load specified image %s: ", s->file);
return;
}
}
+2 -1
View File
@@ -129,7 +129,8 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
g_free(propname);
}
qemu_irq qdev_get_gpio_out_connector(DeviceState *dev, const char *name, int n)
qemu_irq qdev_get_gpio_out_connector(const DeviceState *dev,
const char *name, int n)
{
g_autofree char *propname = g_strdup_printf("%s[%d]",
name ? name : "unnamed-gpio-out", n);
+2 -2
View File
@@ -101,9 +101,9 @@ static void guest_loader_realize(DeviceState *dev, Error **errp)
/* Default to the maximum size being the machine's ram size */
size = load_image_targphys_as(file, s->addr, current_machine->ram_size,
NULL);
NULL, errp);
if (size < 0) {
error_setg(errp, "Cannot load specified image %s", file);
error_prepend(errp, "Cannot load specified image %s: ", file);
return;
}
+30 -12
View File
@@ -48,6 +48,7 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
#include "qapi/type-helpers.h"
#include "qemu/units.h"
#include "trace.h"
#include "hw/hw.h"
#include "disas/disas.h"
@@ -70,14 +71,18 @@
static int roms_loaded;
/* return the size or -1 if error */
int64_t get_image_size(const char *filename)
int64_t get_image_size(const char *filename, Error **errp)
{
int fd;
int64_t size;
fd = open(filename, O_RDONLY | O_BINARY);
fd = qemu_open(filename, O_RDONLY | O_BINARY, errp);
if (fd < 0)
return -1;
size = lseek(fd, 0, SEEK_END);
if (size < 0) {
error_setg_errno(errp, errno, "lseek failure: %s", filename);
return -1;
}
close(fd);
return size;
}
@@ -118,25 +123,38 @@ ssize_t read_targphys(const char *name,
}
ssize_t load_image_targphys(const char *filename,
hwaddr addr, uint64_t max_sz)
hwaddr addr, uint64_t max_sz, Error **errp)
{
return load_image_targphys_as(filename, addr, max_sz, NULL);
return load_image_targphys_as(filename, addr, max_sz, NULL, errp);
}
/* return the size or -1 if error */
ssize_t load_image_targphys_as(const char *filename,
hwaddr addr, uint64_t max_sz, AddressSpace *as)
hwaddr addr, uint64_t max_sz, AddressSpace *as,
Error **errp)
{
ssize_t size;
size = get_image_size(filename);
if (size < 0 || size > max_sz) {
size = get_image_size(filename, errp);
if (size < 0) {
return -1;
}
if (size > 0) {
if (rom_add_file_fixed_as(filename, addr, -1, as) < 0) {
return -1;
}
if (size == 0) {
error_setg(errp, "empty file: %s", filename);
return -1;
}
if (size > max_sz) {
error_setg(errp, "%s exceeds maximum image size (%s)",
filename, size_to_str(max_sz));
return -1;
}
if (rom_add_file_fixed_as(filename, addr, -1, as) < 0) {
error_setg(errp, "could not load '%s' at %" HWADDR_PRIx,
filename, addr);
return -1;
}
return size;
}
@@ -150,7 +168,7 @@ ssize_t load_image_mr(const char *filename, MemoryRegion *mr)
return -1;
}
size = get_image_size(filename);
size = get_image_size(filename, NULL);
if (size < 0 || size > memory_region_size(mr)) {
return -1;
+5 -5
View File
@@ -80,7 +80,7 @@ static void system_bus_class_init(ObjectClass *klass, const void *data)
}
/* Check whether an IRQ source exists */
bool sysbus_has_irq(SysBusDevice *dev, int n)
bool sysbus_has_irq(const SysBusDevice *dev, int n)
{
char *prop = g_strdup_printf("%s[%d]", SYSBUS_DEVICE_GPIO_IRQ, n);
ObjectProperty *r;
@@ -91,12 +91,12 @@ bool sysbus_has_irq(SysBusDevice *dev, int n)
return (r != NULL);
}
bool sysbus_is_irq_connected(SysBusDevice *dev, int n)
bool sysbus_is_irq_connected(const SysBusDevice *dev, int n)
{
return !!sysbus_get_connected_irq(dev, n);
}
qemu_irq sysbus_get_connected_irq(SysBusDevice *dev, int n)
qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n)
{
DeviceState *d = DEVICE(dev);
return qdev_get_gpio_out_connector(d, SYSBUS_DEVICE_GPIO_IRQ, n);
@@ -114,7 +114,7 @@ void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
}
/* Check whether an MMIO region exists */
bool sysbus_has_mmio(SysBusDevice *dev, unsigned int n)
bool sysbus_has_mmio(const SysBusDevice *dev, unsigned int n)
{
return (n < dev->num_mmio);
}
@@ -190,7 +190,7 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory)
dev->mmio[n].memory = memory;
}
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n)
MemoryRegion *sysbus_mmio_get_region(const SysBusDevice *dev, int n)
{
assert(n >= 0 && n < QDEV_MAX_MMIO);
return dev->mmio[n].memory;
+2 -4
View File
@@ -111,7 +111,8 @@ typedef enum {
pl330_chan_fault = 15,
} PL330ChanState;
typedef struct PL330State PL330State;
#define TYPE_PL330 "pl330"
OBJECT_DECLARE_SIMPLE_TYPE(PL330State, PL330)
typedef struct PL330Chan {
uint32_t src;
@@ -274,9 +275,6 @@ struct PL330State {
AddressSpace *mem_as;
};
#define TYPE_PL330 "pl330"
OBJECT_DECLARE_SIMPLE_TYPE(PL330State, PL330)
static const VMStateDescription vmstate_pl330 = {
.name = "pl330",
.version_id = 2,
+3 -2
View File
@@ -493,7 +493,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
ram_addr_t initrd_base;
int64_t initrd_size;
initrd_size = get_image_size(initrd_filename);
initrd_size = get_image_size(initrd_filename, NULL);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
initrd_filename);
@@ -514,7 +514,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
exit(1);
}
load_image_targphys(initrd_filename, initrd_base, initrd_size);
load_image_targphys(initrd_filename, initrd_base, initrd_size,
NULL);
cpu[0]->env.initrd_base = initrd_base;
cpu[0]->env.initrd_end = initrd_base + initrd_size;
}
+1 -1
View File
@@ -337,7 +337,7 @@ int load_multiboot(X86MachineState *x86ms,
*next_space = '\0';
}
mb_debug("multiboot loading module: %s", one_file);
mb_mod_length = get_image_size(one_file);
mb_mod_length = get_image_size(one_file, NULL);
if (mb_mod_length < 0) {
error_report("Failed to open file '%s'", one_file);
exit(1);
+2 -2
View File
@@ -924,7 +924,7 @@ void x86_load_linux(X86MachineState *x86ms,
exit(1);
}
dtb_size = get_image_size(dtb_filename);
dtb_size = get_image_size(dtb_filename, NULL);
if (dtb_size <= 0) {
fprintf(stderr, "qemu: error reading dtb %s: %s\n",
dtb_filename, strerror(errno));
@@ -1025,7 +1025,7 @@ void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmware,
bios_name = MACHINE(x86ms)->firmware ?: default_firmware;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
bios_size = get_image_size(filename, NULL);
} else {
bios_size = -1;
}
+1 -1
View File
@@ -2211,7 +2211,7 @@ static void ipmi_fru_init(IPMIFru *fru)
goto out;
}
fsize = get_image_size(fru->filename);
fsize = get_image_size(fru->filename, NULL);
if (fsize > 0) {
size = QEMU_ALIGN_UP(fsize, fru->areasize);
fru->data = g_malloc0(size);

Some files were not shown because too many files have changed in this diff Show More