Final fixes for 10.0

- properly exit aarch64-softmmu tcg tests on unexpected exceptions
  - fix deadlock when uninstalling a plugin
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmf2P+0ACgkQ+9DbCVqe
 KkTHdAf/b4CGLNJBS7UV/eYxhgxJ2TM4KgfXm4FvrcS4V5rpNheMuLoQzgYDY+EC
 5ioANRcY+rOK2Yd+upO4SbaUyAvf7C5kAtMgs6AYiqbm5F8b47FS/q8f9mBBJ+qB
 tl2FU6hjVjymMRoaPqqpPkkkHy9YNHe48TP4ohGfD6336JA5MW6v8nhdK+d3fsan
 AUCSWAe8gxjmM6qnrhku6vvJ5EOiqpsb8zhsWVXdZesSG+1ATm6KCo6hDd0OkMrk
 si6ML5txU1rxx5VOkGlDUo7ZV2TE/zdgMyaP/kXGtKuj+ipLMzqNjlD50xPJu05b
 o4hTbt8erzxduVHrBKT5qhKQl8BEpw==
 =LN/t
 -----END PGP SIGNATURE-----

Merge tag 'pull-10.0-final-fixes-090425-1' of https://gitlab.com/stsquad/qemu into staging

Final fixes for 10.0

 - properly exit aarch64-softmmu tcg tests on unexpected exceptions
 - fix deadlock when uninstalling a plugin

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmf2P+0ACgkQ+9DbCVqe
# KkTHdAf/b4CGLNJBS7UV/eYxhgxJ2TM4KgfXm4FvrcS4V5rpNheMuLoQzgYDY+EC
# 5ioANRcY+rOK2Yd+upO4SbaUyAvf7C5kAtMgs6AYiqbm5F8b47FS/q8f9mBBJ+qB
# tl2FU6hjVjymMRoaPqqpPkkkHy9YNHe48TP4ohGfD6336JA5MW6v8nhdK+d3fsan
# AUCSWAe8gxjmM6qnrhku6vvJ5EOiqpsb8zhsWVXdZesSG+1ATm6KCo6hDd0OkMrk
# si6ML5txU1rxx5VOkGlDUo7ZV2TE/zdgMyaP/kXGtKuj+ipLMzqNjlD50xPJu05b
# o4hTbt8erzxduVHrBKT5qhKQl8BEpw==
# =LN/t
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 09 Apr 2025 05:37:49 EDT
# 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-final-fixes-090425-1' of https://gitlab.com/stsquad/qemu:
  tests/tcg/plugins: add plugin to test reset and uninstall
  plugins/loader: fix deadlock when resetting/uninstalling a plugin
  tests/tcg: fix semihosting SYS_EXIT for aarch64 in boot.S

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2025-04-14 11:02:09 -04:00
commit 5befef5eed
4 changed files with 77 additions and 5 deletions

View File

@ -370,7 +370,7 @@ static void plugin_reset_destroy(struct qemu_plugin_reset_data *data)
{ {
qemu_rec_mutex_lock(&plugin.lock); qemu_rec_mutex_lock(&plugin.lock);
plugin_reset_destroy__locked(data); plugin_reset_destroy__locked(data);
qemu_rec_mutex_lock(&plugin.lock); qemu_rec_mutex_unlock(&plugin.lock);
} }
static void plugin_flush_destroy(CPUState *cpu, run_on_cpu_data arg) static void plugin_flush_destroy(CPUState *cpu, run_on_cpu_data arg)

View File

@ -73,9 +73,8 @@ lower_a32_serror:
mov x0, SYS_WRITE0 mov x0, SYS_WRITE0
adr x1, .error adr x1, .error
semihosting_call semihosting_call
mov x0, SYS_EXIT mov x0, 1 /* EXIT_FAILURE */
mov x1, 1 bl _exit
semihosting_call
/* never returns */ /* never returns */
.section .rodata .section .rodata

View File

@ -1,6 +1,6 @@
t = [] t = []
if get_option('plugins') if get_option('plugins')
foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall']
if host_os == 'windows' if host_os == 'windows'
t += shared_module(i, files(i + '.c') + '../../../contrib/plugins/win32_linker.c', t += shared_module(i, files(i + '.c') + '../../../contrib/plugins/win32_linker.c',
include_directories: '../../../include/qemu', include_directories: '../../../include/qemu',

73
tests/tcg/plugins/reset.c Normal file
View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2025 Linaro Ltd
*
* Test the reset/uninstall cycle of a plugin.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <glib.h>
#include <qemu-plugin.h>
QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
static qemu_plugin_id_t plugin_id;
static bool was_reset;
static bool was_uninstalled;
static void after_uninstall(qemu_plugin_id_t id)
{
g_assert(was_reset && !was_uninstalled);
qemu_plugin_outs("uninstall done\n");
was_uninstalled = true;
}
static void tb_exec_after_reset(unsigned int vcpu_index, void *userdata)
{
g_assert(was_reset && !was_uninstalled);
qemu_plugin_uninstall(plugin_id, after_uninstall);
}
static void tb_trans_after_reset(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
{
g_assert(was_reset && !was_uninstalled);
qemu_plugin_register_vcpu_tb_exec_cb(tb, tb_exec_after_reset,
QEMU_PLUGIN_CB_NO_REGS, NULL);
}
static void after_reset(qemu_plugin_id_t id)
{
g_assert(!was_reset && !was_uninstalled);
qemu_plugin_outs("reset done\n");
was_reset = true;
qemu_plugin_register_vcpu_tb_trans_cb(id, tb_trans_after_reset);
}
static void tb_exec_before_reset(unsigned int vcpu_index, void *userdata)
{
g_assert(!was_reset && !was_uninstalled);
qemu_plugin_reset(plugin_id, after_reset);
}
static void tb_trans_before_reset(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
{
g_assert(!was_reset && !was_uninstalled);
qemu_plugin_register_vcpu_tb_exec_cb(tb, tb_exec_before_reset,
QEMU_PLUGIN_CB_NO_REGS, NULL);
}
QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
const qemu_info_t *info,
int argc, char **argv)
{
plugin_id = id;
qemu_plugin_register_vcpu_tb_trans_cb(id, tb_trans_before_reset);
return 0;
}
/* Since we uninstall the plugin, we can't use qemu_plugin_register_atexit_cb,
* so we use destructor attribute instead. */
static void __attribute__((destructor)) on_plugin_exit(void)
{
g_assert(was_reset && was_uninstalled);
qemu_plugin_outs("plugin exit\n");
}