Bug 347 - [QT] libQtGui.so on qemux86-64 uses SSSE3 instructions and crashes Qemu
Summary: [QT] libQtGui.so on qemux86-64 uses SSSE3 instructions and crashes Qemu
Status: VERIFIED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: 0.9
Hardware: x86 Multiple
: Medium normal
Target Milestone: 0.9 M4
Assignee: Qing He
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks: 280
  Show dependency tree
 
Reported: 2010-09-21 00:51 UTC by Qing He
Modified: 2010-12-21 06:07 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified: Program Management
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Qing He 2010-09-21 00:51:35 UTC
See also bug 280, it is observed in fotowall loading

######
root@qemux86-64:~# DISPLAY=:0.0 fotowall
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for
BOM: Bad file descriptor
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open
failed
QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
Illegal instruction
######

And dmesg shows
######
fotowall[842] trap invalid opcode ip:7f92361fc1ed sp:7ffff191b798 error:0 in
libQtGui.so.4.6.3[7f9236067000+9d0000]
######


The offending function is qt_blend_argb32_on_argb3_sse2(), it calls intrinsic _mm_set_epi16, and it compiles to PSHUFB, which is only available in SSSE3.

Qemu needs to run with -cpu qemux86-64,+ssse3 explicitly, or it crashes.
Comment 1 Qing He 2010-09-25 20:23:29 UTC
mark this bug at Intel confidential

QtGui has an internal cpu dispatcher, so ideally gdrawhelper_sse2 shouldn't include ssse3 instructions, it uses -msse2 as gcc flags. PSHUFB is actually generated by the use of -march=core2 in gcc-4.5, reproducing it is simple

---
$ cat a.c
#include <emmintrin.h>
__m128i f(int a)
{
    return _mm_set1_epi16(a);
}

$ gcc-4.5 -O2 -m64 -march=core2 -c a.c
$ objdump -d a.o
0000000000000000 <f>:
   0:   66 0f 6e c7             movd   %edi,%xmm0
   4:   66 0f 38 00 05 00 00    pshufb 0x0(%rip),%xmm0   # d <f+0xd>
   b:   00 00
   d:   c3                      retq
---

it can be fixed in at least two ways:
  1. not using -march=core2 for generic machine like qemux86-64
  2. adding "-cpu qemu64,+ssse3" or "-cpu core2duo" into qemu command line

#2 is easier, but it may leads to controversy like:
  http://mer-l-in.blogspot.com/2010/08/are-intel-subverting-meegocom.html
Comment 3 Qing He 2010-10-21 01:01:37 UTC
after removing the optimization flag, the crash doesn't happen anymore
Comment 4 Qing He 2010-10-21 01:01:57 UTC
marked as verified