Message ID | 20240206092423.3005995-4-pierrick.bouvier@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | TCG Plugin inline operation enhancement | expand |
On 2/6/24 19:24, Pierrick Bouvier wrote: > We found that vcpu_init_hook was called*after* idle callback. > vcpu_init is called from cpu_realize_fn, while idle/resume cb are called > from qemu_wait_io_event (in vcpu thread). > > This change ensures we only call idle and resume cb only once a plugin > was init for a given vcpu. > > Next change in the series will run vcpu_init asynchronously, which will > make it run*after* resume callback as well. So we fix this now. > > Signed-off-by: Pierrick Bouvier<pierrick.bouvier@linaro.org> > --- > plugins/core.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
diff --git a/plugins/core.c b/plugins/core.c index 9e64820ad02..609d9d5c184 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -392,12 +392,17 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) void qemu_plugin_vcpu_idle_cb(CPUState *cpu) { - plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE); + /* idle and resume cb may be called before init, ignore in this case */ + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE); + } } void qemu_plugin_vcpu_resume_cb(CPUState *cpu) { - plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); + } } void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id,
We found that vcpu_init_hook was called *after* idle callback. vcpu_init is called from cpu_realize_fn, while idle/resume cb are called from qemu_wait_io_event (in vcpu thread). This change ensures we only call idle and resume cb only once a plugin was init for a given vcpu. Next change in the series will run vcpu_init asynchronously, which will make it run *after* resume callback as well. So we fix this now. Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> --- plugins/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)