On 05/30/2014 07:47 AM, Leon Alrae wrote: > - if (env->CP0_Status & (1 << CP0St_UX)) { > - env->hflags |= MIPS_HFLAG_UX; > + > + if ((((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) && > + (env->CP0_Status & (1 << CP0St_UX))) || > + (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_SM) && > + (env->CP0_Status & (1 << CP0St_SX))) || > + (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_KM) && > + (env->CP0_Status & (1 << CP0St_KX)))) { > + env->hflags |= MIPS_HFLAG_X; > } > #endif > if ((env->CP0_Status & (1 << CP0St_CU0)) || > diff --git a/target-mips/translate.c b/target-mips/translate.c > index 2e94375..6d294e1 100644 > --- a/target-mips/translate.c > +++ b/target-mips/translate.c > @@ -1373,17 +1373,27 @@ generate_exception (DisasContext *ctx, int excp) > gen_helper_0e0i(raise_exception, excp); > } > > +#if defined(TARGET_MIPS64) > +static inline int is_wrapping_needed(DisasContext *ctx) > +{ > + if (!(ctx->hflags & MIPS_HFLAG_X)) { > + /* If not R6 then wrap only in User Mode */ > + if ((ctx->insn_flags & ISA_MIPS64R6) || > + ((ctx->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM)) {
This check should go above, where you set HFLAG_X. r~