Skip to content

Commit

Permalink
Merge pull request #1910 from dotCirill/ppc32_fix_time_spr
Browse files Browse the repository at this point in the history
Fix PPC32 fault when timer-spr access
  • Loading branch information
wtdcode authored Dec 10, 2023
2 parents c0adcfb + b0ea433 commit d17810f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
25 changes: 25 additions & 0 deletions qemu/target/ppc/translate_init.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static void spr_write_ureg(DisasContext *ctx, int sprn, int gprn)

/* SPR common to all non-embedded PowerPC */
/* DECR */
#if 0
static void spr_read_decr(DisasContext *ctx, int gprn, int sprn)
{
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
Expand All @@ -182,7 +183,11 @@ static void spr_read_decr(DisasContext *ctx, int gprn, int sprn)
gen_stop_exception(ctx);
}
}
#else
#define spr_read_decr spr_read_generic
#endif

#if 0
static void spr_write_decr(DisasContext *ctx, int sprn, int gprn)
{
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
Expand All @@ -194,9 +199,13 @@ static void spr_write_decr(DisasContext *ctx, int sprn, int gprn)
gen_stop_exception(ctx);
}
}
#else
#define spr_write_decr spr_write_generic
#endif

/* SPR common to all non-embedded PowerPC, except 601 */
/* Time base */
#if 0
static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn)
{
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
Expand All @@ -209,7 +218,11 @@ static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn)
gen_stop_exception(ctx);
}
}
#else
#define spr_read_tbl spr_read_generic
#endif

#if 0
static void spr_read_tbu(DisasContext *ctx, int gprn, int sprn)
{
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
Expand All @@ -222,6 +235,9 @@ static void spr_read_tbu(DisasContext *ctx, int gprn, int sprn)
gen_stop_exception(ctx);
}
}
#else
#define spr_read_tbu spr_read_generic
#endif

#if 0
// ATTRIBUTE_UNUSED
Expand All @@ -239,6 +255,7 @@ static void spr_read_atbu(DisasContext *ctx, int gprn, int sprn)
}
#endif

#if 0
static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)
{
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
Expand All @@ -251,7 +268,12 @@ static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)
gen_stop_exception(ctx);
}
}
#else
#define spr_write_tbl spr_write_generic
#endif


#if 0
static void spr_write_tbu(DisasContext *ctx, int sprn, int gprn)
{
TCGContext *tcg_ctx = ctx->uc->tcg_ctx;
Expand All @@ -264,6 +286,9 @@ static void spr_write_tbu(DisasContext *ctx, int sprn, int gprn)
gen_stop_exception(ctx);
}
}
#else
#define spr_write_tbu spr_write_generic
#endif

#if 0
// ATTRIBUTE_UNUSED
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,23 @@ static void test_ppc32_cr(void)
OK(uc_close(uc));
}

static void test_ppc32_spr_time(void)
{
char code[] = ("\x7c\x76\x02\xa6" // mfspr r3, DEC
"\x7c\x6d\x42\xa6" // mfspr r3, TBUr
);

uc_engine *uc;
uc_common_setup(&uc, UC_ARCH_PPC, UC_MODE_32 | UC_MODE_BIG_ENDIAN, code,
sizeof(code) - 1);

OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0));
OK(uc_close(uc));
}

TEST_LIST = {{"test_ppc32_add", test_ppc32_add},
{"test_ppc32_fadd", test_ppc32_fadd},
{"test_ppc32_sc", test_ppc32_sc},
{"test_ppc32_cr", test_ppc32_cr},
{"test_ppc32_spr_time", test_ppc32_spr_time},
{NULL, NULL}};

0 comments on commit d17810f

Please sign in to comment.