Misc HW patches

- Allow using plugins on BSD user-emulation
 - Inline VMSTATE_CPU() macro
 - Fix header includes for HVF x86
 - Build hw/hyperv/ files once
 - Various typo fixed
 - Fix issue in i.MX I2C model
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmgco7IACgkQ4+MsLN6t
 wN5b/RAAvI+0Fyo/QNTjUQKBsFT7M9DY2bv2rxElG5+gwQvrqRkwV4POjJ42TFbl
 NazNnywIW2eZvjQ1W3pBceiAhXAOxRi/zSTRO30uhL0DFmfAIEF6aMZdVZKg01mq
 U/x5WF3WM8taXYE5V8kgV+Rr6b02SMGgtUcNVTnDjVdmRI0+ByPf122IwniKffhR
 kJhPj4tgU/wBsOisgPTAr1kbQePyvbvckxKc1kt73jPRV6fUtVV14qcrBN6zECV3
 +uFit6Q/zYH21XpFdq/3X9lEjMZNGI6zBZ939/x5Bpj53MjmYovYY81987ioAB7S
 zsmFZ2Nl7L/8l/jKrhKPS+l71OzmLI1dMzr2CrOxgMhXxfItta9y04CLDf7ZXSf6
 mgDE3rA89C33dzoGnb4axphmcposyM/u0lLhGgnMh3GFv84P6/DqgxKZv8vj6OMq
 U/DhHPw507W/JAg8ge/5YchVJwxKfBbHm0y7NLqH1IGmoyyqsMQo6DbC9/zTK7T4
 dAZdcrm2dBbSxYaL5J8gTGPo/QjVG9BaU9EvKIcZf181QSHg//QCYB6iN5Phx5hO
 KH9hUTmpqA4Lza0XGGUM1c43/24Dq/i1I0EncW4zqFqaf9l9M06i5cdQrU+myzAs
 O/dLsFlm7WAJLDkt2Ax2peYKHVKpGywFRsCR04uulkoLoD5nd/w=
 =1VOP
 -----END PGP SIGNATURE-----

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

Misc HW patches

- Allow using plugins on BSD user-emulation
- Inline VMSTATE_CPU() macro
- Fix header includes for HVF x86
- Build hw/hyperv/ files once
- Various typo fixed
- Fix issue in i.MX I2C model

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmgco7IACgkQ4+MsLN6t
# wN5b/RAAvI+0Fyo/QNTjUQKBsFT7M9DY2bv2rxElG5+gwQvrqRkwV4POjJ42TFbl
# NazNnywIW2eZvjQ1W3pBceiAhXAOxRi/zSTRO30uhL0DFmfAIEF6aMZdVZKg01mq
# U/x5WF3WM8taXYE5V8kgV+Rr6b02SMGgtUcNVTnDjVdmRI0+ByPf122IwniKffhR
# kJhPj4tgU/wBsOisgPTAr1kbQePyvbvckxKc1kt73jPRV6fUtVV14qcrBN6zECV3
# +uFit6Q/zYH21XpFdq/3X9lEjMZNGI6zBZ939/x5Bpj53MjmYovYY81987ioAB7S
# zsmFZ2Nl7L/8l/jKrhKPS+l71OzmLI1dMzr2CrOxgMhXxfItta9y04CLDf7ZXSf6
# mgDE3rA89C33dzoGnb4axphmcposyM/u0lLhGgnMh3GFv84P6/DqgxKZv8vj6OMq
# U/DhHPw507W/JAg8ge/5YchVJwxKfBbHm0y7NLqH1IGmoyyqsMQo6DbC9/zTK7T4
# dAZdcrm2dBbSxYaL5J8gTGPo/QjVG9BaU9EvKIcZf181QSHg//QCYB6iN5Phx5hO
# KH9hUTmpqA4Lza0XGGUM1c43/24Dq/i1I0EncW4zqFqaf9l9M06i5cdQrU+myzAs
# O/dLsFlm7WAJLDkt2Ax2peYKHVKpGywFRsCR04uulkoLoD5nd/w=
# =1VOP
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 08 May 2025 08:29:38 EDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20250508' of https://github.com/philmd/qemu:
  hw/i2c/imx: Always set interrupt status bit if interrupt condition occurs
  hw/i386/acpi-build: Fix typo and grammar in comment
  hw/i386/acpi-build: Update document reference
  hw/i386/acpi-build: Fix build_append_notfication_callback typo
  hw/acpi/ged: Fix wrong identation
  hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
  hw/hyperv/hyperv: common compilation unit
  hw/hyperv/hyperv_testdev: common compilation unit
  hw/hyperv/balloon: common balloon compilation units
  hw/hyperv/syndbg: common compilation unit
  hw/hyperv/vmbus: common compilation unit
  hw/hyperv/hyperv.h: header cleanup
  hw/hyperv/hv-balloon-stub: common compilation unit
  system/hvf: Expose hvf_enabled() to common code
  system/hvf: Avoid including 'cpu.h'
  accel/hvf: Include missing 'hw/core/cpu.h' header
  target/migration: Inline VMSTATE_CPU()
  qom: Factor qom_resolve_path() out
  bsd-user: add option to enable plugins

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2025-05-09 12:04:10 -04:00
commit f9bb7e53a3
23 changed files with 94 additions and 58 deletions

