qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Illegal instruction reported by qemu-ppc with -cpu 7400


From: Matheus K. Ferst
Subject: Re: Illegal instruction reported by qemu-ppc with -cpu 7400
Date: Thu, 17 Mar 2022 13:31:21 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

On 14/03/2022 12:20, Khem Raj wrote:
On Mon, Mar 14, 2022 at 5:34 AM Matheus K. Ferst
<matheus.ferst@eldorado.org.br> wrote:

On 12/03/2022 23:51, Khem Raj wrote:
Hi All

I have built an app with musl C library for ppc32 using clang 14.0.0
and I am using -mcpu=7400 to compile the whole thing including musl.
This fails to run on qemu usermode reporting illegal instruction, a
bit of digging revealed that it's caused by opcode in strspn()
function from musl where clang is emitting vxor instruction and that's
where qemu ppc bails out.

Here is asm file generated by clang

https://paste.debian.net/1233982/

gcc ( 11.2 )

https://paste.debian.net/1233983/

As you can see the disassembly for gcc does not have vxor or any other
altivec instructions in it.
When I add -mno-altivec to clang then the issue is gone or when I use
-mcpu=power5 the issue is gone too.

This is preprocessed strspn.i
https://paste.debian.net/1233987/

I wonder if qemu-ppc -mcpu 7400 should have understood vxor instruction or not ?

Hi Khem,

A quick test suggests that vxor is working with -cpu 7400:
$ cat > vxor.c << EOF
int main(void)
{
      asm volatile ("vxor 2, 2, 2\n\t" ::: "v2");
      return 0;
}
EOF
$ powerpc64-linux-gnu-gcc -m32 -mcpu=7400 vxor.c -o vxor -static
$ qemu-ppc -cpu 7400 vxor
$ echo $?
0

Can you show us the command line you used? What version of QEMU are you
running?


I am using musl based toolchain, clang and qemu cmdline is
qemu-ppc64le -r 3.10.0 -cpu 7400 ....


Are you building for LE? I've tested strspn with a musl+clang toolchain, but it was BE.

gdb clearly is at vxor instruction when the system crashes.

If you have debug symbols in QEMU, gen_invalid is a good place to put a breakpoint and look around. You can check if gen_vxor is in the backtrace, if ctx->altivec_enabled is set, the opcode being parsed in the variable "insn" in ppc_tr_translate_insn, etc.

I also
found another problem
with clang when compiling musl itself where plt.got were not correct,
maybe there is relation
cant say yet.


If you find that it's not only a clang problem, please file a bug on GitLab with more information on how to reproduce this issue.

--
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]