<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>I found that bug finally :)<br>
</p>
<p><br>
</p>
<p>I dumped output for kernel and observed that LLD output starts from ELF header, while BFD points to some code data it seems, what is expected since execution flow makes jmp there.<br>
</p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt">That means decompressed kernel was not copied properly and i</span><span style="font-size:12pt">ssue is at one of points you sent earlier:</span></p>
<p><a href="https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/arch/x86/boot/compressed/misc.c#L300">https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/arch/x86/boot/compressed/misc.c#L300</a><br>
</p>
<p><br>
</p>
<p>Looking on readelf output for vmlinux, <span style="font-size:12pt"> BFD loads has correct LMAs:</span></p>
<div>  LOAD           0x0000000000200000 0xffffffff81000000 0x0000000001000000</div>
<div>                 0x0000000000241000 0x0000000000241000  R E    200000</div>
<div>  LOAD           0x0000000000600000 0xffffffff81400000 0x0000000001400000</div>
<div>                 0x0000000000041000 0x0000000000041000  RW     200000</div>
<div>  LOAD           0x0000000000641000 0xffffffff81441000 0x0000000001441000</div>
<div>                 0x0000000000070699 0x00000000000c4000  RWE    200000<br>
</div>
<div><br>
</div>
<div>But LLD output is broken at that part, <span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">a</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">ll
 LMA are </span><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">0x0000000080000000</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)"> here</span>​:<br>
</div>
<div>
<div>  LOAD           0x0000000000001000 0xffffffff81000000 0x0000000080000000</div>
<div>                 0x0000000000242000 0x0000000000242000  R E    1000</div>
<div>  LOAD           0x0000000000243000 0xffffffff81400000 0x0000000080000000</div>
<div>                 0x0000000000041000 0x0000000000041000  RW     1000</div>
<div>  LOAD           0x0000000000284000 0xffffffff81441000 0x0000000080000000</div>
<div>                 0x0000000000071000 0x00000000000c4000  RWE    1000<br>
</div>
<div><br>
</div>
<div>That happened because <span style="font-size:12pt">script sets address in next way:</span></div>
</div>
<div>.text : AT(ADDR(.text) - 0xffffffff80000000) { ... }<br>
</div>
<div>.data : AT(ADDR(.data) - 0xffffffff80000000) { .. }<br>
</div>
<div>.init.begin : AT(ADDR(.init.begin) - 0xffffffff80000000) { ... }<br>
</div>
<div><br>
</div>
<div>We currently just calculate ADDR(..) as zero in such cases and because of that </div>
<div>always have result == <span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">0x000000008</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">0</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)">000000</span>
 finally. That is the reason of kernel corruption.<br>
</div>
<div><br>
</div>
<div>I prepared patch that fixes it: <a href="https://reviews.llvm.org/D30163">https://reviews.llvm.org/D30163</a>, with that in, I was able to pass that place<br>
</div>
<div>and QEMU no more reboots for me ! </div>
<div><br>
</div>
<div>Though it still hangs a bit later, atm it shows:<br>
</div>
<div>
<div>CPU: AMD QEMU Virtual CPU version 2.5+ (family: 0x6, model: 0x6, stepping: 0x3)</div>
<div>Performance Events: PMU not available due to virtualization, using software events only.</div>
<div>..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1</div>
<div>..MP-BIOS bug: 8254 timer not connected to IO-APIC</div>
<div>...trying to set up timer (IRQ0) through the 8259A ...</div>
<div>..... (found apic 0 pin 2) ...</div>
<div>....... failed.</div>
<div>...trying to set up timer as Virtual Wire IRQ...</div>
<div>..... failed.</div>
<div>...trying to set up timer as ExtINT IRQ...</div>
<div>..... failed :(.</div>
<div>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.<br>
</div>
<div>---[ 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.<br>
</div>
<div>random: fast init done</div>
<div><br>
</div>
</div>
<div>but that is definetely a different new issue, I am investigating it.<br>
</div>
<div>(at least I am happy there is no more silent QEMU reboots and it shows some readable error messages it seems).<br>
</div>
<div><br>
</div>
<p>George.<br>
</p>
</body>
</html>