View file

@ -525,6 +525,7 @@ R: Phil Dennis-Jordan <phil@philjordan.eu>
W: https://wiki.qemu.org/Features/HVF
S: Maintained
F: accel/hvf/
F: accel/stubs/hvf-stub.c
F: include/system/hvf.h
F: include/system/hvf_int.h

View file

@ -12,6 +12,7 @@
#include "qemu/error-report.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
#include "hw/core/cpu.h"
const char *hvf_return_string(hv_return_t ret)
{

12
accel/stubs/hvf-stub.c Normal file
View file

@ -0,0 +1,12 @@
/*
* HVF stubs for QEMU
*
* Copyright (c) Linaro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "system/hvf.h"
bool hvf_allowed;

View file

@ -2,5 +2,6 @@ system_stubs_ss = ss.source_set()
system_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)

View file

@ -175,6 +175,9 @@ static void usage(void)
"-strace log system calls\n"
"-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
" specify tracing options\n"
#ifdef CONFIG_PLUGIN
"-plugin [file=]<file>[,<argname>=<argvalue>]\n"
#endif
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
@ -225,6 +228,8 @@ static void init_task_state(TaskState *ts)
};
}
static QemuPluginList plugins = QTAILQ_HEAD_INITIALIZER(plugins);
void gemu_log(const char *fmt, ...)
{
va_list ap;
@ -307,6 +312,7 @@ int main(int argc, char **argv)
cpu_model = NULL;
qemu_add_opts(&qemu_trace_opts);
qemu_plugin_add_opts();
optind = 1;
for (;;) {
@ -399,6 +405,11 @@ int main(int argc, char **argv)
do_strace = 1;
} else if (!strcmp(r, "trace")) {
trace_opt_parse(optarg);
#ifdef CONFIG_PLUGIN
} else if (!strcmp(r, "plugin")) {
r = argv[optind++];
qemu_plugin_opt_parse(r, &plugins);
#endif
} else if (!strcmp(r, "0")) {
argv0 = argv[optind++];
} else {
@ -433,6 +444,7 @@ int main(int argc, char **argv)
exit(1);
}
trace_init_file();
qemu_plugin_load_list(&plugins, &error_fatal);
/* Zero out regs */
memset(regs, 0, sizeof(struct target_pt_regs));

View file

@ -458,11 +458,11 @@ static void acpi_ged_initfn(Object *obj)
* container for memory hotplug IO and expose it as GED sysbus
* MMIO so that boards can map it separately.
*/
memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
MEMORY_HOTPLUG_IO_LEN);
sysbus_init_mmio(sbd, &s->container_memhp);
acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
&s->memhp_state, 0);
memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
MEMORY_HOTPLUG_IO_LEN);
sysbus_init_mmio(sbd, &s->container_memhp);
acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
&s->memhp_state, 0);
memory_region_init_io(&ged_st->regs, obj, &ged_regs_ops, ged_st,
TYPE_ACPI_GED "-regs", ACPI_GED_REG_COUNT);

