Pierrick Bouvier and Alex Bennée
278035fc81
plugins: fix race condition with scoreboards
...
A deadlock can be created if a new vcpu (a) triggers a scoreboard
reallocation, and another vcpu (b) wants to create a new scoreboard at
the same time.
In this case, (a) holds the plugin lock, and starts an exclusive
section, waiting for (b). But at the same time, (b) is waiting for
plugin lock.
The solution is to drop the lock before entering the exclusive section.
This bug can be easily reproduced by creating a callback for any tb
exec, that allocates a new scoreboard. In this case, as soon as we reach
more than 16 vcpus, the deadlock occurs.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2344
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240812220748.95167-2-pierrick.bouvier@linaro.org >
[AJB: tweak var position to meet coding style]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20240813202329.1237572-22-alex.bennee@linaro.org >
2024-08-16 14:13:07 +01:00
Philippe Mathieu-Daudé and Alex Bennée
20fdd01e51
buildsys: Fix building without plugins on Darwin
...
Since commit 0082475e26 the plugin symbol list is unconditionally
added to the linker flags, leading to a build failure:
Undefined symbols for architecture arm64:
"_qemu_plugin_entry_code", referenced from:
<initial-undefines>
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Fix by restricting the whole meson file to the --enable-plugins
configure argument.
Fixes: 0082475e26 ("meson: merge plugin_ldflags into emulator_link_args")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2476
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Acked-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20240813112457.92560-1-philmd@linaro.org >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240813202329.1237572-9-alex.bennee@linaro.org >
2024-08-16 14:04:19 +01:00
Alex Bennée
7b690fd3d0
plugin/loader: handle basic help query
...
As the list of options isn't fixed we do all the parsing by hand.
Without any named arguments we automatically fill the "file" option
with the value give so check if it is requesting help and dump some
basic usage text.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240729144414.830369-15-alex.bennee@linaro.org >
2024-07-30 11:44:21 +01:00
Philippe Mathieu-Daudé and Alex Bennée
0f3974b64c
accel/tcg: Move qemu_plugin_vcpu_init__async() to plugins/
...
Calling qemu_plugin_vcpu_init__async() on the vCPU thread
is a detail of plugins, not relevant to TCG vCPU management.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240606124010.2460-4-philmd@linaro.org >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240705084047.857176-30-alex.bennee@linaro.org >
2024-07-05 12:34:55 +01:00
Philippe Mathieu-Daudé and Alex Bennée
2089a2e5bb
plugins: Ensure vCPU index is assigned in init/exit hooks
...
Since vCPUs are hashed by their index, this index can't
be uninitialized (UNASSIGNED_CPU_INDEX).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240606124010.2460-2-philmd@linaro.org >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240705084047.857176-28-alex.bennee@linaro.org >
2024-07-05 12:34:48 +01:00
Paolo Bonzini
0082475e26
meson: merge plugin_ldflags into emulator_link_args
...
These serve the same purpose, except plugin_ldflags ends up in the linker
command line in a more roundabout way (through specific_ss). Simplify.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2024-07-03 18:41:25 +02:00
Pierrick Bouvier and Alex Bennée
ca7d7f4276
plugins: fix inject_mem_cb rw masking
...
These are not booleans, but masks.
Issue found by Richard Henderson.
Fixes: f86fd4d872 ("plugins: distinct types for callbacks")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240612195147.93121-3-pierrick.bouvier@linaro.org >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240620152220.2192768-12-alex.bennee@linaro.org >
2024-06-24 10:15:16 +01:00
Alex Bennée
508036532c
plugins: add migration blocker
...
If the plugin in controlling time there is some state that might be
missing from the plugin tracking it. Migration is unlikely to work in
this case so lets put a migration blocker in to let the user know if
they try.
Suggested-by: Dr. David Alan Gilbert <dave@treblig.org >
Reviewed-by: Thomas Huth <thuth@redhat.com >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240620152220.2192768-10-alex.bennee@linaro.org >
2024-06-24 10:15:10 +01:00
Alex Bennée
847a65dd76
plugins: add time control API
...
Expose the ability to control time through the plugin API. Only one
plugin can control time so it has to request control when loaded.
There are probably more corner cases to catch here.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
[AJB: tweaked user-mode handling, merged QEMU_PLUGIN_API fix]
Message-Id: <20240530220610.1245424-6-pierrick.bouvier@linaro.org >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240620152220.2192768-9-alex.bennee@linaro.org >
2024-06-24 10:15:04 +01:00
Akihiko Odaki and Alex Bennée
ad59d5caee
plugins: Ensure register handles are not NULL
...
Ensure register handles are not NULL so that a plugin can assume NULL is
invalid as a register handle.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com >
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240229-null-v1-1-e716501d981e@daynix.com >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20240620152220.2192768-4-alex.bennee@linaro.org >
2024-06-24 10:14:22 +01:00
Alex Bennée and Philippe Mathieu-Daudé
2fa16246dd
plugins: remove special casing for cpu->realized
...
Now the condition variable is initialised early on we don't need to go
through hoops to avoid calling async_run_on_cpu.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-ID: <20240530194250.1801701-5-alex.bennee@linaro.org >
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org >
2024-06-04 10:02:39 +02:00
Pierrick Bouvier and Alex Bennée
09afe9677e
plugins: remove op from qemu_plugin_inline_cb
...
This field is not needed as the callback type already holds this
information.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240502211522.346467-10-pierrick.bouvier@linaro.org >
Reviewed-by: Michael S. Tsirkin <mst@redhat.com >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240514174253.694591-12-alex.bennee@linaro.org >
2024-05-16 08:55:23 +01:00
Pierrick Bouvier and Alex Bennée
f86fd4d872
plugins: distinct types for callbacks
...
To prevent errors when writing new types of callbacks or inline
operations, we split callbacks data to distinct types.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240502211522.346467-8-pierrick.bouvier@linaro.org >
Reviewed-by: Michael S. Tsirkin <mst@redhat.com >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240514174253.694591-10-alex.bennee@linaro.org >
2024-05-16 08:55:23 +01:00
Pierrick Bouvier and Alex Bennée
7de77d3788
plugins: conditional callbacks
...
Extend plugins API to support callback called with a given criteria
(evaluated inline).
Added functions:
- qemu_plugin_register_vcpu_tb_exec_cond_cb
- qemu_plugin_register_vcpu_insn_exec_cond_cb
They expect as parameter a condition, a qemu_plugin_u64_t (op1) and an
immediate (op2). Callback is called if op1 |cond| op2 is true.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240502211522.346467-6-pierrick.bouvier@linaro.org >
Reviewed-by: Michael S. Tsirkin <mst@redhat.com >
[AJB: fix re-base conflict with tb_is_mem_only()]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240514174253.694591-8-alex.bennee@linaro.org >
2024-05-16 08:55:02 +01:00
Pierrick Bouvier and Alex Bennée
36a1d8e710
plugins: add new inline op STORE_U64
...
This new operation can store an immediate u64 value to a given
scoreboard.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Message-Id: <20240502211522.346467-4-pierrick.bouvier@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Michael S. Tsirkin <mst@redhat.com >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240514174253.694591-6-alex.bennee@linaro.org >
2024-05-16 08:47:01 +01:00
Pierrick Bouvier and Alex Bennée
21032784e5
plugins: prepare introduction of new inline ops
...
Until now, only add_u64 was available, and all functions assumed this or
were named uniquely.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Michael S. Tsirkin <mst@redhat.com >
Signed-off-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20240514174253.694591-4-alex.bennee@linaro.org >
2024-05-16 08:47:01 +01:00
Richard Henderson
4c833c60e0
disas: Use translator_st to get disassembly data
...
Read from already translated pages, or saved mmio data.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-15 08:55:19 +02:00
Richard Henderson
e763953a24
plugins: Use DisasContextBase for qemu_plugin_tb_vaddr
...
We do not need to separately record the start of the TB.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-15 08:55:18 +02:00
Richard Henderson
d3ace10590
plugins: Use DisasContextBase for qemu_plugin_insn_haddr
...
We can delay the computation of haddr until the plugin
actually requests it.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-15 08:55:18 +02:00
Richard Henderson
e501325991
plugins: Read mem_only directly from TB cflags
...
Do not pass around a boolean between multiple structures,
just read it from the TranslationBlock in the TCGContext.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-15 08:55:18 +02:00
Richard Henderson
36bc99bc78
plugins: Use translator_st for qemu_plugin_insn_data
...
Use the bytes that we record for the entire TB, rather than
a per-insn GByteArray. Record the length of the insn in
plugin_gen_insn_end rather than infering from the length
of the array.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-15 08:55:18 +02:00
Richard Henderson
4abc892362
plugins: Copy memory in qemu_plugin_insn_data
...
Instead of returning a host pointer, copy the data into
storage provided by the caller.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-15 08:55:18 +02:00
Philippe Mathieu-Daudé
80f034c5b2
accel/tcg: Move @plugin_mem_cbs from CPUState to CPUNegativeOffsetState
...
@plugin_mem_cbs is accessed by tcg generated code, move it
to CPUNegativeOffsetState.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20240429213050.55177-4-philmd@linaro.org >
2024-05-06 11:24:14 +02:00
Richard Henderson
97c872276d
Merge tag 'accel-sh4-ui-20240503' of https://github.com/philmd/qemu into staging
...
- Fix NULL dereference in NVMM & WHPX init_vcpu()
- Move user emulation headers "exec/user" to "user"
- Fix SH-4 ADDV / SUBV opcodes
- Drop Cocoa compatility on macOS <= 10.12
- Update Anthony PERARD email
# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmY1BE4ACgkQ4+MsLN6t
# wN73jg//dbdHQU+4oM7BgTduDZn1ulKz5DtNEJawRP6vxIcSQ+Co2Yd+gdLOSXNI
# 2BaoiOQ8cyDEHj1Uud3WVB0GsQYvHrqgXcjeHpX6yFFCZNyRvzEXizJPHKCtq+4e
# XQFtfTFftlJdaKCLqyDqVnrVNRacFPm7kinrEQbTSmglAhwnyu3GwsokDAYiJTqp
# g0n6mX/pWVEMDNY1HrDsk2Q/pyIZFmzhtuRyXRvi/bh8/BnmMCpySG+2463dnu1O
# xIGr2w8ldc+mKn2w2k3wYKDnUHz/NhOkE86tL/ZxIgjCzeenZXwXNdzM+cuAmOZX
# L9KIu5io6bTevYVwwHhd5/N6MCqVEhoRmsUQfF0CIkIzxXbyF14M89YHXZo3YJAd
# n2uoJ7i6hF/4Pt6Uqlg09+vEk7onwrobnTPnbKHEKNWHNOMKXpq1CBxxcVz2qe24
# +CTAAOOhHqaTjODPSexzHZDZYxugCy1XSqps9AFF1HqUcmsPCL/PQ75YGTJJO0oF
# 0V1Yvzjhin26AQS9SglIeXnHxYC26Cg2mXnUpVbryWnG888r0XAGpRl+FEuXK7Ln
# /dGuCIWTozypSkG9304IlxlYsOoXhL11NZqINW+W/Tor3dMRQhWUQcHqv98Jl4Ad
# rnpzZ0Dhd9ityZdbI0CCMZZZLY5dw1Rq5q407GTJr1CDU4PJBh0=
# =N8q0
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 03 May 2024 08:35:42 AM PDT
# gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org >" [full]
* tag 'accel-sh4-ui-20240503' of https://github.com/philmd/qemu :
ui/cocoa.m: Drop old macOS-10.12-and-earlier compat ifdefs
target/sh4: Rename TCGv variables as manual for SUBV opcode
target/sh4: Rename TCGv variables as manual for ADDV opcode
target/sh4: Fix SUBV opcode
target/sh4: Fix ADDV opcode
MAINTAINERS: Update my email address
plugins: Update stale comment
plugins/api: Only include 'exec/ram_addr.h' with system emulation
coverity: Update user emulation regexp
user: Move 'thunk.h' from 'exec/user' to 'user'
user: Move 'abitypes.h' from 'exec/user' to 'user'
exec: Include missing license in 'exec/cpu-common.h'
accel/whpx: Fix NULL dereference in whpx_init_vcpu()
accel/nvmm: Fix NULL dereference in nvmm_init_vcpu()
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2024-05-03 14:42:50 -07:00
Philippe Mathieu-Daudé
e096d370ad
plugins: Update stale comment
...
"plugin_mask" was renamed as "event_mask" in commit c006147122
("plugins: create CPUPluginState and migrate plugin_mask").
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20240427155714.53669-3-philmd@linaro.org >
2024-05-03 17:21:20 +02:00