From eb775926fd89fc74de2e70a513d475928530dbd2 Mon Sep 17 00:00:00 2001 From: Yongbok Kim Date: Fri, 17 Aug 2018 14:25:20 -0400 Subject: [PATCH] target/mips: Check ELPA flag only in some cases of MFHC0 and MTHC0 MFHC0 and MTHC0 used to handle EntryLo0 and EntryLo1 registers only, and placing ELPA flag checks before switch statement were technically correct. However, after adding handling more registers, these checks should be moved to act only in cases of handling EntryLo0 and EntryLo1. Backports commit 59488dda1f16c0259bc2610d8d71686ef436c649 from qemu --- qemu/target/mips/translate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu/target/mips/translate.c b/qemu/target/mips/translate.c index f3437b57..e2c6681b 100644 --- a/qemu/target/mips/translate.c +++ b/qemu/target/mips/translate.c @@ -4971,12 +4971,11 @@ static void gen_mfhc0(DisasContext *ctx, TCGv arg, int reg, int sel) TCGContext *s = ctx->uc->tcg_ctx; const char *rn = "invalid"; - CP0_CHECK(ctx->hflags & MIPS_HFLAG_ELPA); - switch (reg) { case 2: switch (sel) { case 0: + CP0_CHECK(ctx->hflags & MIPS_HFLAG_ELPA); gen_mfhc0_entrylo(s, arg, offsetof(CPUMIPSState, CP0_EntryLo0)); rn = "EntryLo0"; break; @@ -4987,6 +4986,7 @@ static void gen_mfhc0(DisasContext *ctx, TCGv arg, int reg, int sel) case 3: switch (sel) { case 0: + CP0_CHECK(ctx->hflags & MIPS_HFLAG_ELPA); gen_mfhc0_entrylo(s, arg, offsetof(CPUMIPSState, CP0_EntryLo1)); rn = "EntryLo1"; break; @@ -5042,12 +5042,11 @@ static void gen_mthc0(DisasContext *ctx, TCGv arg, int reg, int sel) const char *rn = "invalid"; uint64_t mask = ctx->PAMask >> 36; - CP0_CHECK(ctx->hflags & MIPS_HFLAG_ELPA); - switch (reg) { case 2: switch (sel) { case 0: + CP0_CHECK(ctx->hflags & MIPS_HFLAG_ELPA); tcg_gen_andi_tl(s, arg, arg, mask); gen_mthc0_entrylo(s, arg, offsetof(CPUMIPSState, CP0_EntryLo0)); rn = "EntryLo0"; @@ -5059,6 +5058,7 @@ static void gen_mthc0(DisasContext *ctx, TCGv arg, int reg, int sel) case 3: switch (sel) { case 0: + CP0_CHECK(ctx->hflags & MIPS_HFLAG_ELPA); tcg_gen_andi_tl(s, arg, arg, mask); gen_mthc0_entrylo(s, arg, offsetof(CPUMIPSState, CP0_EntryLo1)); rn = "EntryLo1";