View file

@ -13,6 +13,8 @@
#include "qapi/error.h"
#include "system/address-spaces.h"
#include "system/memory.h"
#include "exec/target_page.h"
#include "linux/kvm.h"
#include "system/kvm.h"
#include "qemu/bitops.h"
#include "qemu/error-report.h"
@ -23,7 +25,6 @@
#include "hw/hyperv/hyperv.h"
#include "qom/object.h"
#include "target/i386/kvm/hyperv-proto.h"
#include "target/i386/cpu.h"
#include "exec/target_page.h"
struct SynICState {

View file

@ -1,5 +1,6 @@
specific_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'))
specific_ss.add(when: 'CONFIG_HYPERV_TESTDEV', if_true: files('hyperv_testdev.c'))
specific_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c'))
specific_ss.add(when: 'CONFIG_SYNDBG', if_true: files('syndbg.c'))
specific_ss.add(when: 'CONFIG_HV_BALLOON', if_true: files('hv-balloon.c', 'hv-balloon-page_range_tree.c', 'hv-balloon-our_range_memslots.c'), if_false: files('hv-balloon-stub.c'))
system_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'))
system_ss.add(when: 'CONFIG_HYPERV_TESTDEV', if_true: files('hyperv_testdev.c'))
system_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c'))
system_ss.add(when: 'CONFIG_SYNDBG', if_true: files('syndbg.c'))
system_ss.add(when: 'CONFIG_HV_BALLOON', if_true: files('hv-balloon.c', 'hv-balloon-page_range_tree.c', 'hv-balloon-our_range_memslots.c'))
system_ss.add(when: 'CONFIG_HV_BALLOON', if_false: files('hv-balloon-stub.c'))

View file

@ -10,11 +10,11 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/sockets.h"
#include "qemu/units.h"
#include "qapi/error.h"
#include "migration/vmstate.h"
#include "hw/qdev-properties.h"
#include "hw/loader.h"
#include "cpu.h"
#include "exec/target_page.h"
#include "hw/hyperv/hyperv.h"
#include "hw/hyperv/vmbus-bridge.h"
@ -184,12 +184,15 @@ static bool create_udp_pkt(HvSynDbg *syndbg, void *pkt, uint32_t pkt_len,
return true;
}
#define MSG_BUFSZ (4 * KiB)
static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa,
uint32_t count, bool is_raw, uint32_t options,
uint64_t timeout, uint32_t *retrieved_count)
{
uint16_t ret;
uint8_t data_buf[TARGET_PAGE_SIZE - UDP_PKT_HEADER_SIZE];
g_assert(MSG_BUFSZ >= qemu_target_page_size());
uint8_t data_buf[MSG_BUFSZ];
hwaddr out_len;
void *out_data;
ssize_t recv_byte_count;
@ -202,7 +205,7 @@ static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa,
recv_byte_count = 0;
} else {
recv_byte_count = recv(syndbg->socket, data_buf,
MIN(sizeof(data_buf), count), MSG_WAITALL);
MIN(MSG_BUFSZ, count), MSG_WAITALL);
if (recv_byte_count == -1) {
return HV_STATUS_INVALID_PARAMETER;
}

View file

