Skip to contentSkip to conversation

target/mips: Fixes for 4.1

PATCH Superseded Aleksandar Markovic 3 participants 12 messages Jul 12, 2019

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover target/mips: Fixes for 4.1

From: Aleksandar Markovic <[email protected]>

At the moment, this includes fixes for problems in switch statements found by GCC 8.3 improved code analysis features.

Aleksandar Markovic (4):
target/mips: Add 'fall through' comments for handling nanoMips' SHXS,
SWXS
target/mips: Add missing 'break' for a case of MTHC0 handling target/mips: Add missing 'break' for certain cases of MFTR handling target/mips: Add missing 'break' for certain cases of MTTR handling

 target/mips/translate.c | 7 +++++++
 1 file changed, 7 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 target/mips: Add 'fall through' comments for handling nanoMips' SHXS, SWXS

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

---
 target/mips/translate.c | 2 ++
 1 file changed, 2 insertions(+)
target/mips/translate.c +2 -0
index f96f141..2be5e2d 100644
@@ -20136,12 +20136,14 @@ static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt)
         switch (extract32(ctx->opcode, 7, 4)) {
         case NM_SHXS:
             check_nms(ctx);
+            /* fall through */
         case NM_LHXS:
         case NM_LHUXS:
             tcg_gen_shli_tl(t0, t0, 1);
             break;
         case NM_SWXS:
             check_nms(ctx);
+            /* fall through */
         case NM_LWXS:
         case NM_LWC1XS:
         case NM_SWC1XS:
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 target/mips: Add missing 'break' for a case of MTHC0 handling

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

---
 target/mips/translate.c | 1 +
 1 file changed, 1 insertion(+)
target/mips/translate.c +1 -0
index 2be5e2d..59d4acd 100644
@@ -6745,6 +6745,7 @@ static void gen_mthc0(DisasContext *ctx, TCGv arg, int reg, int sel)
         default:
             goto cp0_unimplemented;
         }
+        break;
     case CP0_REGISTER_17:
         switch (sel) {
         case 0:
Signature · 1 line
2.7.4
Reviewed-by Tested-by on v1 2/4
#3 lore raw

Re: [Qemu-devel] [PATCH for 4.1 2/4] target/mips: Add missing 'break' for a case of MTHC0 handling

Hi Aleksandar,

Quoted 4 lines · Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

I think you can amend:

Fixes 5fb2dcd1792
Quoted 11 lines
---
 target/mips/translate.c | 1 +
 1 file changed, 1 insertion(+)
target/mips/translate.c +0 -0
index 2be5e2d..59d4acd 100644

target/mips/translate.c static void gen_mthc0(DisasContext *ctx, TCGv arg, int reg, int sel) · line 6751

Quoted 7 lines
target/mips/translate.c +1 -0
@@ -6745,6 +6745,7 @@ static void gen_mthc0(DisasContext *ctx, TCGv arg, int reg, int sel)
         default:
             goto cp0_unimplemented;
         }
