Bug 8748 - qemu86-64 with corei7-64 did not support gcc optimization level 3 '-O3' very well
Summary: qemu86-64 with corei7-64 did not support gcc optimization level 3 '-O3' very ...
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 x86_64
: Medium+ normal
Target Milestone: 2.2 M1
Assignee: Aníbal Limón
QA Contact: David Rodriguez
URL:
Whiteboard:
: 8747 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-12-02 04:58 UTC by Hongxu Jia
Modified: 2016-06-17 17:05 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hongxu Jia 2015-12-02 04:58:57 UTC
1. On qemux86-64, set corei7-64 to instaed of core2-64
diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
index 489194a..080ca79 100644
--- a/meta/conf/machine/qemux86-64.conf
+++ b/meta/conf/machine/qemux86-64.conf
@@ -8,8 +8,8 @@ PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa"
 PREFERRED_PROVIDER_virtual/libgles2 ?= "mesa"
 
 require conf/machine/include/qemu.inc
-DEFAULTTUNE ?= "core2-64"
-require conf/machine/include/tune-core2.inc
+DEFAULTTUNE ?= "corei7-64"
+require conf/machine/include/tune-corei7.inc
 
 KERNEL_IMAGETYPE = "bzImage"

diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 3b0e54c..1543f94 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -442,7 +442,7 @@ if [ "$MACHINE" = "qemux86-64" ]; then
     if [ "$KVM_ACTIVE" = "yes" ]; then
         CPU_SUBTYPE=kvm64
     else
-        CPU_SUBTYPE=core2duo
+        CPU_SUBTYPE=Nehalem
     fi
     if [ ! -z "$vga_option" ]; then
         QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"

