<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X86_32] Miscompilation with __llvm_retpoline_push"
   href="https://bugs.llvm.org/show_bug.cgi?id=36329">36329</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86_32] Miscompilation with __llvm_retpoline_push
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dwmw2@infradead.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19849" name="attach_19849" title="Config file for kernel build">attachment 19849</a> <a href="attachment.cgi?id=19849&action=edit" title="Config file for kernel build">[details]</a></span>
Config file for kernel build

After a call via __llvm_retpoline_push, code in the calling function seems
confused about where %esp points.

Reproduced with llvm/clang master (r324745 / r324741 resp.) and also with 6.0
branch (r324726 / r324719 resp) with r326645 added to the latter.

To reproduce:

  git clone git://git.infradead.org/linux-retpoline.git
  cd linux-retpoline
  git checkout clang
  cp /where/you/downloaded/the/attached/config .config
  make CC=/where/is/your/clang bzImage
  qemu-system-i386  -display none -serial stdio -kernel arch/x86/boot/bzImage 
-append earlyprintk=ttyS0,keep

Observe the output from mp_register_ioapic():
[    0.000000] mp_register_ioapic, 0 fec00000 0 c1b31e88
[    0.000000] At line 412, gsi_base is 0
[    0.000000] At line 425, gsi_base is -1043707140
[    0.000000] At line 427, gsi_base is -1043707140

Between line 412 and 425, gsi_base got clobbered.

Now uncomment the CFLAGS_io_apic_b line in arch/x86/kernel/apic/Makefile and
repeat, to disable the retpoline. Observe the problem go away.

To eliminate the external thunks as a cause of this problem, also retest with
CFLAGS_io_apic_b.o += -mno-retpoline-external-thunk -mretpoline
The problem persists even when we let LLVM emit its own thunks.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>