target/ppc: Integrate icount to purr, vtb, and tbu40
PATCH v2 1/1 target/ppc: Integrate icount to purr, vtb, and tbu40
Currently if option '-icount auto' is passed to the QEMU TCG to enable counting instructions the VM crashes with the following error report when Linux runs on it:
qemu-system-ppc64: Bad icount read
This happens because read/write access to the SPRs PURR, VTB, and TBU40 is not integrated to the icount framework.
This commit fixes that issue by making the read/write access of these SPRs aware of icount framework, adding the proper gen_io_start() calls before calling the helpers to load/store these SPRs in TCG and ensuring that the associated TBs end immediately after, accordingly to what's in docs/devel/tcg-icount.rst.
--- target/ppc/translate_init.inc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
target/ppc/translate_init.inc.c +30 -0
@@ -284,12 +284,24 @@ static void spr_write_atbu(DisasContext *ctx, int sprn, int gprn)ATTRIBUTE_UNUSED static void spr_read_purr(DisasContext *ctx, int gprn, int sprn) { +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }gen_helper_load_purr (cpu_gpr[gprn], cpu_env); +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_stop_exception (ctx); + } }static void spr_write_purr (DisasContext *ctx,int sprn,int gprn) { +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }gen_helper_store_purr (cpu_env, cpu_gpr[gprn]); +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_stop_exception (ctx); + } }/* HDECR */
@@ -319,17 +331,35 @@ static void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn)static void spr_read_vtb (DisasContext *ctx,int gprn,int sprn) { +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }gen_helper_load_vtb (cpu_gpr[gprn], cpu_env); +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_stop_exception (ctx); + } }static void spr_write_vtb (DisasContext *ctx,int sprn,int gprn) { +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }gen_helper_store_vtb (cpu_env, cpu_gpr[gprn]); +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_stop_exception (ctx); + } }static void spr_write_tbu40 (DisasContext *ctx,int sprn,int gprn) { +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }gen_helper_store_tbu40 (cpu_env, cpu_gpr[gprn]); +if (tb_cflags (ctx->base.tb) &CF_USE_ICOUNT ) { +gen_stop_exception (ctx); + } }#endif
Signature · 1 line
2.17.1
Quoted 15 lines · Gustavo Romero
Currently if option '-icount auto' is passed to the QEMU TCG to enable counting instructions the VM crashes with the following error report when Linux runs on it:
qemu-system-ppc64: Bad icount read
This happens because read/write access to the SPRs PURR, VTB, and TBU40 is not integrated to the icount framework.
This commit fixes that issue by making the read/write access of these SPRs aware of icount framework, adding the proper
gen_io_start()calls before calling the helpers to load/store these SPRs in TCG and ensuring that the associated TBs end immediately after, accordingly to what's indocs/devel/tcg-icount.rst.
Quoted 4 lines
Signed-off-by Gustavo Romero <[email protected]>--- target/ppc/translate_init.inc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
r~
David Gibson
AppliedQuoted 16 lines · Richard Henderson
Quoted 15 lines · Gustavo Romero
Currently if option '-icount auto' is passed to the QEMU TCG to enable counting instructions the VM crashes with the following error report when Linux runs on it:
qemu-system-ppc64: Bad icount read
This happens because read/write access to the SPRs PURR, VTB, and TBU40 is not integrated to the icount framework.
This commit fixes that issue by making the read/write access of these SPRs aware of icount framework, adding the proper
gen_io_start()calls before calling the helpers to load/store these SPRs in TCG and ensuring that the associated TBs end immediately after, accordingly to what's indocs/devel/tcg-icount.rst.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Gustavo Romero <[email protected]>--- target/ppc/translate_init.inc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)Reviewed-by Richard Henderson <[email protected]>
Applied to ppc-for-5.2, thanks.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 17 lines · David Gibson
Quoted 16 lines · Richard Henderson
Quoted 15 lines · Gustavo Romero
Currently if option '-icount auto' is passed to the QEMU TCG to enable counting instructions the VM crashes with the following error report when Linux runs on it:
qemu-system-ppc64: Bad icount read
This happens because read/write access to the SPRs PURR, VTB, and TBU40 is not integrated to the icount framework.
This commit fixes that issue by making the read/write access of these SPRs aware of icount framework, adding the proper
gen_io_start()calls before calling the helpers to load/store these SPRs in TCG and ensuring that the associated TBs end immediately after, accordingly to what's indocs/devel/tcg-icount.rst.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Signed-off-by Gustavo Romero <[email protected]>--- target/ppc/translate_init.inc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)Reviewed-by Richard Henderson <[email protected]>Applied to ppc-for-5.2, thanks.
Thanks Peter, Richard and David.
Best regards,
Gustavo