Skip to contentSkip to conversation

target-microblaze: Coverity fixes

PATCH In review Edgar E. Iglesias 3 participants 6 messages Jun 14, 2018 – Jun 15, 2018

lore
Share & tools
lore
#0 lore raw

cover target-microblaze: Coverity fixes

From: "Edgar E. Iglesias" <[email protected]>

This series has fixes for the Coverity issues that Peter Maydell reported.

CID 1391441
CID 1391443

Best regards,
Edgar

Edgar E. Iglesias (2):
target-microblaze: mmu: Correct masking of output addresses
target-microblaze: Rework NOP/zero instruction handling

 target/microblaze/mmu.c       |  1 -
 target/microblaze/translate.c | 15 ++++-----------
 2 files changed, 4 insertions(+), 12 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/2 target-microblaze: mmu: Correct masking of output addresses

From: "Edgar E. Iglesias" <[email protected]>

Correct the masking of output addresses.

This fixes Coverity CID 1391441.

Fixes commit 3924a9aa02
---
 target/microblaze/mmu.c | 1 -
 1 file changed, 1 deletion(-)
target/microblaze/mmu.c +0 -1
index f4ceaea520..fcf86b12d5 100644
@@ -159,7 +159,6 @@ unsigned int mmu_translate(struct microblaze_mmu *mmu,
 
             lu->vaddr = tlb_tag;
             lu->paddr = tlb_rpn & mmu->c_addr_mask;
-            lu->paddr = tlb_rpn;
             lu->size = tlb_size;
             lu->err = ERR_HIT;
             lu->idx = i;
Signature · 1 line
2.14.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v1 1/2] target-microblaze: mmu: Correct masking of output addresses

Quoted 9 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Correct the masking of output addresses.

This fixes Coverity CID 1391441.

Fixes commit 3924a9aa02

Alistair

Quoted 20 lines
---
 target/microblaze/mmu.c | 1 -
 1 file changed, 1 deletion(-)
target/microblaze/mmu.c +0 -2
index f4ceaea520..fcf86b12d5 100644
@@ -159,7 +159,6 @@ unsigned int mmu_translate(struct microblaze_mmu *mmu,
 
             lu->vaddr = tlb_tag;
             lu->paddr = tlb_rpn & mmu->c_addr_mask;
-            lu->paddr = tlb_rpn;
             lu->size = tlb_size;
             lu->err = ERR_HIT;
             lu->idx = i;
--

2.14.1

Reviewed-by on v1 1/2
#3 lore raw

Re: [Qemu-devel] [PATCH v1 1/2] target-microblaze: mmu: Correct masking of output addresses

In reply to Edgar E. Iglesias
Quoted 9 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Correct the masking of output addresses.

This fixes Coverity CID 1391441.

Fixes commit 3924a9aa02
Quoted 17 lines
---
 target/microblaze/mmu.c | 1 -
 1 file changed, 1 deletion(-)
target/microblaze/mmu.c +0 -1
index f4ceaea520..fcf86b12d5 100644
@@ -159,7 +159,6 @@ unsigned int mmu_translate(struct microblaze_mmu *mmu,
 
             lu->vaddr = tlb_tag;
             lu->paddr = tlb_rpn & mmu->c_addr_mask;
-            lu->paddr = tlb_rpn;
             lu->size = tlb_size;
             lu->err = ERR_HIT;
             lu->idx = i;
#4 lore raw

PATCH 2/2 target-microblaze: Rework NOP/zero instruction handling

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Remove the abort on a sequence of NOP/zero instructions. Always return early and avoid decoding NOP/zero instructions.

This fixes Coverity CID 1391443.

---
 target/microblaze/translate.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
target/microblaze/translate.c +4 -11
index 6c64946398..78ca265b04 100644
@@ -90,7 +90,6 @@ typedef struct DisasContext {
     uint32_t jmp_pc;
 
     int abort_at_next_insn;
-    int nr_nops;
     struct TranslationBlock *tb;
     int singlestep_enabled;
 } DisasContext;
@@ -1576,17 +1575,12 @@ static inline void decode(DisasContext *dc, uint32_t ir)
     dc->ir = ir;
     LOG_DIS("%8.8x\t", dc->ir);
 
-    if (dc->ir)
-        dc->nr_nops = 0;
-    else {
+    if (ir == 0) {
         trap_illegal(dc, dc->cpu->env.pvr.regs[2] & PVR2_OPCODE_0x0_ILL_MASK);
-
-        LOG_DIS("nr_nops=%d\t", dc->nr_nops);
-        dc->nr_nops++;
-        if (dc->nr_nops > 4) {
-            cpu_abort(CPU(dc->cpu), "fetching nop sequence\n");
-        }
+        /* Don't decode nop/zero instructions any further.  */
+        return;
     }
+
     /* bit 2 seems to indicate insn type.  */
     dc->type_b = ir & (1 << 29);
 
@@ -1633,7 +1627,6 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
     dc->singlestep_enabled = cs->singlestep_enabled;
     dc->cpustate_changed = 0;
     dc->abort_at_next_insn = 0;
-    dc->nr_nops = 0;
 
     if (pc_start & 3) {
         cpu_abort(cs, "Microblaze: unaligned PC=%x\n", pc_start);
Signature · 1 line
2.14.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [Qemu-devel] [PATCH v1 2/2] target-microblaze: Rework NOP/zero instruction handling

Quoted 8 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Remove the abort on a sequence of NOP/zero instructions. Always return early and avoid decoding NOP/zero instructions.

This fixes Coverity CID 1391443.

Quoted 47 lines
---
 target/microblaze/translate.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
target/microblaze/translate.c +4 -11
index 6c64946398..78ca265b04 100644
@@ -90,7 +90,6 @@ typedef struct DisasContext {
     uint32_t jmp_pc;
 
     int abort_at_next_insn;
-    int nr_nops;
     struct TranslationBlock *tb;
     int singlestep_enabled;
 } DisasContext;
@@ -1576,17 +1575,12 @@ static inline void decode(DisasContext *dc, uint32_t ir)
     dc->ir = ir;
     LOG_DIS("%8.8x\t", dc->ir);
 
-    if (dc->ir)
-        dc->nr_nops = 0;
-    else {
+    if (ir == 0) {
         trap_illegal(dc, dc->cpu->env.pvr.regs[2] & PVR2_OPCODE_0x0_ILL_MASK);
-
-        LOG_DIS("nr_nops=%d\t", dc->nr_nops);
-        dc->nr_nops++;
-        if (dc->nr_nops > 4) {
-            cpu_abort(CPU(dc->cpu), "fetching nop sequence\n");
-        }
+        /* Don't decode nop/zero instructions any further.  */
+        return;
     }
+
     /* bit 2 seems to indicate insn type.  */
     dc->type_b = ir & (1 << 29);
 
@@ -1633,7 +1627,6 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
     dc->singlestep_enabled = cs->singlestep_enabled;
     dc->cpustate_changed = 0;
     dc->abort_at_next_insn = 0;
-    dc->nr_nops = 0;
 
     if (pc_start & 3) {
         cpu_abort(cs, "Microblaze: unaligned PC=%x\n", pc_start);