From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, Claudio Fontana <cfontana@suse.de>
Subject: [PULL v2 06/13] target/i386: Use cpu_unwind_state_data for tpr access
Date: Tue, 1 Nov 2022 09:00:17 +1100 [thread overview]
Message-ID: <20221031220020.414768-3-richard.henderson@linaro.org> (raw)
In-Reply-To: <20221031220020.414768-1-richard.henderson@linaro.org>
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
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/helper.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/target/i386/helper.c b/target/i386/helper.c
index b62a1e48e2..0ac2da066d 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -509,6 +509,27 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank,
}
}
+static inline target_ulong get_memio_eip(CPUX86State *env)
+{
+#ifdef CONFIG_TCG
+ 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;
+ }
+#else
+ qemu_build_not_reached();
+#endif
+}
+
void cpu_report_tpr_access(CPUX86State *env, TPRAccess access)
{
X86CPU *cpu = env_archcpu(env);
@@ -519,9 +540,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
next prev parent reply other threads:[~2022-10-31 22:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 21:57 [PULL v2 00/13] tcg-next patch queue Richard Henderson
2022-10-31 21:57 ` [PULL v2 01/13] tcg/sparc: Remove support for sparc32plus Richard Henderson
2022-10-31 21:57 ` [PULL v2 02/13] tcg/sparc64: Rename from tcg/sparc Richard Henderson
2022-10-31 21:57 ` [PULL v2 03/13] tcg/sparc64: Remove sparc32plus constraints Richard Henderson
2022-10-31 22:00 ` [PULL v2 04/13] tcg/tci: fix logic error when registering helpers via FFI Richard Henderson
2022-10-31 22:00 ` [PULL v2 05/13] accel/tcg: Introduce cpu_unwind_state_data Richard Henderson
2022-10-31 22:00 ` Richard Henderson [this message]
2022-10-31 22:00 ` [PULL v2 07/13] target/openrisc: Always exit after mtspr npc Richard Henderson
2022-10-31 22:00 ` [PULL v2 08/13] target/openrisc: Use cpu_unwind_state_data for mfspr Richard Henderson
2022-10-31 22:00 ` [PULL v2 09/13] accel/tcg: Remove will_exit argument from cpu_restore_state Richard Henderson
2022-10-31 22:01 ` [PULL v2 10/13] accel/tcg: Remove reset_icount argument from cpu_restore_state_from_tb Richard Henderson
2022-10-31 22:01 ` [PULL v2 11/13] target/i386: Expand eflags updates inline Richard Henderson
2022-10-31 22:01 ` [PULL v2 12/13] accel/tcg: Complete cpu initialization before registration Richard Henderson
2022-10-31 22:01 ` [PULL v2 13/13] tests/tcg/multiarch: Add munmap-pthread.c Richard Henderson
2022-11-01 15:03 ` [PULL v2 00/13] tcg-next patch queue Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221031220020.414768-3-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=cfontana@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).