Maybe that is https://reviews.llvm.org/D30171. On Mon, Feb 20, 2017 at 11:16 PM, Dmitry Golovin <dima at golovin.in> wrote:> Hi, > > I can't build the Linux kernel anymore. With the latest kernel source and > latest LLVM and LLD (with D30163) I can only get this error message when > linking vmlinux: > > ld.lld: error: unable to move location counter backward > > Did you have similar errors? How do I get rid of it? > > Regards, > Dmitry > > > 20.02.2017, 17:51, "George Rimar" <grimar at accesssoftek.com>: > > And I think current issue with "Kernel panic - not syncing: IO-APIC + > timer doesn't work!" is also clear. > > timer_irq_works(void) never returns 1: > https://github.com/torvalds/linux/blob/d966564fcdc19e13eb6ba1fbe6b810 > 1070339c3d/arch/x86/kernel/apic/io_apic.c#L1641 > > I think it happens because of jiffies (http://www.makelinux.net/ > books/lkd2/ch10lev1sec3#ch10fig01) > > It should have the same address as jiffies_64: > https://github.com/torvalds/linux/blob/b66484cd74706fa8681d051840fe4b > 18a3da40ff/arch/x86/kernel/vmlinux.lds.S#L41 > > And that is true for BFD linked binary: > 10595: ffffffff8140b000 8 OBJECT GLOBAL DEFAULT 8 jiffies > 11730: ffffffff8140b000 8 OBJECT GLOBAL DEFAULT 8 jiffies_64 > > But something is wrong with them for LLD case: > 6422: ffffffff8140b000 8 OBJECT GLOBAL DEFAULT 19 jiffies > 7416: ffffffff81400000 0 NOTYPE GLOBAL DEFAULT 19 jiffies_64 > > I think we probably incorrectly assign symbols outside SECTIONS > declarations in scripts. Looking at it. > > George. > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170220/a3bf01d7/attachment.html>
Dmitry Golovin via llvm-dev
2017-Feb-21 11:17 UTC
[llvm-dev] Linking Linux kernel with LLD
<div>Thank you! It worked and I finally got a working kernel. Here is the kernel boot log:</div><div> </div><div><div> Linux version 4.10.0+ (build@buildarch) (gcc version 6.3.1 20170109 (GCC) ) #2 Tue Feb 21 13:08:29 EET 2017</div><div> Command line: console=ttyS0 noapic</div><div> x86/fpu: Legacy x87 FPU detected.</div><div> e820: BIOS-provided physical RAM map:</div><div> BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable</div><div> BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved</div><div> BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved</div><div> BIOS-e820: [mem 0x0000000000100000-0x0000000007fdffff] usable</div><div> BIOS-e820: [mem 0x0000000007fe0000-0x0000000007ffffff] reserved</div><div> BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved</div><div> NX (Execute Disable) protection: active</div><div> e820: last_pfn = 0x7fe0 max_arch_pfn = 0x400000000</div><div> found SMP MP-table at [mem 0x000f6640-0x000f664f] mapped at [ffff8800000f6640]</div><div> RAMDISK: [mem 0x04718000-0x07fdffff]</div><div> Zone ranges:</div><div> DMA32 [mem 0x0000000000001000-0x0000000007fdffff]</div><div> Normal empty</div><div> Movable zone start for each node</div><div> Early memory node ranges</div><div> node 0: [mem 0x0000000000001000-0x000000000009efff]</div><div> node 0: [mem 0x0000000000100000-0x0000000007fdffff]</div><div> Initmem setup node 0 [mem 0x0000000000001000-0x0000000007fdffff]</div><div> Intel MultiProcessor Specification v1.4</div><div> MPTABLE: OEM ID: BOCHSCPU</div><div> MPTABLE: Product ID: 0.1 </div><div> MPTABLE: APIC at: 0xFEE00000</div><div> Processor #0 (Bootup-CPU)</div><div> IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23</div><div> Processors: 1</div><div> e820: [mem 0x08000000-0xfffbffff] available for PCI devices</div><div> clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 30582079743023 ns</div><div> Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32169</div><div> Kernel command line: console=ttyS0 noapic</div><div> PID hash table entries: 512 (order: 0, 4096 bytes)</div><div> Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)</div><div> Inode-cache hash table entries: 8192 (order: 4, 65536 bytes)</div><div> Memory: 65016K/130552K available (740K kernel code, 218K rwdata, 116K rodata, 424K init, 236K bss, 65536K reserved, 0K cma-reserved)</div><div> NR_IRQS:4352 nr_irqs:48 16</div><div> console [ttyS0] enabled</div><div> tsc: Fast TSC calibration using PIT</div><div> tsc: Detected 2494.298 MHz processor</div><div> Calibrating delay loop (skipped), value calculated using timer frequency.. 4988.59 BogoMIPS (lpj=9977192)</div><div> pid_max: default: 4096 minimum: 301</div><div> Mount-cache hash table entries: 512 (order: 0, 4096 bytes)</div><div> Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)</div><div> Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0</div><div> Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0</div><div> CPU: AMD QEMU Virtual CPU version 2.4.0 (family: 0x6, model: 0x6, stepping: 0x3)</div><div> Performance Events: PMU not available due to virtualization, using software events only.</div><div> APIC timer disabled due to verification failure</div><div> clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns</div><div> clocksource: Switched to clocksource refined-jiffies</div><div> Unpacking initramfs...</div><div> Freeing initrd memory: 58144K</div><div> platform rtc_cmos: registered platform RTC device (no PNP device found)</div><div> workingset: timestamp_bits=62 max_order=15 bucket_order=0</div><div> Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled</div><div> serial8250: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A</div><div> Freeing unused kernel memory: 424K</div><div> Write protecting the kernel read-only data: 4096k</div><div> Freeing unused kernel memory: 1300K</div><div> random: fast init done</div><div> Freeing unused kernel memory: 1932K</div><div> Failed to execute /init (error -2)</div><div> Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.</div><div> Kernel Offset: disabled</div><div> ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.</div><div> </div><div><br />Regards,</div><div>Dmitry</div></div><div><br /></div><div><br /></div><div>21.02.2017, 09:26, "Rui Ueyama" <ruiu@google.com>:</div><blockquote type="cite"><div dir="ltr">Maybe that is <a href="https://reviews.llvm.org/D30171">https://reviews.llvm.org/D30171</a>.</div><div><br /><div>On Mon, Feb 20, 2017 at 11:16 PM, Dmitry Golovin <span dir="ltr"><<a href="mailto:dima@golovin.in" target="_blank">dima@golovin.in</a>></span> wrote:<br /><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div>Hi,</div><div> </div><div>I can't build the Linux kernel anymore. With the latest kernel source and latest LLVM and LLD (with D30163) I can only get this error message when linking vmlinux:</div><div> </div><div>ld.lld: error: unable to move location counter backward<div> </div><div>Did you have similar errors? How do I get rid of it?</div></div><div> </div><div>Regards,</div><div>Dmitry</div></div><div><br /></div><div><br /></div><div>20.02.2017, 17:51, "George Rimar" <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>>:</div><div><div><blockquote type="cite"> <div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif;"> <p></p> <div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif;"> <div> <div> <div>And I think current issue with "Kernel panic - not syncing: IO-APIC + timer doesn't work!" is also clear.</div> <div><br /> </div> <div>timer_irq_works(void) never returns 1:</div> <div><a href="https://github.com/torvalds/linux/blob/d966564fcdc19e13eb6ba1fbe6b8101070339c3d/arch/x86/kernel/apic/io_apic.c#L1641" target="_blank">https://github.com/torvalds/<wbr />linux/blob/<wbr />d966564fcdc19e13eb6ba1fbe6b810<wbr />1070339c3d/arch/x86/kernel/<wbr />apic/io_apic.c#L1641</a></div> <div><br /> </div> <div>I think it happens because of jiffies (<a href="http://www.makelinux.net/books/lkd2/ch10lev1sec3#ch10fig01" target="_blank">http://www.makelinux.net/<wbr />books/lkd2/ch10lev1sec3#<wbr />ch10fig01</a>)</div> <div><br /> </div> <div>It should have the same address as jiffies_64:</div> <div><a href="https://github.com/torvalds/linux/blob/b66484cd74706fa8681d051840fe4b18a3da40ff/arch/x86/kernel/vmlinux.lds.S#L41" target="_blank">https://github.com/torvalds/<wbr />linux/blob/<wbr />b66484cd74706fa8681d051840fe4b<wbr />18a3da40ff/arch/x86/kernel/<wbr />vmlinux.lds.S#L41</a></div> <div><br /> </div> <div>And that is true for BFD linked binary:</div> <div> 10595: ffffffff8140b000 8 OBJECT GLOBAL DEFAULT 8 jiffies</div> <div> 11730: ffffffff8140b000 8 OBJECT GLOBAL DEFAULT 8 jiffies_64</div> <div> </div> <div>But something is wrong with them for LLD case:</div> <div> 6422: ffffffff8140b000 8 OBJECT GLOBAL DEFAULT 19 jiffies</div> <div> 7416: ffffffff<span><span>81400000</span></span> 0 NOTYPE GLOBAL DEFAULT 19 jiffies_64</div> <div> </div> <div>I think we probably incorrectly assign symbols outside SECTIONS declarations in scripts. Looking at it.<br /> </div> <br /> </div> <p>George.<br /> </p> </div> </div> </div> </blockquote> </div></div></blockquote></div><br /></div> </blockquote>
>Thank you! It worked and I finally got a working kernel. Here is the kernel boot log:Sound great ! Though I ended with error from log below. Had no chance to fix it yet: ? CPU: AMD QEMU Virtual CPU version 2.5+ (family: 0x6, model: 0x6, stepping: 0x3) Performance Events: PMU not available due to virtualization, using software events only. ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 ..MP-BIOS bug: 8254 timer not connected to IO-APIC ...trying to set up timer (IRQ0) through the 8259A ... ..... (found apic 0 pin 2) ... ....... failed. ...trying to set up timer as Virtual Wire IRQ... ..... failed. ...trying to set up timer as ExtINT IRQ... ..... failed :(. Kernel panic - not syncing: IO-APIC + timer doesn't work! Boot with apic=debug and send a report. Then try booting with the 'noapic' option. ---[ end Kernel panic - not syncing: IO-APIC + timer doesn't work! Boot with apic=debug and send a report. Then try booting with the 'noapic' option. random: fast init done Did you see something alike ? Looks there is nothing in your log about these timers. I suppose you disabled those ? George. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170221/2ead967c/attachment.html>