[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/13] accel/tcg: Move @plugin_state from CPUState to TCG Acce
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 04/13] accel/tcg: Move @plugin_state from CPUState to TCG AccelCPUState |
Date: |
Tue, 30 Apr 2024 14:27:58 +0200 |
@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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240429213050.55177-5-philmd@linaro.org>
---
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(-)
diff --git a/accel/tcg/vcpu-state.h b/accel/tcg/vcpu-state.h
index e30368edae..35c2695a77 100644
--- a/accel/tcg/vcpu-state.h
+++ b/accel/tcg/vcpu-state.h
@@ -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
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 571ef3e514..91e793e590 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -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;
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index fd268c79b5..88d720d549 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -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;
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index f2826d0409..ea342213d6 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -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
diff --git a/plugins/core.c b/plugins/core.c
index a097d02788..722224e5d8 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -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;
}
--
2.41.0
- [PATCH v3 00/13] exec: Rework around CPUState user fields (part 2), Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 01/13] accel/tcg: Restrict qemu_plugin_vcpu_exit_hook() to TCG plugins, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 02/13] accel/tcg: Restrict cpu_plugin_mem_cbs_enabled() to TCG, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 03/13] accel/tcg: Move @plugin_mem_cbs from CPUState to CPUNegativeOffsetState, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 04/13] accel/tcg: Move @plugin_state from CPUState to TCG AccelCPUState,
Philippe Mathieu-Daudé <=
- [PATCH v3 05/13] accel/tcg: Restrict cpu_loop_exit_requested() to TCG, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 06/13] accel/tcg: Restrict IcountDecr / can_do_io / CPUTLB to TCG, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 07/13] accel/tcg: Move @jmp_env from CPUState to TCG AccelCPUState, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 08/13] accel/tcg: Move @cflags_next_tb from CPUState to TCG AccelCPUState, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 09/13] accel/tcg: Move @iommu_notifiers from CPUState to TCG AccelCPUState, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 10/13] accel/tcg: Move @tcg_cflags from CPUState to TCG AccelCPUState, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 11/13] accel/tcg: Restrict icount to system emulation, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 12/13] accel/tcg: Move icount fields from CPUState to TCG AccelCPUState, Philippe Mathieu-Daudé, 2024/04/30
- [PATCH v3 13/13] accel/tcg: Move @tb_jmp_cache from CPUState to TCG AccelCPUState, Philippe Mathieu-Daudé, 2024/04/30
- Re: [PATCH v3 00/13] exec: Rework around CPUState user fields (part 2), Ilya Leoshkevich, 2024/04/30