accel/tcg: Revert mapping of PCREL translation block to multiple virtual addresses
PATCH 1/1 accel/tcg: Revert mapping of PCREL translation block to multiple virtual addresses
This is causing regressions that have not been analyzed yet. Revert the change on stable branches.
Cc: [email protected]
Cc: Michael Tokarev <[email protected]>
Related: https://gitlab.com/qemu-project/qemu/-/issues/2092
Signed-off-by Paolo Bonzini <[email protected]>
--- include/exec/exec-all.h | 6 ------ accel/tcg/cpu-exec.c | 4 ++-- accel/tcg/tb-maint.c | 6 +++--- accel/tcg/translate-all.c | 2 -- 4 files changed, 5 insertions(+), 13 deletions(-)
include/exec/exec-all.h +0 -6
@@ -503,7 +503,6 @@ struct tb_tc { };struct TranslationBlock { -#if !TARGET_TB_PCREL /* * Guest PC corresponding to this block. This must be the true * virtual address. Therefore e.g. x86 stores EIP + CS_BASE, and
@@ -518,7 +517,6 @@ struct TranslationBlock {* deposited into the "current" PC. */ target_ulong pc; -#endif /* * Target-specific data associated with the TranslationBlock, e.g.:
@@ -604,11 +602,7 @@ struct TranslationBlock {/* Hide the read to avoid ifdefs for TARGET_TB_PCREL. */ static inline target_ulong tb_pc (const TranslationBlock *tb) { -#if TARGET_TB_PCREL -qemu_build_not_reached (); -#else return tb->pc; -#endif }/* Hide the qatomic_read to make code a little easier on the eyes */
accel/tcg/cpu-exec.c +2 -2
@@ -186,7 +186,7 @@ static bool tb_lookup_cmp(const void *p, const void *d)const TranslationBlock *tb = p;const struct tb_desc *desc = d; - if ((TARGET_TB_PCREL || tb_pc(tb) == desc->pc) && + if (tb_pc(tb) == desc->pc && tb_page_addr0(tb) == desc->page_addr0 && tb->cs_base == desc->cs_base && tb->flags == desc->flags &&
@@ -238,7 +238,7 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,return NULL ; } desc.page_addr0 = phys_pc; - h =tb_hash_func (phys_pc, (TARGET_TB_PCREL ?0 : pc), + h =tb_hash_func (phys_pc, pc, flags, cflags, *cpu->trace_dstate);return qht_lookup_custom (&tb_ctx.htable, &desc, h, tb_lookup_cmp); }
accel/tcg/tb-maint.c +3 -3
@@ -34,7 +34,7 @@ static bool tb_cmp(const void *ap, const void *bp)const TranslationBlock *a = ap;const TranslationBlock *b = bp; - return ((TARGET_TB_PCREL || tb_pc(a) == tb_pc(b)) && + return (tb_pc(a) == tb_pc(b) && a->cs_base == b->cs_base && a->flags == b->flags && (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) &&
@@ -269,7 +269,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)/* remove the TB from the hash list */ phys_pc =tb_page_addr0 (tb); - h =tb_hash_func (phys_pc, (TARGET_TB_PCREL ?0 :tb_pc (tb)), + h =tb_hash_func (phys_pc,tb_pc (tb), tb->flags, orig_cflags, tb->trace_vcpu_dstate);if (!qht_remove (&tb_ctx.htable, tb, h)) {return ;
@@ -459,7 +459,7 @@ TranslationBlock *tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, }/* add in the hash table */ - h =tb_hash_func (phys_pc, (TARGET_TB_PCREL ?0 :tb_pc (tb)), + h =tb_hash_func (phys_pc,tb_pc (tb), tb->flags, tb->cflags, tb->trace_vcpu_dstate);qht_insert (&tb_ctx.htable, tb, h, &existing_tb);
accel/tcg/translate-all.c +0 -2
@@ -818,9 +818,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, gen_code_buf = tcg_ctx->code_gen_ptr; tb->tc.ptr =tcg_splitwx_to_rx (gen_code_buf); -#if !TARGET_TB_PCREL tb->pc = pc; -#endif tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags;
Signature · 1 line
2.43.0
PATCH 1/1 accel/tcg: Revert mapping of PCREL translation block to multiple virtual addresses
This is causing regressions that have not been analyzed yet. Revert the change on stable branches.
Related: https://gitlab.com/qemu-project/qemu/-/issues/2092
Signed-off-by Paolo Bonzini <[email protected]>
--- include/exec/exec-all.h | 6 ------ accel/tcg/cpu-exec.c | 4 ++-- accel/tcg/tb-maint.c | 6 +++--- accel/tcg/translate-all.c | 2 -- 4 files changed, 5 insertions(+), 13 deletions(-)
include/exec/exec-all.h +0 -6
@@ -503,7 +503,6 @@ struct tb_tc { };struct TranslationBlock { -#if !TARGET_TB_PCREL /* * Guest PC corresponding to this block. This must be the true * virtual address. Therefore e.g. x86 stores EIP + CS_BASE, and
@@ -518,7 +517,6 @@ struct TranslationBlock {* deposited into the "current" PC. */ target_ulong pc; -#endif /* * Target-specific data associated with the TranslationBlock, e.g.:
@@ -604,11 +602,7 @@ struct TranslationBlock {/* Hide the read to avoid ifdefs for TARGET_TB_PCREL. */ static inline target_ulong tb_pc (const TranslationBlock *tb) { -#if TARGET_TB_PCREL -qemu_build_not_reached (); -#else return tb->pc; -#endif }/* Hide the qatomic_read to make code a little easier on the eyes */
accel/tcg/cpu-exec.c +2 -2
@@ -186,7 +186,7 @@ static bool tb_lookup_cmp(const void *p, const void *d)const TranslationBlock *tb = p;const struct tb_desc *desc = d; - if ((TARGET_TB_PCREL || tb_pc(tb) == desc->pc) && + if (tb_pc(tb) == desc->pc && tb_page_addr0(tb) == desc->page_addr0 && tb->cs_base == desc->cs_base && tb->flags == desc->flags &&
@@ -238,7 +238,7 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,return NULL ; } desc.page_addr0 = phys_pc; - h =tb_hash_func (phys_pc, (TARGET_TB_PCREL ?0 : pc), + h =tb_hash_func (phys_pc, pc, flags, cflags, *cpu->trace_dstate);return qht_lookup_custom (&tb_ctx.htable, &desc, h, tb_lookup_cmp); }
accel/tcg/tb-maint.c +3 -3
@@ -34,7 +34,7 @@ static bool tb_cmp(const void *ap, const void *bp)const TranslationBlock *a = ap;const TranslationBlock *b = bp; - return ((TARGET_TB_PCREL || tb_pc(a) == tb_pc(b)) && + return (tb_pc(a) == tb_pc(b) && a->cs_base == b->cs_base && a->flags == b->flags && (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) &&
@@ -269,7 +269,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)/* remove the TB from the hash list */ phys_pc =tb_page_addr0 (tb); - h =tb_hash_func (phys_pc, (TARGET_TB_PCREL ?0 :tb_pc (tb)), + h =tb_hash_func (phys_pc,tb_pc (tb), tb->flags, orig_cflags, tb->trace_vcpu_dstate);if (!qht_remove (&tb_ctx.htable, tb, h)) {return ;
@@ -459,7 +459,7 @@ TranslationBlock *tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, }/* add in the hash table */ - h =tb_hash_func (phys_pc, (TARGET_TB_PCREL ?0 :tb_pc (tb)), + h =tb_hash_func (phys_pc,tb_pc (tb), tb->flags, tb->cflags, tb->trace_vcpu_dstate);qht_insert (&tb_ctx.htable, tb, h, &existing_tb);
accel/tcg/translate-all.c +0 -2
@@ -818,9 +818,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, gen_code_buf = tcg_ctx->code_gen_ptr; tb->tc.ptr =tcg_splitwx_to_rx (gen_code_buf); -#if !TARGET_TB_PCREL tb->pc = pc; -#endif tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags;
Signature · 1 line
2.43.0