+        break;
     case CP0_REGISTER_17:
         switch (sel) {
         case 0:

Thanks,

Phil.

#4 lore raw

Re: [Qemu-devel] ?==?utf-8?q? ?==?utf-8?q? [PATCH for 4.1?==?utf-8?q? 2/4]?==?utf-8?q? target/mips: Add missing 'break' for a case of MTHC0 handling

Quoted 5 lines

From: Philippe Mathieu-Daudé <[email protected]>

Quoted 2 lines

From: Aleksandar Markovic <[email protected]>

Quoted 8 lines
Quoted 2 lines

This was found by GCC 8.3 static analysis.


I think you can amend:

Fixes 5fb2dcd1792

Yes, indeed. This will be added in the next version.

Thanks,
Aleksandar

#5 lore raw

PATCH v2 1/1 linux-user: Fix structure target_ucontext for MIPS

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Structure ucontext for MIPS is defined in the following way in Linux kernel:

(arch/mips/include/uapi/asm/ucontext.h, lines 54-64)

struct ucontext {
    /* Historic fields matching asm-generic */
    unsigned long       uc_flags;
    struct ucontext     *uc_link;
    stack_t             uc_stack;
    struct sigcontext   uc_mcontext;
    sigset_t            uc_sigmask;

    /* Extended context structures may follow ucontext */
    unsigned long long	uc_extcontext[0];
};

Fix the structure target_ucontext for MIPS to reflect the definition above, except the correction for field uc_extcontext, which will follow at some later time.

Fixes 94c5495d

---

v2: rectified a commit message mistake with
s/target_sigset_t/target_ucontext

---
 linux-user/mips/signal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
linux-user/mips/signal.c +2 -3
index 6aa303e..455a8a2 100644
@@ -71,10 +71,9 @@ struct sigframe {
 };
 
 struct target_ucontext {
-    target_ulong tuc_flags;
-    target_ulong tuc_link;
+    abi_ulong tuc_flags;
+    abi_ulong tuc_link;
     target_stack_t tuc_stack;
-    target_ulong pad0;
     struct target_sigcontext tuc_mcontext;
     target_sigset_t tuc_sigmask;
 };
Signature · 1 line
2.7.4
#6 lore raw

Re: [Qemu-devel] [PATCH for 4.1 v2] linux-user: Fix structure target_ucontext for MIPS

Le 12/07/2019 à 13:37, Aleksandar Markovic a écrit :

Quoted 45 lines

From: Aleksandar Markovic <[email protected]>

Structure ucontext for MIPS is defined in the following way in Linux kernel:

(arch/mips/include/uapi/asm/ucontext.h, lines 54-64)

struct ucontext {
    /* Historic fields matching asm-generic */
    unsigned long       uc_flags;
    struct ucontext     *uc_link;
    stack_t             uc_stack;
    struct sigcontext   uc_mcontext;
    sigset_t            uc_sigmask;

    /* Extended context structures may follow ucontext */
    unsigned long long	uc_extcontext[0];
};

Fix the structure target_ucontext for MIPS to reflect the definition above, except the correction for field uc_extcontext, which will follow at some later time.

Fixes 94c5495d

---

v2: rectified a commit message mistake with
s/target_sigset_t/target_ucontext

---
 linux-user/mips/signal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
linux-user/mips/signal.c +0 -0
index 6aa303e..455a8a2 100644
@@ -71,10 +71,9 @@ struct sigframe {
 };
 

linux-user/mips/signal.c struct sigframe { · line 79

Quoted 10 lines
linux-user/mips/signal.c +2 -3
 struct target_ucontext {
-    target_ulong tuc_flags;
-    target_ulong tuc_link;
+    abi_ulong tuc_flags;
+    abi_ulong tuc_link;
     target_stack_t tuc_stack;
-    target_ulong pad0;
     struct target_sigcontext tuc_mcontext;
     target_sigset_t tuc_sigmask;
 };

Applied to my linux-user branch.

Thanks,
Laurent

#7 lore raw

PATCH 3/4 target/mips: Add missing 'break' for certain cases of MFTR handling

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

---
 target/mips/translate.c | 2 ++
 1 file changed, 2 insertions(+)
target/mips/translate.c +2 -0
index 59d4acd..b1cf5f0 100644
@@ -9826,6 +9826,7 @@ static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
                 gen_mfc0(ctx, t0, rt, sel);
                 break;
             }
+            break;
         case 12:
             switch (sel) {
             case 0:
@@ -9835,6 +9836,7 @@ static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
                 gen_mfc0(ctx, t0, rt, sel);
                 break;
             }
+            break;
         case 13:
             switch (sel) {
             case 0:
Signature · 1 line
2.7.4
Reviewed-by Tested-by on v1 3/4
#8 lore raw

Re: [Qemu-devel] [PATCH for 4.1 3/4] target/mips: Add missing 'break' for certain cases of MFTR handling

Quoted 4 lines · Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

Again, please amend:

Fixes ead9360e2fb
Quoted 19 lines
---
 target/mips/translate.c | 2 ++
 1 file changed, 2 insertions(+)
target/mips/translate.c +1 -0
index 59d4acd..b1cf5f0 100644
@@ -9826,6 +9826,7 @@ static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
                 gen_mfc0(ctx, t0, rt, sel);
                 break;
             }
+            break;
         case 12:
             switch (sel) {
             case 0:

target/mips/translate.c static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd, · line 9842

Quoted 7 lines
target/mips/translate.c +1 -0
@@ -9835,6 +9836,7 @@ static void gen_mftr(CPUMIPSState *env, DisasContext *ctx, int rt, int rd,
                 gen_mfc0(ctx, t0, rt, sel);
                 break;
             }
+            break;
         case 13:
             switch (sel) {
             case 0:

12 years missing...

#9 lore raw

Re: [Qemu-devel] ?==?utf-8?q? ?==?utf-8?q? [PATCH for 4.1?==?utf-8?q? 3/4]?==?utf-8?q? target/mips: Add missing 'break' for certain cases of MFTR handling

Quoted 11 lines

From: Philippe Mathieu-Daudé <[email protected]>

Quoted 4 lines

From: Aleksandar Markovic <[email protected]>
This was found by GCC 8.3 static analysis.


Again, please amend:

Fixes ead9360e2fb

Who would think that this bug existed since 2007? ...étrange.

Thanks,
Aleksandar

#10 lore raw

PATCH 4/4 target/mips: Add missing 'break' for certain cases of MTTR handling

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

---
 target/mips/translate.c | 2 ++
 1 file changed, 2 insertions(+)
target/mips/translate.c +2 -0
index b1cf5f0..ca62800 100644
@@ -10055,6 +10055,7 @@ static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt,
                 gen_mtc0(ctx, t0, rd, sel);
                 break;
             }
+            break;
         case 12:
             switch (sel) {
             case 0:
@@ -10064,6 +10065,7 @@ static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt,
                 gen_mtc0(ctx, t0, rd, sel);
                 break;
             }
+            break;
         case 13:
             switch (sel) {
             case 0:
Signature · 1 line
2.7.4
Reviewed-by Tested-by on v1 4/4
#11 lore raw

Re: [Qemu-devel] [PATCH for 4.1 4/4] target/mips: Add missing 'break' for certain cases of MTTR handling

Quoted 4 lines · Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This was found by GCC 8.3 static analysis.

Similar to the previous one:

Fixes ead9360e2fb
Quoted 1 line

Thanks for cleaning this!

Regards,

Phil.

Quoted 25 lines
---
 target/mips/translate.c | 2 ++
 1 file changed, 2 insertions(+)
target/mips/translate.c +2 -0
index b1cf5f0..ca62800 100644
@@ -10055,6 +10055,7 @@ static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt,
                 gen_mtc0(ctx, t0, rd, sel);
                 break;
             }
+            break;
         case 12:
             switch (sel) {
             case 0:
@@ -10064,6 +10065,7 @@ static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt,
                 gen_mtc0(ctx, t0, rd, sel);
                 break;
             }
+            break;
         case 13:
             switch (sel) {
             case 0: