Skip to contentSkip to conversation

target-arm: Reinsert SRS missing return statements.

PATCH Superseded Peter Chubb 2 participants 6 messages Apr 15, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-arm: Reinsert SRS missing return statements.

Since patch
81465888c5306cd94abb9847e560796fd13d3c2f
target-arm: factor out handling of SRS instruction
the SRS instruction has not worked in QEMU.

The problem is a return directive that was removed in the refactoring, so after decoding the instruction, qemu would fall through to do stuff that it should not have done.

target-arm/translate.c +2 -0
index 35a21be..c870246 100644
@@ -6762,6 +6762,7 @@ static void disas_arm_insn(CPUARMState * env, DisasContext *s)
             }
             ARCH(6);
             gen_srs(s, (insn & 0x1f), (insn >> 23) & 3, insn & (1 << 21));
+            return;
         } else if ((insn & 0x0e50ffe0) == 0x08100a00) {
             /* rfe */
             int32_t offset;
@@ -8209,6 +8210,7 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
                     /* srs */
                     gen_srs(s, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2,
                             insn & (1 << 21));
+                    return;
                 }
             } else {
                 int i, loaded_base = 0;
Signature · 6 lines
1.7.10.4



Dr Peter Chubb				        peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA
#1 lore raw
Quoted 10 lines · Peter Chubb

Since patch
81465888c5306cd94abb9847e560796fd13d3c2f
target-arm: factor out handling of SRS instruction
the SRS instruction has not worked in QEMU.

The problem is a return directive that was removed in the refactoring, so after decoding the instruction, qemu would fall through to do stuff that it should not have done.

Nice catch for the ARM decoder, but not needed for thumb2 I think?

thanks
-- PMM

#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Peter" == Peter Maydell <[email protected]> writes:

Peter> On 15 April 2013 05:50, Peter Chubb <[email protected]>

Quoted 9 lines · Peter> wrote:
Quoted 9 lines

Since patch 81465888c5306cd94abb9847e560796fd13d3c2f target-arm:
factor out handling of SRS instruction the SRS instruction has not worked in QEMU.

The problem is a return directive that was removed in the refactoring, so after decoding the instruction, qemu would fall through to do stuff that it should not have done.

Peter> Nice catch for the ARM decoder, but not needed for thumb2 I Peter> think?

It was there in the code that was removed.
I didn't analyse too deeply, as nothing we do uses the thumb version.

Peter C
--
Dr Peter Chubb peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au Software Systems Research Group/NICTA

#3 lore raw
Quoted 11 lines · Peter Chubb
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Peter" == Peter Maydell <[email protected]> writes:

Peter> On 15 April 2013 05:50, Peter Chubb <[email protected]>

Quoted 3 lines · Peter> wrote:
Quoted 3 lines

The problem is a return directive that was removed in the refactoring, so after decoding the instruction, qemu would fall through to do stuff that it should not have done.

Peter> Nice catch for the ARM decoder, but not needed for thumb2 I Peter> think?

It was there in the code that was removed.

No it wasn't, I just looked at the broken commit which is why I pointed it out. (Also you can see that the gen_rfe() above isn't followed by a return, so I checked code flow to be sure it was OK.)

thanks
-- PMM

#4 lore raw

PATCH v2 1/1 target-arm: Reinsert SRS missing return statement.

Since patch
81465888c5306cd94abb9847e560796fd13d3c2f
target-arm: factor out handling of SRS instruction
the SRS instruction has not worked in QEMU.

The problem is a missing return directive that was removed in the refactoring, so after decoding the instruction, qemu would do all the generic stuff that it should do for most instructions -- but not SRS.

---
 target-arm/translate.c |    1 +
 1 file changed, 1 insertion(+)
target-arm/translate.c +1 -0
index 35a21be..a1b7b8c 100644
@@ -6762,6 +6762,7 @@ static void disas_arm_insn(CPUARMState * env, DisasContext *s)
             }
             ARCH(6);
             gen_srs(s, (insn & 0x1f), (insn >> 23) & 3, insn & (1 << 21));
+            return;
         } else if ((insn & 0x0e50ffe0) == 0x08100a00) {
             /* rfe */
             int32_t offset;
Signature · 6 lines
1.7.10.4


--
Dr Peter Chubb				        peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA
Reviewed-by on v2 1/1
#5 lore raw

Re: [Qemu-devel] [PATCH v2] target-arm: Reinsert SRS missing return statement.

Quoted 9 lines · Peter Chubb

Since patch
81465888c5306cd94abb9847e560796fd13d3c2f
target-arm: factor out handling of SRS instruction
the SRS instruction has not worked in QEMU.

The problem is a missing return directive that was removed in the refactoring, so after decoding the instruction, qemu would do all the generic stuff that it should do for most instructions -- but not SRS.

Actually, the problem is not doing generic stuff, but that we hit the 'goto illegal_op' at the bottom of the if..elseif ladder.

Quoted 18 lines
---
 target-arm/translate.c |    1 +
 1 file changed, 1 insertion(+)
target-arm/translate.c +1 -1
index 35a21be..a1b7b8c 100644
@@ -6762,6 +6762,7 @@ static void disas_arm_insn(CPUARMState * env, DisasContext *s)
             }
             ARCH(6);
             gen_srs(s, (insn & 0x1f), (insn >> 23) & 3, insn & (1 << 21));
+            return;
         } else if ((insn & 0x0e50ffe0) == 0x08100a00) {
             /* rfe */
             int32_t offset;
--
Quoted 1 line

1.7.10.4

Code is ok, though:

I'll pull it into the target-arm tree and tweak the commit message.

-- PMM