From 9b23bf5024b5c7d91cfe9233f71859208f4ffa94 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Mon, 31 Mar 2025 16:42:28 -0700 Subject: [PATCH 01/19] bsd-user: add option to enable plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing prevent plugins to be enabled on this platform for user binaries, only the option in the driver is missing. Signed-off-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250331234228.3475706-1-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- bsd-user/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 603fc80ba7..7c0a059c3b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -175,6 +175,9 @@ static void usage(void) "-strace log system calls\n" "-trace [[enable=]][,events=][,file=]\n" " specify tracing options\n" +#ifdef CONFIG_PLUGIN + "-plugin [file=][,=]\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)); From 67ce2866a76935cdea39f03e282844e3c4559f12 Mon Sep 17 00:00:00 2001 From: Steve Sistare Date: Mon, 3 Mar 2025 13:09:57 -0800 Subject: [PATCH 02/19] qom: Factor qom_resolve_path() out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Factor out a helper to resolve the user's path and print error messages. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Philippe Mathieu-Daudé Message-ID: <1741036202-265696-2-git-send-email-steven.sistare@oracle.com> Signed-off-by: Philippe Mathieu-Daudé --- qom/qom-qmp-cmds.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index e866547618..293755f409 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -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; } From dd54fc2a6b95e067bc4c3a139a0169114dba594a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Tue, 29 Apr 2025 10:42:26 +0200 Subject: [PATCH 03/19] target/migration: Inline VMSTATE_CPU() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VMSTATE_CPU() is only used in 4 places and doesn't provide much, directly inline it using VMSTATE_STRUCT(). This removes the last COMPILING_PER_TARGET in "hw/core/cpu.h". Signed-off-by: Philippe Mathieu-Daudé Acked-by: Peter Xu Reviewed-by: Richard Henderson Message-Id: <20250429085148.11876-1-philmd@linaro.org> --- include/hw/core/cpu.h | 12 ------------ target/alpha/machine.c | 2 +- target/hppa/machine.c | 2 +- target/microblaze/machine.c | 2 +- target/openrisc/machine.c | 2 +- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 12b2ff1f7d..1e87f7d393 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -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 diff --git a/target/alpha/machine.c b/target/alpha/machine.c index f09834f635..5f302b166d 100644 --- a/target/alpha/machine.c +++ b/target/alpha/machine.c @@ -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() }; diff --git a/target/hppa/machine.c b/target/hppa/machine.c index bb47a2e689..13e555151a 100644 --- a/target/hppa/machine.c +++ b/target/hppa/machine.c @@ -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() }; diff --git a/target/microblaze/machine.c b/target/microblaze/machine.c index 51705e4f5c..a4cf38dc89 100644 --- a/target/microblaze/machine.c +++ b/target/microblaze/machine.c @@ -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() }; diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index 3574e571cb..081c706d02 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -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() } From b3b3ad22c8d2e408511a08562f4277e36dedd5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 7 May 2025 22:35:37 +0200 Subject: [PATCH 04/19] accel/hvf: Include missing 'hw/core/cpu.h' header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit d5bd8d8267e ("hvf: only update sysreg from owning thread") hvf-all.c accesses the run_on_cpu_data type and calls run_on_cpu(), both defined in the "hw/core/cpu.h" header. Fortunately, it is indirectly included via: "system/hvf.h" -> "target/arm/cpu.h" -> "target/arm/cpu-qom.h" -> "hw/core/cpu.h" "system/hvf.h" however doesn't need "target/arm/cpu.h" and we want to remove it there. In order to do that we first need to include it in hvf-all.c, otherwise we get: ../accel/hvf/hvf-all.c:61:54: error: unknown type name 'run_on_cpu_data' 61 | static void do_hvf_update_guest_debug(CPUState *cpu, run_on_cpu_data arg) | ^ ../accel/hvf/hvf-all.c:68:5: error: call to undeclared function 'run_on_cpu' 68 | run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL); | ^ ../accel/hvf/hvf-all.c:68:48: error: use of undeclared identifier 'RUN_ON_CPU_NULL' 68 | run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL); | ^ Cc: Mads Ynddal Reported-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mads Ynddal Message-Id: <20250507204401.45379-1-philmd@linaro.org> --- accel/hvf/hvf-all.c | 1 + 1 file changed, 1 insertion(+) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 3fc65d6b23..8c387fda24 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -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) { From 0af34b1daccb08649a5a3c5d2d3843e5efc89ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 2 Apr 2025 13:17:28 +0200 Subject: [PATCH 05/19] system/hvf: Avoid including 'cpu.h' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "system/hvf.h" doesn't need to include a full "cpu.h", only "exec/vaddr.h" and "qemu/queue.h" are required. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Message-Id: <20250403235821.9909-27-philmd@linaro.org> --- include/system/hvf.h | 3 ++- include/system/hvf_int.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/system/hvf.h b/include/system/hvf.h index 730f927f03..d50049e1a1 100644 --- a/include/system/hvf.h +++ b/include/system/hvf.h @@ -14,10 +14,11 @@ #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 extern bool hvf_allowed; diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index 42ae18433f..8c8b84012d 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -11,6 +11,8 @@ #ifndef HVF_INT_H #define HVF_INT_H +#include "qemu/queue.h" + #ifdef __aarch64__ #include typedef hv_vcpu_t hvf_vcpuid; From 962f9f18d29ac8d229e391e4756ca586cb07e8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 4 Apr 2025 00:59:48 +0200 Subject: [PATCH 06/19] system/hvf: Expose hvf_enabled() to common code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently hvf_enabled() is restricted to target-specific code. By defining CONFIG_HVF_IS_POSSIBLE we allow its use anywhere. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20250403235821.9909-28-philmd@linaro.org> Reviewed-by: Richard Henderson --- MAINTAINERS | 1 + accel/stubs/hvf-stub.c | 12 ++++++++++++ accel/stubs/meson.build | 1 + include/system/hvf.h | 14 +++++++++----- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 accel/stubs/hvf-stub.c diff --git a/MAINTAINERS b/MAINTAINERS index 7c2b9e69ad..13f2a52c5e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -525,6 +525,7 @@ R: Phil Dennis-Jordan 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 diff --git a/accel/stubs/hvf-stub.c b/accel/stubs/hvf-stub.c new file mode 100644 index 0000000000..42eadc5ca9 --- /dev/null +++ b/accel/stubs/hvf-stub.c @@ -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; diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build index 91a2d21925..8ca1a4529e 100644 --- a/accel/stubs/meson.build +++ b/accel/stubs/meson.build @@ -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) diff --git a/include/system/hvf.h b/include/system/hvf.h index d50049e1a1..7b45a2e198 100644 --- a/include/system/hvf.h +++ b/include/system/hvf.h @@ -19,15 +19,19 @@ #include "qom/object.h" #ifdef COMPILING_PER_TARGET +# 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") From 7d49a5e8bfcaa550211d10476fa14df02bd41bdb Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:22 -0700 Subject: [PATCH 07/19] hw/hyperv/hv-balloon-stub: common compilation unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250424232829.141163-2-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index d3d2668c71..f4aa0a5ada 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -2,4 +2,5 @@ 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')) +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')) +system_ss.add(when: 'CONFIG_HV_BALLOON', if_false: files('hv-balloon-stub.c')) From 690bc5f98ac3117407ce387b09f202eaea8223a6 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:23 -0700 Subject: [PATCH 08/19] hw/hyperv/hyperv.h: header cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250424232829.141163-3-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/hyperv/hyperv.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index d717b4e13d..63a8b65278 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -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; From 4a695643a9e79d56c72c460ab0663303698931a6 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:24 -0700 Subject: [PATCH 09/19] hw/hyperv/vmbus: common compilation unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250424232829.141163-4-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/meson.build | 2 +- hw/hyperv/vmbus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index f4aa0a5ada..c855fdcf04 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -1,6 +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')) +system_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')) system_ss.add(when: 'CONFIG_HV_BALLOON', if_false: files('hv-balloon-stub.c')) diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index b147ea06d8..961406cdd6 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -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 { From 3efb9d22622110ca6cae18599169ab6ca2cc1a07 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:25 -0700 Subject: [PATCH 10/19] hw/hyperv/syndbg: common compilation unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We assume that page size is 4KB only, to dimension buffer size for receiving message. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Pierrick Bouvier Message-ID: <20250424232829.141163-5-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/meson.build | 2 +- hw/hyperv/syndbg.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index c855fdcf04..a9f2045a9a 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -1,6 +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')) system_ss.add(when: 'CONFIG_VMBUS', if_true: files('vmbus.c')) -specific_ss.add(when: 'CONFIG_SYNDBG', if_true: files('syndbg.c')) +system_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')) system_ss.add(when: 'CONFIG_HV_BALLOON', if_false: files('hv-balloon-stub.c')) diff --git a/hw/hyperv/syndbg.c b/hw/hyperv/syndbg.c index ca291826a0..8b8a14750d 100644 --- a/hw/hyperv/syndbg.c +++ b/hw/hyperv/syndbg.c @@ -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; } From 8def07485b9c08592b59ffe4953477286b9e947c Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:26 -0700 Subject: [PATCH 11/19] hw/hyperv/balloon: common balloon compilation units MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250424232829.141163-6-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index a9f2045a9a..5acd709bdd 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -2,5 +2,5 @@ specific_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c')) specific_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')) -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')) +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')) From b554e754fcf13f0606092abfc1007204316a4ff5 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:27 -0700 Subject: [PATCH 12/19] hw/hyperv/hyperv_testdev: common compilation unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250424232829.141163-7-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index 5acd709bdd..ef5a596c8a 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -1,5 +1,5 @@ specific_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c')) -specific_ss.add(when: 'CONFIG_HYPERV_TESTDEV', if_true: files('hyperv_testdev.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')) From 40316f9536cb62a05916ae5eff91e736c468b053 Mon Sep 17 00:00:00 2001 From: Pierrick Bouvier Date: Thu, 24 Apr 2025 16:28:29 -0700 Subject: [PATCH 13/19] hw/hyperv/hyperv: common compilation unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson Message-ID: <20250424232829.141163-9-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/hyperv.c | 3 ++- hw/hyperv/meson.build | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 0271cfd271..e4d0688dbf 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -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 { diff --git a/hw/hyperv/meson.build b/hw/hyperv/meson.build index ef5a596c8a..d1cf781f04 100644 --- a/hw/hyperv/meson.build +++ b/hw/hyperv/meson.build @@ -1,4 +1,4 @@ -specific_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.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')) From 4c5712eb0a454ab400ef7f29ced424f1fbf86d69 Mon Sep 17 00:00:00 2001 From: Eric Auger Date: Mon, 28 Apr 2025 12:25:27 +0200 Subject: [PATCH 14/19] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric Auger Reviewed-by: Gustavo Romero Message-ID: <20250428102628.378046-2-eric.auger@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/pci/pcie_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index 54f639e3d4..f3841a2656 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -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 = { From 353ad624f5b2920c98bca0b00d901271d5fd2684 Mon Sep 17 00:00:00 2001 From: Eric Auger Date: Mon, 28 Apr 2025 12:25:28 +0200 Subject: [PATCH 15/19] hw/acpi/ged: Fix wrong identation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric Auger Reviewed-by: Gustavo Romero Message-ID: <20250428102628.378046-3-eric.auger@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/acpi/generic_event_device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index d8adfea648..7a62f8d5bc 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -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); From 43edad68ca5bdbfb4164b46624f3b5ceb2395772 Mon Sep 17 00:00:00 2001 From: Eric Auger Date: Mon, 28 Apr 2025 12:25:29 +0200 Subject: [PATCH 16/19] hw/i386/acpi-build: Fix build_append_notfication_callback typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename build_append_notfication_callback into build_append_notification_callback Signed-off-by: Eric Auger Reviewed-by: Gustavo Romero Message-ID: <20250428102628.378046-4-eric.auger@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/acpi-build.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3fffa4a332..85c8a8566b 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -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); } From dc6da00ed77dce16975b4ca6e521fbebd5f741a5 Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Sun, 4 May 2025 21:56:37 +0000 Subject: [PATCH 17/19] hw/i386/acpi-build: Update document reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the reference for QEMU's ACPI PCI hotplug device interface. Also, use the possessive form in the comment. Signed-off-by: Gustavo Romero Message-ID: <20250504215639.54860-9-gustavo.romero@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/acpi-build.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h index 0dce155c8c..275ec058a1 100644 --- a/hw/i386/acpi-build.h +++ b/hw/i386/acpi-build.h @@ -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 From 35cb01fce6ea8aade77cbc3d7d77c83321bbaf9b Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Sun, 4 May 2025 21:56:35 +0000 Subject: [PATCH 18/19] hw/i386/acpi-build: Fix typo and grammar in comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix typo and verb conjugation in a comment about FADT initialization. Signed-off-by: Gustavo Romero Message-ID: <20250504215639.54860-7-gustavo.romero@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 85c8a8566b..f40ad062f9 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -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); From 54e54e594bc8273d210f7ff4448c165a989cbbe8 Mon Sep 17 00:00:00 2001 From: Bernhard Beschow Date: Wed, 7 May 2025 14:40:40 +0200 Subject: [PATCH 19/19] hw/i2c/imx: Always set interrupt status bit if interrupt condition occurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the i.MX 8M Plus reference manual, the status flag I2C_I2SR[IIF] continues to be set when an interrupt condition occurs even when I2C interrupts are disabled (I2C_I2CR[IIEN] is clear). However, the device model only sets the flag when I2C interrupts are enabled which causes U-Boot to loop forever. Fix the device model by always setting the flag and let I2C_I2CR[IIEN] guard I2C interrupts only. Also remove the comment in the code since it merely stated the obvious and would be outdated now. Cc: qemu-stable@nongnu.org Fixes: 20d0f9cf6a41 ("i.MX: Add I2C controller emulator") Signed-off-by: Bernhard Beschow Acked-by: Corey Minyard Message-ID: <20250507124040.425773-1-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/i2c/imx_i2c.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c index 91f84c2ad7..d26177c85d 100644 --- a/hw/i2c/imx_i2c.c +++ b/hw/i2c/imx_i2c.c @@ -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); + } } }