<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>4854</bug_id>
          
          <creation_ts>2013-07-16 09:01:22 +0000</creation_ts>
          <short_desc>floor call (from math.h) is broken on qemuppc</short_desc>
          <delta_ts>2013-10-07 13:39:15 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>1.5</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.5</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Stefan Stanacar">sstncr</reporter>
          <assigned_to name="Khem Raj">raj.khem</assigned_to>
          <cc>bruce.ashfield</cc>
    
    <cc>elizabeth.flanagan</cc>
    
    <cc>jessica.zhang</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>34592</commentid>
    <comment_count>0</comment_count>
    <who name="Stefan Stanacar">sstncr</who>
    <bug_when>2013-07-16 09:01:22 +0000</bug_when>
    <thetext>poky commit: 74e403705e25afec656b5e40921771a9c29bdc40

1. Given 3 core-image-sato-sdk images for qemuarm, qemux86-64 and qemuppc and the following test.c file:

---cut here---
#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main(int argc, char * argv[])
{
  double f = 1234.67;
  printf(&quot;floor(%f) = %f\n&quot;, f, floor(f));
  return 0;                                 
}
---and here----

2. copy the test.c file on the target and run on the target:

gcc test.c -lm -o test
./test

3. The output will be:

- on qemux86-64 and qemuarm:

floor(1234.670000) = 1234.000000

- on qemuppc:

floor(1234.670000) = 1235.000000


Now according to the floor man page: 
&quot;floor, floorf, floorl - largest integral value not greater than argument
These functions return the largest integral value that is not greater than x.
For example, floor(0.5) is 0.0, and floor(-0.5) is -1.0&quot;
So, that&apos;s clearly broken on qemuppc.
I haven&apos;t tested this with adt-installer nor meta-toolchain.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34646</commentid>
    <comment_count>1</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2013-07-17 14:57:26 +0000</bug_when>
    <thetext>This works fine on real ppc(p2020) hardware. Could be qemu problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34651</commentid>
    <comment_count>2</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2013-07-17 21:29:38 +0000</bug_when>
    <thetext>another data point is that it works fine with uclibc/qemuppc now I wonder if it has to do with the machine 603e that we tune eglibc for when building it for qemuppc and the machine we use in qemu emulation which is G4/ppc7xxx, uclibc does not have any machine specific knowledge when it comes to these two ppc variants.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34766</commentid>
    <comment_count>3</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-07-22 20:14:04 +0000</bug_when>
    <thetext>*** Bug 4891 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34910</commentid>
    <comment_count>4</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2013-07-25 15:15:35 +0000</bug_when>
    <thetext>khem: are we seeing the same thing with softfloat or turn on math emulation
in the kernel ? I haven&apos;t checked if that&apos;s even possible for our mac99, but
wanted to toss that out. We&apos;ve seen plenty of softfloat -&gt; math emu -&gt; exception handling issues in the past with e500 cores, and this sounds similar.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35245</commentid>
    <comment_count>5</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-08-01 06:40:42 +0000</bug_when>
    <thetext>Where are we with this issue, it&apos;s a very visible failure on the Autobuilder 
due to the new sanity tests.  I am not sure if this needs an updated tune or 
changes to eglibc, Khem can you please let us know so we can have someone else 
look into it if needed.

Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35249</commentid>
    <comment_count>6</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2013-08-01 06:48:45 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Where are we with this issue, it&apos;s a very visible failure on the Autobuilder 
&gt; due to the new sanity tests.  I am not sure if this needs an updated tune or 
&gt; changes to eglibc, Khem can you please let us know so we can have someone
&gt; else 
&gt; look into it if needed.

Someone could play with tunings as I have suggested so to check if its not
the mismatch between tunings and qemu emulation mode. Rule out tuning mismatch
from suspects.

Try using older 1.4.x qemu and see if it fails consistently there too
rule out qemu from suspects.

Other track is to is to look into eglibc&apos;s implementation itself 
I cant look into it this week but someone beats me to it all the better

&gt; 
&gt; Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35310</commentid>
    <comment_count>7</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-08-01 23:39:14 +0000</bug_when>
    <thetext>More data, I build master and dylan today and ran master against 1.4 qemu and 
1.4 against master qemu (criss-cross).

1.4 Qemu with 1.4 Image = Good
1.4 Qemu with 1.5 Image = Good
1.5 Qemu with 1.4 Image = Bad
1.5 Qemu with 1.5 Image = Bad

So the winner is something changed in the current version of Qemu, I am going 
to try a quick and dirty update to 
qemu_git.  More info later.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35312</commentid>
    <comment_count>8</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-08-02 02:10:47 +0000</bug_when>
    <thetext>OK, bisect of qemu show this commit in qemu, this is as far as I can take this, 
I need someone with more PPC and Qemu know how to take this further

7d08d85645def18eac2a9d672c1868a35e0bcf79 is the first bad commit
commit 7d08d85645def18eac2a9d672c1868a35e0bcf79
Author: Aurelien Jarno &lt;aurelien@aurel32.net&gt;
Date:   Sat Apr 20 08:56:22 2013 +0000

    target-ppc: add support for extended mtfsf/mtfsfi forms
    
    Power ISA 2.05 adds support for extended mtfsf/mtfsfi form, with a new
    W field to select the upper part of the FPCSR register.
    
    For that the helper is changed to handle 64-bit input values and mask with
    up to 16 bits. The mtfsf/mtfsfi instructions do not have the W bit
    marked as invalid anymore. Instead this is checked in the helper, which
    therefore needs to access to the insns/insns_flags2. They are added in
    the DisasContext struct. Finally change all accesses to the opcode fields
    through extract helpers, prefixed with FP for consistency.
    
    Signed-off-by: Aurelien Jarno &lt;aurelien@aurel32.net&gt;
    Signed-off-by: Alexander Graf &lt;agraf@suse.de&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35431</commentid>
    <comment_count>9</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-08-06 15:38:02 +0000</bug_when>
    <thetext>This issue exists in the 3.10 kernel also, I tested with the latest 
linux-yocto-dev branch (AUTOREV&apos;ed)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35666</commentid>
    <comment_count>10</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2013-08-15 05:55:34 +0000</bug_when>
    <thetext>At this point its most likely a QEMU regression, since the eglibc/floor() function works fine on real h/w I did a static compile of binary to make sure it uses the same floor() function which fails on qemu.

I have initiated discussion on with qemu developers on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35669</commentid>
    <comment_count>11</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2013-08-15 13:58:51 +0000</bug_when>
    <thetext>The proposed patch works and thefore I have added it to qemu and sent out the patch on oe-core ml.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35823</commentid>
    <comment_count>12</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-08-21 17:41:13 +0000</bug_when>
    <thetext>http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=2a48e9007cc92fedfdb6919411859fb943eacc94</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37686</commentid>
    <comment_count>13</comment_count>
    <who name="Stefan Stanacar">sstncr</who>
    <bug_when>2013-10-07 13:39:15 +0000</bug_when>
    <thetext>Marked as Verified.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>