qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 29/35] target/mips: Fix ERET/ERETNC can cause AD


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 29/35] target/mips: Fix ERET/ERETNC can cause ADEL exception
Date: Fri, 22 Jun 2018 01:31:33 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 06/20/2018 09:06 AM, Yongbok Kim wrote:
> From: Yongbok Kim <address@hidden>
> 
> Fix ERET/ERETNC can cause ADEL exception
> 
> Signed-off-by: Yongbok Kim <address@hidden>
> ---
>  target/mips/op_helper.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
> index 6f5e5a3..09ec20a 100644
> --- a/target/mips/op_helper.c
> +++ b/target/mips/op_helper.c
> @@ -2434,6 +2434,13 @@ static void set_pc(CPUMIPSState *env, target_ulong 
> error_pc)
>      env->active_tc.PC = error_pc & ~(target_ulong)1;
>      if (env->insn_flags & ISA_NANOMIPS32) {
>          /* Don't clear MIPS_HFLAG_M16 */
> +        if (error_pc & 1) {
> +            if (!(env->hflags & MIPS_HFLAG_DM)) {
> +                env->CP0_BadVAddr = error_pc;
> +            }
> +            env->active_tc.PC = error_pc;
> +            do_raise_exception(env, EXCP_AdEL, 0);
> +        }
>          return;
>      }
>      if (error_pc & 1) {
> @@ -2471,10 +2478,12 @@ void helper_eretnc(CPUMIPSState *env)
>  void helper_deret(CPUMIPSState *env)
>  {
>      debug_pre_eret(env);
> -    set_pc(env, env->CP0_DEPC);
>  
>      env->hflags &= ~MIPS_HFLAG_DM;
>      compute_hflags(env);
> +
> +    set_pc(env, env->CP0_DEPC);

Now set_pc() uses MIPS_HFLAG_DM, so it makes sens to call it _after_
updating env->hflags. Correct.

> +
>      debug_post_eret(env);
>  }
>  #endif /* !CONFIG_USER_ONLY */
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]