qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 28/34] accel/tcg: Make plugin-gen.c target independent


From: Anton Johansson
Subject: [RFC PATCH 28/34] accel/tcg: Make plugin-gen.c target independent
Date: Fri, 19 Jan 2024 15:40:18 +0100

Switches computation of offsets into CPUState to use that the offset
between CPUState and CPUArchState is guaranteed to be sizeof(CPUState).

Signed-off-by: Anton Johansson <anjo@rev.ng>
---
 accel/tcg/plugin-gen.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index d31c9993ea..ce7635958f 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -43,10 +43,9 @@
  * CPU's index into a TCG temp, since the first callback did it already.
  */
 #include "qemu/osdep.h"
-#include "cpu.h"
 #include "tcg/tcg.h"
 #include "tcg/tcg-temp-internal.h"
-#include "tcg/tcg-op.h"
+#include "tcg/tcg-op-common.h"
 #include "exec/exec-all.h"
 #include "exec/plugin-gen.h"
 #include "exec/translator.h"
@@ -104,8 +103,8 @@ static void gen_empty_udata_cb(void)
     TCGv_ptr udata = tcg_temp_ebb_new_ptr();
 
     tcg_gen_movi_ptr(udata, 0);
-    tcg_gen_ld_i32(cpu_index, tcg_env,
-                   -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
+    tcg_gen_ld_i32(cpu_index, tcg_env, offsetof(CPUState, cpu_index) -
+                                       sizeof(CPUState));
     gen_helper_plugin_vcpu_udata_cb(cpu_index, udata);
 
     tcg_temp_free_ptr(udata);
@@ -138,8 +137,8 @@ static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info)
 
     tcg_gen_movi_i32(meminfo, info);
     tcg_gen_movi_ptr(udata, 0);
-    tcg_gen_ld_i32(cpu_index, tcg_env,
-                   -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
+    tcg_gen_ld_i32(cpu_index, tcg_env, offsetof(CPUState, cpu_index) -
+                                       sizeof(CPUState));
 
     gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, addr, udata);
 
@@ -158,7 +157,7 @@ static void gen_empty_mem_helper(void)
 
     tcg_gen_movi_ptr(ptr, 0);
     tcg_gen_st_ptr(ptr, tcg_env, offsetof(CPUState, plugin_mem_cbs) -
-                                 offsetof(ArchCPU, env));
+                                 sizeof(CPUState));
     tcg_temp_free_ptr(ptr);
 }
 
@@ -582,7 +581,7 @@ void plugin_gen_disable_mem_helpers(void)
         return;
     }
     tcg_gen_st_ptr(tcg_constant_ptr(NULL), tcg_env,
-                   offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, 
env));
+                   offsetof(CPUState, plugin_mem_cbs) - sizeof(CPUState));
 }
 
 static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb,
-- 
2.43.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]