Message ID | 20210620221046.1526418-7-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | target/nios2: Convert to TranslatorOps | expand |
On Sun, 20 Jun 2021 at 23:15, Richard Henderson <richard.henderson@linaro.org> wrote: > > Direct assignments to env during translation do not work. > > As it happens, the only way we can get here is if env->pc > is already set to dc->pc. More to the point, t_gen_helper_raise_exception() does tcg_gen_movi_tl(dc->cpu_R[R_PC], dc->pc); before raising the exception (as you would expect it to). > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/nios2/translate.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/target/nios2/translate.c b/target/nios2/translate.c > index 06705c894d..31f63d9faa 100644 > --- a/target/nios2/translate.c > +++ b/target/nios2/translate.c > @@ -740,14 +740,15 @@ static void handle_instruction(DisasContext *dc, CPUNios2State *env) > uint32_t code; > uint8_t op; > const Nios2Instruction *instr; > + > #if defined(CONFIG_USER_ONLY) > /* FIXME: Is this needed ? */ > if (dc->pc >= 0x1000 && dc->pc < 0x2000) { > - env->regs[R_PC] = dc->pc; > t_gen_helper_raise_exception(dc, 0xaa); > return; > } > #endif > + > code = cpu_ldl_code(env, dc->pc); > op = get_opcode(code); Reviewed-by: Peter Maydell <peter.maydell@linaro.org> but you probably want to tweak the commit message. thanks -- PMM
On 6/28/21 8:31 AM, Peter Maydell wrote: > On Sun, 20 Jun 2021 at 23:15, Richard Henderson > <richard.henderson@linaro.org> wrote: >> >> Direct assignments to env during translation do not work. >> >> As it happens, the only way we can get here is if env->pc >> is already set to dc->pc. > > More to the point, t_gen_helper_raise_exception() does > tcg_gen_movi_tl(dc->cpu_R[R_PC], dc->pc); > before raising the exception (as you would expect it to). Ah, didn't notice that. My comment works from the other direction: Within the page, 0x1000-0x1fff, any insn executed will raise the 0xaa exception, which means pc will be set for that insn. r~
diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 06705c894d..31f63d9faa 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -740,14 +740,15 @@ static void handle_instruction(DisasContext *dc, CPUNios2State *env) uint32_t code; uint8_t op; const Nios2Instruction *instr; + #if defined(CONFIG_USER_ONLY) /* FIXME: Is this needed ? */ if (dc->pc >= 0x1000 && dc->pc < 0x2000) { - env->regs[R_PC] = dc->pc; t_gen_helper_raise_exception(dc, 0xaa); return; } #endif + code = cpu_ldl_code(env, dc->pc); op = get_opcode(code);
Direct assignments to env during translation do not work. As it happens, the only way we can get here is if env->pc is already set to dc->pc. We will trap on the first insn we execute anywhere on the page. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/nios2/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.25.1