[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 19/33] accel/tcg: Use DisasContextBase in plugin_gen_tb_start
From: |
Richard Henderson |
Subject: |
[PATCH v2 19/33] accel/tcg: Use DisasContextBase in plugin_gen_tb_start |
Date: |
Tue, 16 Aug 2022 15:33:46 -0500 |
Use the pc coming from db->pc_first rather than the TB.
Use the cached host_addr rather than re-computing for the
first page. We still need a separate lookup for the second
page because it won't be computed for DisasContextBase until
the translator actually performs a read from the page.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/plugin-gen.h | 7 ++++---
accel/tcg/plugin-gen.c | 23 ++++++++++++-----------
accel/tcg/translator.c | 2 +-
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h
index f92f169739..5004728c61 100644
--- a/include/exec/plugin-gen.h
+++ b/include/exec/plugin-gen.h
@@ -19,7 +19,8 @@ struct DisasContextBase;
#ifdef CONFIG_PLUGIN
-bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool
supress);
+bool plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db,
+ bool supress);
void plugin_gen_tb_end(CPUState *cpu);
void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db);
void plugin_gen_insn_end(void);
@@ -48,8 +49,8 @@ static inline void plugin_insn_append(abi_ptr pc, const void
*from, size_t size)
#else /* !CONFIG_PLUGIN */
-static inline
-bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool
supress)
+static inline bool
+plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db, bool sup)
{
return false;
}
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index 8377c15383..0f080386af 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -852,7 +852,8 @@ static void plugin_gen_inject(const struct qemu_plugin_tb
*plugin_tb)
pr_ops();
}
-bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool
mem_only)
+bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db,
+ bool mem_only)
{
bool ret = false;
@@ -870,9 +871,9 @@ bool plugin_gen_tb_start(CPUState *cpu, const
TranslationBlock *tb, bool mem_onl
ret = true;
- ptb->vaddr = tb->pc;
+ ptb->vaddr = db->pc_first;
ptb->vaddr2 = -1;
- get_page_addr_code_hostp(cpu->env_ptr, tb->pc, true, &ptb->haddr1);
+ ptb->haddr1 = db->host_addr[0];
ptb->haddr2 = NULL;
ptb->mem_only = mem_only;
@@ -898,16 +899,16 @@ void plugin_gen_insn_start(CPUState *cpu, const
DisasContextBase *db)
* Note that we skip this when haddr1 == NULL, e.g. when we're
* fetching instructions from a region not backed by RAM.
*/
- if (likely(ptb->haddr1 != NULL && ptb->vaddr2 == -1) &&
- unlikely((db->pc_next & TARGET_PAGE_MASK) !=
- (db->pc_first & TARGET_PAGE_MASK))) {
- get_page_addr_code_hostp(cpu->env_ptr, db->pc_next,
- true, &ptb->haddr2);
- ptb->vaddr2 = db->pc_next;
- }
- if (likely(ptb->vaddr2 == -1)) {
+ if (ptb->haddr1 == NULL) {
+ pinsn->haddr = NULL;
+ } else if (is_same_page(db, db->pc_next)) {
pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr;
} else {
+ if (ptb->vaddr2 == -1) {
+ ptb->vaddr2 = TARGET_PAGE_ALIGN(db->pc_first);
+ get_page_addr_code_hostp(cpu->env_ptr, ptb->vaddr2,
+ true, &ptb->haddr2);
+ }
pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2;
}
}
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index a693c17259..3e6fab482e 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -81,7 +81,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int
max_insns,
ops->tb_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
- plugin_enabled = plugin_gen_tb_start(cpu, tb, cflags & CF_MEMI_ONLY);
+ plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY);
while (true) {
db->num_insns++;
--
2.34.1
- [PATCH v2 03/33] linux-user/x86_64: Allocate vsyscall page as a commpage, (continued)
- [PATCH v2 03/33] linux-user/x86_64: Allocate vsyscall page as a commpage, Richard Henderson, 2022/08/16
- [PATCH v2 05/33] tests/tcg/i386: Move smc_code2 to an executable section, Richard Henderson, 2022/08/16
- [PATCH v2 06/33] accel/tcg: Remove PageDesc code_bitmap, Richard Henderson, 2022/08/16
- [PATCH v2 11/33] accel/tcg: Use probe_access_internal for softmmu get_page_addr_code_hostp, Richard Henderson, 2022/08/16
- [PATCH v2 09/33] accel/tcg: Move qemu_ram_addr_from_host_nofail to physmem.c, Richard Henderson, 2022/08/16
- [PATCH v2 08/33] accel/tcg: Make tb_htable_lookup static, Richard Henderson, 2022/08/16
- [PATCH v2 04/33] linux-user: Honor PT_GNU_STACK, Richard Henderson, 2022/08/16
- [PATCH v2 14/33] accel/tcg: Raise PROT_EXEC exception early, Richard Henderson, 2022/08/16
- [PATCH v2 13/33] accel/tcg: Unlock mmap_lock after longjmp, Richard Henderson, 2022/08/16
- [PATCH v2 19/33] accel/tcg: Use DisasContextBase in plugin_gen_tb_start,
Richard Henderson <=
- [PATCH v2 21/33] include/hw/core: Create struct CPUJumpCache, Richard Henderson, 2022/08/16
- [PATCH v2 15/33] accel/tcg: Introduce is_same_page(), Richard Henderson, 2022/08/16
- [PATCH v2 17/33] accel/tcg: Add pc and host_pc params to gen_intermediate_code, Richard Henderson, 2022/08/16
- [PATCH v2 07/33] accel/tcg: Use bool for page_find_alloc, Richard Henderson, 2022/08/16
- [PATCH v2 20/33] accel/tcg: Do not align tb->page_addr[0], Richard Henderson, 2022/08/16
- [PATCH v2 12/33] accel/tcg: Add nofault parameter to get_page_addr_code_hostp, Richard Henderson, 2022/08/16
- [PATCH v2 18/33] accel/tcg: Add fast path for translator_ld*, Richard Henderson, 2022/08/16
- [PATCH v2 10/33] accel/tcg: Properly implement get_page_addr_code for user-only, Richard Henderson, 2022/08/16
- [PATCH v2 24/33] accel/tcg: Split log_cpu_exec into inline and slow path, Richard Henderson, 2022/08/16
- [PATCH v2 26/33] target/arm: Change gen_goto_tb to work on displacements, Richard Henderson, 2022/08/16