diff options
| author | Stefan Hajnoczi <stefanha@redhat.com> | 2025-03-11 09:26:14 +0800 |
|---|---|---|
| committer | Stefan Hajnoczi <stefanha@redhat.com> | 2025-03-11 09:26:15 +0800 |
| commit | 6d1829fce4ea50d343f2df63eeff96685a359bf5 (patch) | |
| tree | 38dd268a019e2acddef602485225f744fa1a7c88 /plugins/api-system.c | |
| parent | 5136598e2667f35ef3dc1d757616a266bd5eb3a2 (diff) | |
| parent | 0d3dea7d7a49c22897e7435e8e09d9f587bc56c8 (diff) | |
| download | focaccia-qemu-6d1829fce4ea50d343f2df63eeff96685a359bf5.tar.gz focaccia-qemu-6d1829fce4ea50d343f2df63eeff96685a359bf5.zip | |
Merge tag 'pull-10.0-for-softfreeze-100325-3' of https://gitlab.com/stsquad/qemu into staging
functional and tcg tests, plugins and MAINTAINERS - update and expand aarch64 GPU tests - fix build dependence for plugins - update libvirt-ci to vulkan-tools - allow plugin tests to run on non-POSIX systems - tweak test/vm times - mark test-vma as linux only - various compiler fixes for tcg tests - add gitlab build unit tracker - error out early on stalled RME tests - compile core plugin code once - update MAINTAINERS # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmfOwjcACgkQ+9DbCVqe # KkRkcwgAlRTflCqYlZxdlo4CiOSXaHAFr8yfwWq138LJQRQH530JZnz1lZtxTbEM # pXT7ixnuJQDMybCQJmvUlK5UTUkZhGS3VuAR1VeM2J8/3VXYzf5sFjZ7yko9mA8S # 2FX8vdfbko8/J31+lKccA0tpbHyi2AbMR+mO8xj6KZQoePwmHoRmhgH7p7LE35YO # 8ytaOjMwTKF5fReVK+tlcrVJHFMdGsGNwtsnB2FhhVjI56fQqyM5hGXfOING2Fx3 # iZH3rjzfDB4SWbBqaRsMgH9RXjuB9Eo4v0Qs5ve5SjDyzRJk+/CbbBJ4oRt9hurJ # bA+CYZuNLGBf8Z/mUeYMavA7rxT5rw== # =qobU # -----END PGP SIGNATURE----- # gpg: Signature made Mon 10 Mar 2025 18:43:03 HKT # gpg: using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44 # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.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: 6685 AE99 E751 67BC AFC8 DF35 FBD0 DB09 5A9E 2A44 * tag 'pull-10.0-for-softfreeze-100325-3' of https://gitlab.com/stsquad/qemu: (31 commits) MAINTAINERS: remove widely sanctioned entities plugins/core: make a single build unit plugins/api: build only once plugins/api: split out time control helpers plugins/api: split out the vaddr/hwaddr helpers plugins/api: split out binary path/start/end/entry code plugins/loader: compile loader only once plugins/plugin.h: include queue.h plugins/api: clean-up the includes include/qemu: plugin-memory.h doesn't need cpu-defs.h plugins/loader: populate target_name with target_name() plugins/api: use qemu_target_page_mask() to get value tests/functional: add boot error detection for RME tests gitlab: add a new build_unit job to track build size tests/tcg: Suppress compiler false-positive warning on sha1.c tests/tcg: enable -fwrapv for test-i386-bmi tests/tcg: fix constraints in test-i386-adcox tests/tcg: add message to _Static_assert in test-avx tests/tcg: mark test-vma as a linux-only test tests/vm: bump timeout for shutdown ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'plugins/api-system.c')
| -rw-r--r-- | plugins/api-system.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/plugins/api-system.c b/plugins/api-system.c new file mode 100644 index 0000000000..cc190b167e --- /dev/null +++ b/plugins/api-system.c @@ -0,0 +1,131 @@ +/* + * QEMU Plugin API - System specific implementations + * + * This provides the APIs that have a specific system implementation + * or are only relevant to system-mode. + * + * Copyright (C) 2017, Emilio G. Cota <cota@braap.org> + * Copyright (C) 2019-2025, Linaro + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "qapi/error.h" +#include "migration/blocker.h" +#include "hw/boards.h" +#include "qemu/plugin-memory.h" +#include "qemu/plugin.h" + +/* + * In system mode we cannot trace the binary being executed so the + * helpers all return NULL/0. + */ +const char *qemu_plugin_path_to_binary(void) +{ + return NULL; +} + +uint64_t qemu_plugin_start_code(void) +{ + return 0; +} + +uint64_t qemu_plugin_end_code(void) +{ + return 0; +} + +uint64_t qemu_plugin_entry_code(void) +{ + return 0; +} + +/* + * Virtual Memory queries + */ + +static __thread struct qemu_plugin_hwaddr hwaddr_info; + +struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, + uint64_t vaddr) +{ + CPUState *cpu = current_cpu; + unsigned int mmu_idx = get_mmuidx(info); + enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info); + hwaddr_info.is_store = (rw & QEMU_PLUGIN_MEM_W) != 0; + + assert(mmu_idx < NB_MMU_MODES); + + if (!tlb_plugin_lookup(cpu, vaddr, mmu_idx, + hwaddr_info.is_store, &hwaddr_info)) { + error_report("invalid use of qemu_plugin_get_hwaddr"); + return NULL; + } + + return &hwaddr_info; +} + +bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr) +{ + return haddr->is_io; +} + +uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr) +{ + if (haddr) { + return haddr->phys_addr; + } + return 0; +} + +const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) +{ + if (h && h->is_io) { + MemoryRegion *mr = h->mr; + if (!mr->name) { + unsigned maddr = (uintptr_t)mr; + g_autofree char *temp = g_strdup_printf("anon%08x", maddr); + return g_intern_string(temp); + } else { + return g_intern_string(mr->name); + } + } else { + return g_intern_static_string("RAM"); + } +} + +/* + * Time control + */ +static bool has_control; +static Error *migration_blocker; + +const void *qemu_plugin_request_time_control(void) +{ + if (!has_control) { + has_control = true; + error_setg(&migration_blocker, + "TCG plugin time control does not support migration"); + migrate_add_blocker(&migration_blocker, NULL); + return &has_control; + } + return NULL; +} + +static void advance_virtual_time__async(CPUState *cpu, run_on_cpu_data data) +{ + int64_t new_time = data.host_ulong; + qemu_clock_advance_virtual_time(new_time); +} + +void qemu_plugin_update_ns(const void *handle, int64_t new_time) +{ + if (handle == &has_control) { + /* Need to execute out of cpu_exec, so bql can be locked. */ + async_run_on_cpu(current_cpu, + advance_virtual_time__async, + RUN_ON_CPU_HOST_ULONG(new_time)); + } +} |