2. Make use of service in meta-skeleton to do the test
diff --git a/meta-skeleton/recipes-skeleton/service/service/skeleton_test.c b/meta-skeleton/recipes-skeleton/service/service/skeleton_test.c
index 96c67ac..a338b20 100644
--- a/meta-skeleton/recipes-skeleton/service/service/skeleton_test.c
+++ b/meta-skeleton/recipes-skeleton/service/service/skeleton_test.c
@@ -1,12 +1,32 @@
-#include <unistd.h>
-
-/* This demo does nothing except for testing /etc/init.d/skeleton */
-
-int main(int argc, char *argv[])
-{
-       daemon(0, 0);
-       while (1) {
-               sleep(1);
-       }
-       return 0;
-}
+#include <stdio.h> 
+#include <string.h> 
+
+int main(int argc, char *argv[]) 
+{ 
+    char hex_digest[44]; 
+    char digest[20] = {0xc4, 0xf9, 0x37, 0x5f, 0x98, 
+                       0x34, 0xb4, 0xe7, 0xf0, 0xa5, 
+                       0x28, 0xcc, 0x65, 0xc0, 0x55, 
+                       0x70, 0x2b, 0xf5, 0xf2, 0x4a}; 
+    unsigned int i, j, digest_size = 20; 
+
+    /* Make hex version of the digest: correct in qemu */ 
+    memset(hex_digest, 0, sizeof(hex_digest)); 
+    for (i=0; i<digest_size; i++) 
+        sprintf(hex_digest+i*2, "%x", digest[i]&0xFF); 
+    printf("hex_digest %s\n", hex_digest); 
+
+    /* Make hex version of the digest: incorrect in qemu */ 
+    memset(hex_digest, 0, sizeof(hex_digest)); 
+    for(i=j=0; i<digest_size; i++) { 
+        char c; 
+        c = (digest[i] >> 4) & 0xf; 
+        c = (c>9) ? c+'a'-10 : c + '0'; 
+        hex_digest[j++] = c; 
+        c = (digest[i] & 0xf); 
+        c = (c>9) ? c+'a'-10 : c + '0'; 
+        hex_digest[j++] = c; 
+    } 
+    printf("hex_digest %s\n", hex_digest); 
+} 
+
diff --git a/meta-skeleton/recipes-skeleton/service/service_0.1.bb b/meta-skeleton/recipes-skeleton/service/service_0.1.bb
index c5cd7a9..e00f033 100644
--- a/meta-skeleton/recipes-skeleton/service/service_0.1.bb
+++ b/meta-skeleton/recipes-skeleton/service/service_0.1.bb
@@ -9,7 +9,7 @@ SRC_URI = "file://skeleton \
           "
 
 do_compile () {
-       ${CC} ${WORKDIR}/skeleton_test.c -o ${WORKDIR}/skeleton-test
+       ${CC} -O3 ${WORKDIR}/skeleton_test.c -o ${WORKDIR}/skeleton-test
 }
 
 do_install () {


3. $ Add service to image
In bblayers.conf
...
BBLAYERS ?= " \ 
  /buildarea/raid0/hjia/poky/meta \
  /buildarea/raid0/hjia/poky/meta-yocto \
  /buildarea/raid0/hjia/poky/meta-skeleton \
  /buildarea/raid0/hjia/poky/meta-yocto-bsp \
  "
...

In local.conf
...
MACHINE ?= "qemux86-64"
IMAGE_INSTALL_append = " service"
...

bitbake core-image-minimal

4. Run qemu and invoke service
runqemu qemux86-64 nographic

root@qemux86-64:~# skeleton-test 
hex_digest c4f9375f9834b4e7f0a528cc65c055702bf5f24a
hex_digest c4f9375f9834b4e7f005080c050005002bf5f24a

The two hex_digest outputs should be same, but it is not on qemux86-64 with corei7-64

//Hongxu
Comment 1 Hongxu Jia 2015-12-02 05:00:59 UTC
It is the root cause of https://bugzilla.yoctoproject.org/show_bug.cgi?id=8747
Comment 2 Ross Burton 2015-12-02 15:11:23 UTC
Can you (or have you) reported this to upstream?
Comment 3 Hongxu Jia 2015-12-03 01:35:20 UTC
(In reply to comment #2)
> Can you (or have you) reported this to upstream?

Got it, let me do some investigation

//Hongxu
Comment 4 Ross Burton 2015-12-03 15:57:34 UTC
*** Bug 8747 has been marked as a duplicate of this bug. ***
Comment 5 Cristian Iorga 2015-12-04 15:55:37 UTC
The latest qemu changelog adds the following info for IA and x86 and related architectures:
"CPU models and features
Haswell and Broadwell CPU models now include ABM
Cache information passthrough (which was enabled by default on "-cpu host") is now disabled by default
ABM, POPCNT, and SSE4a are not enabled in the default CPU models (qemu64, qemu32) anymore, as many hosts don't support it
RDTSCP was removed from AMD CPU models, as current KVM versions can't expose RDTSCP to guests in AMD hosts
New Intel memory instructions (clflushopt/clwb/pcommit) are now supported"
Comment 6 Saul Wold 2016-03-31 15:17:42 UTC
It appears that this might be fixed in the upstream now, but will require a qemu update, this will have to wait for 2.2.  Assigning to Qemu maintainer
Comment 7 Aníbal Limón 2016-05-11 19:04:11 UTC
I tested in master with your changes [1] and it works under qemu 2.5.0.

I don't now if it is targeted to work for qemu 2.4.x or this bug could be closed?.

[1] http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=alimon/simple_patches&id=b0059633ca6017ef5c3947ca84920b0a89f23cff
Comment 8 Hongxu Jia 2016-05-13 04:50:16 UTC
(In reply to comment #7)
> I tested in master with your changes [1] and it works under qemu 2.5.0.
> 
> I don't now if it is targeted to work for qemu 2.4.x or this bug could be
> closed?.
> 
> [1]
> http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=alimon/
> simple_patches&id=b0059633ca6017ef5c3947ca84920b0a89f23cff

I think your test is reasonable, my suggestion is to close it

//Hongxu
Comment 9 Aníbal Limón 2016-05-13 17:27:05 UTC
Closing because this issue was fixed in qemu 2.5.x.
Comment 10 David Rodriguez 2016-06-17 17:05:56 UTC
As stated on Comment 7 this issue is already verified.