@ -19,7 +19,7 @@
#include "hw/hyperv/vmbus.h"
#include "hw/hyperv/vmbus-bridge.h"
#include "hw/sysbus.h"
#include "cpu.h"
#include "exec/target_page.h"
#include "trace.h"
enum {

View file

@ -79,13 +79,12 @@ static void imx_i2c_reset(DeviceState *dev)
static inline void imx_i2c_raise_interrupt(IMXI2CState *s)
{
/*
* raise an interrupt if the device is enabled and it is configured
* to generate some interrupts.
*/
if (imx_i2c_is_enabled(s) && imx_i2c_interrupt_is_enabled(s)) {
if (imx_i2c_is_enabled(s)) {
s->i2sr |= I2SR_IIF;
qemu_irq_raise(s->irq);
if (imx_i2c_interrupt_is_enabled(s)) {
qemu_irq_raise(s->irq);
}
}
}

View file

@ -139,7 +139,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
/*
* "ICH9-LPC" or "PIIX4_PM" has "smm-compat" property to keep the old
* behavior for compatibility irrelevant to smm_enabled, which doesn't
* comforms to ACPI spec.
* conform to the ACPI spec.
*/
bool smm_enabled = object_property_get_bool(o, "smm-compat", NULL) ?
true : x86_machine_is_smm_enabled(x86ms);
@ -589,8 +589,8 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)
}
}
static bool build_append_notfication_callback(Aml *parent_scope,
const PCIBus *bus)
static bool build_append_notification_callback(Aml *parent_scope,
const PCIBus *bus)
{
Aml *method;
PCIBus *sec;
@ -604,7 +604,7 @@ static bool build_append_notfication_callback(Aml *parent_scope,
continue;
}
nr_notifiers = nr_notifiers +
build_append_notfication_callback(br_scope, sec);
build_append_notification_callback(br_scope, sec);
/*
* add new child scope to parent
* and keep track of bus that have PCNT,
@ -1773,7 +1773,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
PCIBus *b = PCI_HOST_BRIDGE(pci_host)->bus;
scope = aml_scope("\\_SB.PCI0");
has_pcnt = build_append_notfication_callback(scope, b);
has_pcnt = build_append_notification_callback(scope, b);
if (has_pcnt) {
aml_append(dsdt, scope);
}

View file

@ -5,7 +5,7 @@
extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */
/* PCI Hot-plug registers' base. See docs/specs/acpi_pci_hotplug.rst */
#define ACPI_PCIHP_SEJ_BASE 0x8
#define ACPI_PCIHP_BNMR_BASE 0x10

View file

@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus)
return dsp_count;
}
static bool pcie_slot_is_hotpluggbale_bus(HotplugHandler *plug_handler,
static bool pcie_slot_is_hotpluggable_bus(HotplugHandler *plug_handler,
BusState *bus)
{
PCIESlot *s = PCIE_SLOT(bus->parent);
@ -221,7 +221,7 @@ static void pcie_slot_class_init(ObjectClass *oc, const void *data)
hc->plug = pcie_cap_slot_plug_cb;
hc->unplug = pcie_cap_slot_unplug_cb;
hc->unplug_request = pcie_cap_slot_unplug_request_cb;
hc->is_hotpluggable_bus = pcie_slot_is_hotpluggbale_bus;
hc->is_hotpluggable_bus = pcie_slot_is_hotpluggable_bus;
}
static const TypeInfo pcie_slot_type_info = {

View file

@ -1121,20 +1121,8 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);
#ifdef COMPILING_PER_TARGET
extern const VMStateDescription vmstate_cpu_common;
#define VMSTATE_CPU() { \
.name = "parent_obj", \
.size = sizeof(CPUState), \
.vmsd = &vmstate_cpu_common, \
.flags = VMS_STRUCT, \
.offset = 0, \
}
#endif /* COMPILING_PER_TARGET */
#define UNASSIGNED_CPU_INDEX -1
#define UNASSIGNED_CLUSTER_INDEX -1

View file

@ -10,7 +10,8 @@
#ifndef HW_HYPERV_HYPERV_H
#define HW_HYPERV_HYPERV_H
#include "cpu-qom.h"
#include "exec/hwaddr.h"
#include "hw/core/cpu.h"
#include "hw/hyperv/hyperv-proto.h"
typedef struct HvSintRoute HvSintRoute;

View file

