[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH-for-9.1 10/27] target/i386: Convert to TCGCPUOps::get_cpu_state()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH-for-9.1 10/27] target/i386: Convert to TCGCPUOps::get_cpu_state() |
Date: |
Tue, 19 Mar 2024 16:42:39 +0100 |
Convert cpu_get_tb_cpu_state() to TCGCPUOps::get_cpu_state().
Note, now x86_get_cpu_state() is restricted to TCG.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/i386/cpu.h | 16 ----------------
target/i386/cpu.c | 2 +-
target/i386/tcg/tcg-cpu.c | 15 +++++++++++++++
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 954495fff0..390abc969e 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2354,22 +2354,6 @@ static inline int cpu_mmu_index_kernel(CPUX86State *env)
#include "hw/i386/apic.h"
#endif
-#define TARGET_HAS_CPU_GET_TB_CPU_STATE
-
-static inline void cpu_get_tb_cpu_state(CPUX86State *env, vaddr *pc,
- uint64_t *cs_base, uint32_t *flags)
-{
- *flags = env->hflags |
- (env->eflags & (IOPL_MASK | TF_MASK | RF_MASK | VM_MASK | AC_MASK));
- if (env->hflags & HF_CS64_MASK) {
- *cs_base = 0;
- *pc = env->eip;
- } else {
- *cs_base = env->segs[R_CS].base;
- *pc = (uint32_t)(*cs_base + env->eip);
- }
-}
-
void do_cpu_init(X86CPU *cpu);
#define MCE_INJECT_BROADCAST 1
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 9a210d8d92..249b6fe0bb 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7679,7 +7679,7 @@ static vaddr x86_cpu_get_pc(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);
- /* Match cpu_get_tb_cpu_state. */
+ /* Match x86_get_cpu_state. */
return cpu->env.eip + cpu->env.segs[R_CS].base;
}
diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c
index cca19cd40e..a89c11a34b 100644
--- a/target/i386/tcg/tcg-cpu.c
+++ b/target/i386/tcg/tcg-cpu.c
@@ -93,6 +93,20 @@ static void x86_restore_state_to_opc(CPUState *cs,
}
}
+static inline void x86_get_cpu_state(CPUX86State *env, vaddr *pc,
+ uint64_t *cs_base, uint32_t *flags)
+{
+ *flags = env->hflags |
+ (env->eflags & (IOPL_MASK | TF_MASK | RF_MASK | VM_MASK | AC_MASK));
+ if (env->hflags & HF_CS64_MASK) {
+ *cs_base = 0;
+ *pc = env->eip;
+ } else {
+ *cs_base = env->segs[R_CS].base;
+ *pc = (uint32_t)(*cs_base + env->eip);
+ }
+}
+
#ifndef CONFIG_USER_ONLY
static bool x86_debug_check_breakpoint(CPUState *cs)
{
@@ -110,6 +124,7 @@ static const TCGCPUOps x86_tcg_ops = {
.initialize = tcg_x86_init,
.synchronize_from_tb = x86_cpu_synchronize_from_tb,
.restore_state_to_opc = x86_restore_state_to_opc,
+ .get_cpu_state = x86_get_cpu_state,
.cpu_exec_enter = x86_cpu_exec_enter,
.cpu_exec_exit = x86_cpu_exec_exit,
#ifdef CONFIG_USER_ONLY
--
2.41.0
- [PATCH-for-9.1 00/27] accel/tcg: Introduce TCGCPUOps::get_cpu_state() handler, Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 01/27] accel/tcg: Ensure frontends define restore_state_to_opc handler, Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 02/27] accel/tcg: Introduce TCGCPUOps::get_cpu_state() handler, Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 03/27] target/alpha: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 04/27] target/arm: Restrict TCG-specific declarations, Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 05/27] target/arm: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 06/27] target/avr: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 07/27] target/cris: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 09/27] target/hppa: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 10/27] target/i386: Convert to TCGCPUOps::get_cpu_state(),
Philippe Mathieu-Daudé <=
- [PATCH-for-9.1 08/27] target/hexagon: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 11/27] target/loongarch: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 12/27] target/m68k: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 13/27] target/microblaze: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 15/27] target/nios2: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 14/27] target/mips: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 16/27] target/openrisc: Convert to TCGCPUOps::get_cpu_state(), Philippe Mathieu-Daudé, 2024/03/19
- [PATCH-for-9.1 17/27] target/ppc: Indent ppc_tcg_ops[] with 4 spaces, Philippe Mathieu-Daudé, 2024/03/19