"setend" incorrectly handled in thumb mode

Bug #953544 reported by Daniel Forsgren on 2012-03-12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro QEMU
Fix Released

Bug Description

I suspect that "setend" incorrectly is decoded as "cps" in thumb mode. When running qemu-linaro-1.0.50-2012.02 (targeting A9), I noticed the following odd behavior:

    > root@linaro-developer:/test# cat foo.c
    > #include <stdio.h>
    > int main(void)
    > {
    > __asm__ __volatile__ ("setend be");
    > printf("done!\n");
    > }
    > root@linaro-developer:/test# gcc -marm foo.c
    > root@linaro-developer:/test# ./a.out
    > Illegal instruction
    > root@linaro-developer:/test# gcc -mthumb foo.c
    > root@linaro-developer:/test# ./a.out
    > done!
    > root@linaro-developer:/test#

I think it is a perfectly ok limitiation to not support be mode. But it should at least be consistent.

Some minor review of disas_thumb_insn (translate.c) reveal something like:

    > switch (insn >> 12) {
    > case 11:
    > /* misc */
    > op = (insn >> 8) & 0xf;
    > switch (op) {
    > case 6: /* cps */
    > ARCH(6);
    > if (IS_USER(s))
    > break;

That is, to me, "setend" seems to be decoded as "cps", and when running in user mode being silently ignored.

(possibly worse - if executed in priviledged mode, "setend" would actually be executed as "cps"?)

Peter Maydell (pmaydell) wrote :

BE8 mode is completely unsupported in QEMU at the moment. We have some patches which will allow the armeb user mode to support an "always in BE8" mode, but dynamic switching via setend is somewhat harder and not currently planned work. You're right that not UNDEFfing on the Thumb encoding of setend is accidental and could perhaps be fixed, though.

Changed in qemu-linaro:
importance: Undecided → Low

Yes, it's perfectly fine to have BE8 as unsupported. My observeration was really:

1) It should behave same, regardless of thumb/arm mode (which is currently not the case).

2) It should not interpret/execute "setend" as "cps" in thumb mode (because that is simply incorrect).

Peter Maydell (pmaydell) on 2012-03-13
Changed in qemu-linaro:
milestone: none → 2012.04
status: New → Confirmed
status: Confirmed → In Progress
Peter Maydell (pmaydell) on 2012-03-30
Changed in qemu-linaro:
status: In Progress → Fix Committed
Peter Maydell (pmaydell) on 2012-04-12
Changed in qemu-linaro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers