[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 1 12:34:04 PST 2022


nickdesaulniers added a comment.

Hey! Looks like Diff 404763 for an x86 defconfig plus CONFIG_ZERO_CALL_USED_REGS=y starts booting! Looks like it panics though trying to launch `init`(pid 1) though.

  [    0.702163] Run /bin/sh as init process
  [    0.702913] Failed to execute /bin/sh (error -22)
  [    0.703721] Run /sbin/init as init process
  [    0.704454] Starting init: /sbin/init exists but couldn't execute it (error -22)
  [    0.705702] Run /etc/init as init process
  [    0.706390] Run /bin/init as init process
  [    0.707037] Run /bin/sh as init process
  [    0.707736] Starting init: /bin/sh exists but couldn't execute it (error -22)
  [    0.708895] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
  [    0.711246] CPU: 1 PID: 1 Comm: sh Not tainted 5.16.0-12116-g74e25defe135 #6
  [    0.712426] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  [    0.713778] Call Trace:
  [    0.714188]  <TASK>
  [    0.714578]  dump_stack_lvl+0x65/0x9a
  [    0.715190]  panic+0x101/0x295
  [    0.715743]  ? _printk+0x54/0x80
  [    0.716297]  ? rest_init+0xd0/0xd0
  [    0.716882]  kernel_init+0x18b/0x190
  [    0.717525]  ret_from_fork+0x22/0x30
  [    0.718138]  </TASK>
  [    0.721159] Kernel Offset: 0xe800000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
  [    0.722977] ---[ end Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---

If I disable `CONFIG_ZERO_CALL_USED_REGS=y`, I can launch userspace just fine. (`Error -22` corresponds to `EINVAL` FWIW).  Perhaps some kernel code related to launching init (or processes, generally) isn't happy with a zero'd register somewhere, or we have another codegen bug.  Either way, that needs to be investigated+fixed before merging.  Probably could sprinkle `subdir-ccflags-y += -fzero_call_used_regs=skip` (or whatever) in various Makefiles to pinpoint which object file is affected, then take a look at the disassembly from there. (or add function attributes to get more fine grained).

It looks like the Kconfig detection for `CONFIG_CC_HAS_ZERO_CALL_USED_REGS` is working correctly now. i.e.

  $ ARCH=arm64 make LLVM=1 -j72 defconfig
  $ grep -rn ZERO_CALL_USED_REGS .config
  $ make LLVM=1 -j72 defconfig
  $ grep -rn ZERO_CALL_USED_REGS .config
  4230:CONFIG_CC_HAS_ZERO_CALL_USED_REGS=y
  4231:# CONFIG_ZERO_CALL_USED_REGS is not set

(LGTM)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110869/new/

https://reviews.llvm.org/D110869



More information about the llvm-commits mailing list