@@ -10,11 +10,16 @@
/**
* AccelCPUState: vCPU fields specific to TCG accelerator
+ * @plugin_state: per-CPU plugin state
*/
struct AccelCPUState {
#ifdef CONFIG_USER_ONLY
TaskState *ts;
#endif /* !CONFIG_USER_ONLY */
+
+#ifdef CONFIG_PLUGIN
+ CPUPluginState *plugin_state;
+#endif /* CONFIG_PLUGIN */
};
#ifdef CONFIG_USER_ONLY
@@ -423,7 +423,6 @@ struct qemu_work_item;
* @kvm_fd: vCPU file descriptor for KVM.
* @work_mutex: Lock to prevent multiple access to @work_list.
* @work_list: List of pending asynchronous work.
- * @plugin_state: per-CPU plugin state
* @ignore_memory_transaction_failures: Cached copy of the MachineState
* flag of the same name: allows the board to suppress calling of the
* CPU do_transaction_failed hook function.
@@ -514,10 +513,6 @@ struct CPUState {
/* Use by accel-block: CPU is executing an ioctl() */
QemuLockCnt in_ioctl_lock;
-#ifdef CONFIG_PLUGIN
- CPUPluginState *plugin_state;
-#endif
-
/* TODO Move common fields from CPUArchState here. */
int cpu_index;
int cluster_index;
@@ -52,6 +52,7 @@
#include "exec/plugin-gen.h"
#include "exec/translator.h"
#include "exec/helper-proto-common.h"
+#include "accel/tcg/vcpu-state.h"
#define HELPER_H "accel/tcg/plugin-helpers.h"
#include "exec/helper-info.c.inc"
@@ -872,7 +873,8 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db,
{
bool ret = false;
- if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_state->event_mask)) {
+ if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS,
+ cpu->accel->plugin_state->event_mask)) {
struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb;
int i;
@@ -31,6 +31,7 @@
#include "hw/qdev-properties.h"
#include "trace.h"
#ifdef CONFIG_PLUGIN
+#include "accel/tcg/vcpu-state.h" // ???
#include "qemu/plugin.h"
#endif
@@ -215,7 +216,7 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
/* Plugin initialization must wait until the cpu start executing code */
#ifdef CONFIG_PLUGIN
if (tcg_enabled()) {
- cpu->plugin_state = qemu_plugin_create_vcpu_state();
+ cpu->accel->plugin_state = qemu_plugin_create_vcpu_state();
async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL);
}
#endif
@@ -28,6 +28,7 @@
#include "exec/tb-flush.h"
#include "tcg/tcg.h"
#include "tcg/tcg-op.h"
+#include "accel/tcg/vcpu-state.h"
#include "plugin.h"
struct qemu_plugin_cb {
@@ -55,7 +56,7 @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id)
static void plugin_cpu_update__async(CPUState *cpu, run_on_cpu_data data)
{
- bitmap_copy(cpu->plugin_state->event_mask,
+ bitmap_copy(cpu->accel->plugin_state->event_mask,
&data.host_ulong, QEMU_PLUGIN_EV_MAX);
tcg_flush_jmp_cache(cpu);
}
@@ -396,7 +397,7 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a2,
struct qemu_plugin_cb *cb, *next;
enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL;
- if (!test_bit(ev, cpu->plugin_state->event_mask)) {
+ if (!test_bit(ev, cpu->accel->plugin_state->event_mask)) {
return;
}
@@ -418,7 +419,7 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret)
struct qemu_plugin_cb *cb, *next;
enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL_RET;
- if (!test_bit(ev, cpu->plugin_state->event_mask)) {
+ if (!test_bit(ev, cpu->accel->plugin_state->event_mask)) {
return;
}
@plugin_state is specific to TCG accelerator, move it to its AccelCPUState. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- TODO: check dubious include of "accel/tcg/vcpu-state.h" in hw/core/cpu-common.c. --- accel/tcg/vcpu-state.h | 5 +++++ include/hw/core/cpu.h | 5 ----- accel/tcg/plugin-gen.c | 4 +++- hw/core/cpu-common.c | 3 ++- plugins/core.c | 7 ++++--- 5 files changed, 14 insertions(+), 10 deletions(-)