@ -14,19 +14,24 @@
#define HVF_H
#include "qemu/accel.h"
#include "qemu/queue.h"
#include "exec/vaddr.h"
#include "qom/object.h"
#ifdef COMPILING_PER_TARGET
#include "cpu.h"
# ifdef CONFIG_HVF
# define CONFIG_HVF_IS_POSSIBLE
# endif /* !CONFIG_HVF */
#else
# define CONFIG_HVF_IS_POSSIBLE
#endif /* COMPILING_PER_TARGET */
#ifdef CONFIG_HVF
#ifdef CONFIG_HVF_IS_POSSIBLE
extern bool hvf_allowed;
#define hvf_enabled() (hvf_allowed)
#else /* !CONFIG_HVF */
#else /* !CONFIG_HVF_IS_POSSIBLE */
#define hvf_enabled() 0
#endif /* !CONFIG_HVF */
#endif /* COMPILING_PER_TARGET */
#endif /* !CONFIG_HVF_IS_POSSIBLE */
#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")

View file

@ -11,6 +11,8 @@
#ifndef HVF_INT_H
#define HVF_INT_H
#include "qemu/queue.h"
#ifdef __aarch64__
#include <Hypervisor/Hypervisor.h>
typedef hv_vcpu_t hvf_vcpuid;

View file

@ -28,15 +28,11 @@
#include "qom/object_interfaces.h"
#include "qom/qom-qobject.h"
ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
static Object *qom_resolve_path(const char *path, Error **errp)
{
Object *obj;
bool ambiguous = false;
ObjectPropertyInfoList *props = NULL;
ObjectProperty *prop;
ObjectPropertyIterator iter;
Object *obj = object_resolve_path(path, &ambiguous);
obj = object_resolve_path(path, &ambiguous);
if (obj == NULL) {
if (ambiguous) {
error_setg(errp, "Path '%s' is ambiguous", path);
@ -44,6 +40,19 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", path);
}
}
return obj;
}
ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
{
Object *obj;
ObjectPropertyInfoList *props = NULL;
ObjectProperty *prop;
ObjectPropertyIterator iter;
obj = qom_resolve_path(path, errp);
if (obj == NULL) {
return NULL;
}

View file

@ -74,7 +74,7 @@ static const VMStateDescription vmstate_env = {
};
static const VMStateField vmstate_cpu_fields[] = {
VMSTATE_CPU(),
VMSTATE_STRUCT(parent_obj, AlphaCPU, 0, vmstate_cpu_common, CPUState),
VMSTATE_STRUCT(env, AlphaCPU, 1, vmstate_env, CPUAlphaState),
VMSTATE_END_OF_LIST()
};

View file

@ -216,7 +216,7 @@ static const VMStateDescription vmstate_env = {
};
static const VMStateField vmstate_cpu_fields[] = {
VMSTATE_CPU(),
VMSTATE_STRUCT(parent_obj, HPPACPU, 0, vmstate_cpu_common, CPUState),
VMSTATE_STRUCT(env, HPPACPU, 1, vmstate_env, CPUHPPAState),
VMSTATE_END_OF_LIST()
};

View file

@ -93,7 +93,7 @@ static const VMStateDescription vmstate_env = {
};
static const VMStateField vmstate_cpu_fields[] = {
VMSTATE_CPU(),
VMSTATE_STRUCT(parent_obj, MicroBlazeCPU, 0, vmstate_cpu_common, CPUState),
VMSTATE_STRUCT(env, MicroBlazeCPU, 1, vmstate_env, CPUMBState),
VMSTATE_END_OF_LIST()
};

View file

@ -136,7 +136,7 @@ const VMStateDescription vmstate_openrisc_cpu = {
.minimum_version_id = 1,
.post_load = cpu_post_load,
.fields = (const VMStateField[]) {
VMSTATE_CPU(),
VMSTATE_STRUCT(parent_obj, OpenRISCCPU, 0, vmstate_cpu_common, CPUState),
VMSTATE_STRUCT(env, OpenRISCCPU, 1, vmstate_env, CPUOpenRISCState),
VMSTATE_END_OF_LIST()
}