accel/tcg: Use DisasContextBase in plugin_gen_tb_start
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. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
f79542afa7
commit
b21af662c1
@ -852,7 +852,8 @@ static void plugin_gen_inject(const struct qemu_plugin_tb *plugin_tb)
|
|||||||
pr_ops();
|
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;
|
bool ret = false;
|
||||||
|
|
||||||
@ -870,9 +871,9 @@ bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool mem_onl
|
|||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
ptb->vaddr = tb->pc;
|
ptb->vaddr = db->pc_first;
|
||||||
ptb->vaddr2 = -1;
|
ptb->vaddr2 = -1;
|
||||||
get_page_addr_code_hostp(cpu->env_ptr, tb->pc, &ptb->haddr1);
|
ptb->haddr1 = db->host_addr[0];
|
||||||
ptb->haddr2 = NULL;
|
ptb->haddr2 = NULL;
|
||||||
ptb->mem_only = mem_only;
|
ptb->mem_only = mem_only;
|
||||||
|
|
||||||
@ -898,16 +899,15 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db)
|
|||||||
* Note that we skip this when haddr1 == NULL, e.g. when we're
|
* Note that we skip this when haddr1 == NULL, e.g. when we're
|
||||||
* fetching instructions from a region not backed by RAM.
|
* fetching instructions from a region not backed by RAM.
|
||||||
*/
|
*/
|
||||||
if (likely(ptb->haddr1 != NULL && ptb->vaddr2 == -1) &&
|
if (ptb->haddr1 == NULL) {
|
||||||
unlikely((db->pc_next & TARGET_PAGE_MASK) !=
|
pinsn->haddr = NULL;
|
||||||
(db->pc_first & TARGET_PAGE_MASK))) {
|
} else if (is_same_page(db, db->pc_next)) {
|
||||||
get_page_addr_code_hostp(cpu->env_ptr, db->pc_next,
|
|
||||||
&ptb->haddr2);
|
|
||||||
ptb->vaddr2 = db->pc_next;
|
|
||||||
}
|
|
||||||
if (likely(ptb->vaddr2 == -1)) {
|
|
||||||
pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr;
|
pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr;
|
||||||
} else {
|
} else {
|
||||||
|
if (ptb->vaddr2 == -1) {
|
||||||
|
ptb->vaddr2 = TARGET_PAGE_ALIGN(db->pc_first);
|
||||||
|
get_page_addr_code_hostp(cpu->env_ptr, ptb->vaddr2, &ptb->haddr2);
|
||||||
|
}
|
||||||
pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2;
|
pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
|
|||||||
ops->tb_start(db, cpu);
|
ops->tb_start(db, cpu);
|
||||||
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
|
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) {
|
while (true) {
|
||||||
db->num_insns++;
|
db->num_insns++;
|
||||||
|
@ -19,7 +19,8 @@ struct DisasContextBase;
|
|||||||
|
|
||||||
#ifdef CONFIG_PLUGIN
|
#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_tb_end(CPUState *cpu);
|
||||||
void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db);
|
void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db);
|
||||||
void plugin_gen_insn_end(void);
|
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 */
|
#else /* !CONFIG_PLUGIN */
|
||||||
|
|
||||||
static inline
|
static inline bool
|
||||||
bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool supress)
|
plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db, bool sup)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user