[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 25/29] target/i386: Use cpu_unwind_state_data for tpr access
From: |
Richard Henderson |
Subject: |
[PATCH 25/29] target/i386: Use cpu_unwind_state_data for tpr access |
Date: |
Mon, 24 Oct 2022 23:24:55 +1000 |
Avoid cpu_restore_state, and modifying env->eip out from
underneath the translator with TARGET_TB_PCREL. There is
some slight duplication from x86_restore_state_to_opc,
but it's just a few lines.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1269
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/helper.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/target/i386/helper.c b/target/i386/helper.c
index b62a1e48e2..2cd1756f1a 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -509,6 +509,23 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int
bank,
}
}
+static target_ulong get_memio_eip(CPUX86State *env)
+{
+ uint64_t data[TARGET_INSN_START_WORDS];
+ CPUState *cs = env_cpu(env);
+
+ if (!cpu_unwind_state_data(cs, cs->mem_io_pc, data)) {
+ return env->eip;
+ }
+
+ /* Per x86_restore_state_to_opc. */
+ if (TARGET_TB_PCREL) {
+ return (env->eip & TARGET_PAGE_MASK) | data[0];
+ } else {
+ return data[0] - env->segs[R_CS].base;
+ }
+}
+
void cpu_report_tpr_access(CPUX86State *env, TPRAccess access)
{
X86CPU *cpu = env_archcpu(env);
@@ -519,9 +536,9 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess
access)
cpu_interrupt(cs, CPU_INTERRUPT_TPR);
} else if (tcg_enabled()) {
- cpu_restore_state(cs, cs->mem_io_pc, false);
+ target_ulong eip = get_memio_eip(env);
- apic_handle_tpr_access_report(cpu->apic_state, env->eip, access);
+ apic_handle_tpr_access_report(cpu->apic_state, eip, access);
}
}
#endif /* !CONFIG_USER_ONLY */
--
2.34.1
- Re: [PATCH 21/29] target/tricore: Convert to tcg_ops restore_state_to_opc, (continued)
- [PATCH 23/29] accel/tcg: Remove restore_state_to_opc function, Richard Henderson, 2022/10/24
- [PATCH 20/29] target/sparc: Convert to tcg_ops restore_state_to_opc, Richard Henderson, 2022/10/24
- [PATCH 19/29] target/sh4: Convert to tcg_ops restore_state_to_opc, Richard Henderson, 2022/10/24
- [PATCH 26/29] target/openrisc: Always exit after mtspr npc, Richard Henderson, 2022/10/24
- [PATCH 25/29] target/i386: Use cpu_unwind_state_data for tpr access,
Richard Henderson <=
- [PATCH 27/29] target/openrisc: Use cpu_unwind_state_data for mfspr, Richard Henderson, 2022/10/24
- [PATCH 28/29] accel/tcg: Remove will_exit argument from cpu_restore_state, Richard Henderson, 2022/10/24
- [PATCH 24/29] accel/tcg: Introduce cpu_unwind_state_data, Richard Henderson, 2022/10/24
- [PATCH 29/29] accel/tcg: Remove reset_icount argument from cpu_restore_state_from_tb, Richard Henderson, 2022/10/24