Re: [PATCH] MIPS: UAPI: Fix unrecognized opcode WSBH/DSBH/DSHD when using MIPS16.

From: Maciej W. Rozycki
Date: Sun Sep 06 2015 - 19:23:47 EST


On Sun, 6 Sep 2015, Yousong Zhou wrote:

> Hi, Maciej, first of all, thank you for your time on this,
> appreciate it.

You're welcome!

> > The bug certainly was there, it's just your analysis and consequently the
> > fix that are wrong in the general case for some reason, maybe a buggy
> > compiler.
> >
>
> This is the compiler "--version",
>
> mips-openwrt-linux-gcc (OpenWrt/Linaro GCC 4.8-2014.04 r46763) 4.8.3

A-ha! I've checked GCC's history and the symptom you're seeing was PR
target/55777:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55777

and the bug has only been fixed pretty recently (r199328), already after
GCC 4.8 has branched. From your troubles I infer the fix has not been
backported to 4.8 and therefore is only available from GCC 4.9 up; of
course either you or OpenWrt can still backport it and apply locally.

Fortunately as I noted you need not dive into that hole as the
reasonable choice here is to avoid the asm for MIPS16 code altogether,
regardless of the GCC bug.

> > Now if you stick `.set nomips16' just above WSBH, then this code will
> > happily assemble, because this single instruction only (`.set pop' reverts
> > any previous `.set' directives; I'm assuming you wrote above by hand and
> > `.pop' is a typo) will assemble in the regular MIPS instruction mode. But
> > if this code is ever reached, then the processor will still execute the
> > machine code produced by the assembler from the WSBH instruction in the
> > MIPS16 mode.
>
> Yes, I hand-copied it from the output of "gcc -S" just to
> show the form/pattern (the original output is too long for
> this conversation). No, that `.pop' is not a typo (I just
> did a double-check).

Well, please check again then as there's no such pseudo-op:

$ cat pop.s
.pop
$ mips-mti-linux-gnu-as -o pop.o pop.s
pop.s: Assembler messages:
pop.s:1: Error: unknown pseudo-op: `.pop'
$

> > No, it's your bug after all. I think the last paragraph I wrote quoted
> > above combined with the source code in question make it clear what to do.
>
> Okay, I will try. Most of the time when textbooks read
> clearly/obviously/apparently, things go astray ;)

Well, if you really find yourself stuck with it, then come back for
more hints, however please do try figuring it out yourself first as
it'll be a good exercise.

Maciej
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/