Bug 347

Summary: [QT] libQtGui.so on qemux86-64 uses SSSE3 instructions and crashes Qemu
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Qing He <qing.he>
Component: meta-yoctoAssignee: Qing He <qing.he>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: jessica.zhang, jiajun.xu, ke.yu, kevin.tian, poky.bs.watcher, poky.watcher, richard.purdie, sgw
Version: 0.9   
Target Milestone: 0.9 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Program Management Documentation change: ---
Bug Depends on:    
Bug Blocks: 280    

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