9-pcboot-e820-regs: 9load passes amd64 kernels an empty memory map
Before going to protected mode, the pcboot loaders ask the BIOS for
the E820 memory map (INT 15h, AX=E820h) and keep the entries at
BIOSTABLES; warp64 hands them to an amd64 kernel in its multiboot
header. The call takes a 32-bit continuation value in EBX (zero for
the first call) and a buffer at ES:DI. l16r.s (9load, 9loadusb) and
ldecomp.s (9boot, 9bootpbs) clear them with CLR, which clears only
BX and DI:
CLR(rDI)
...
CLR(rBX)
Whatever an earlier BIOS call left in the upper halves of EBX and EDI
goes into the first E820 call. A BIOS that reads all of EBX sees a
nonzero continuation value, fails the call, and the loop ends with no
entries. i386 kernels do not notice: they query E820 themselves
(pc/memory.c). A 9k amd64 kernel has no other source of memory size,
so it panics in mmuinit:
warp64(0xffffffffc0110000) 0x110000 0
panic: mmuinit: pa 0x0 memstart 0x3fb000
The fix clears all of EBX and EDI (OPSIZE; CLR), as the 32-bit code
in pc/l.s and pcboot/realmode0.s does, and corrects the comment that
calls the continuation value BX.
Apply
cd /
ape/patch -p0 < /path/to/9-pcboot-e820-regs/9-pcboot-e820-regs.diff
Rebuild
cd /sys/src/9/pcboot && mk pcclean && mk 9load.install
mk pcclean removes kernel objects in /sys/src/9/pc; with
them the loader's link fails with redefinitions. The
other loaders are built the same way (mk install builds
all four).
Verification
Boot a 9k amd64 kernel through the new 9load and read the line
9load prints before jumping to it:
warp64(0xffffffffc0110000) 0x110000 N
Before: N = 0 and the kernel panics as above.
After: N is the number of E820 entries the i386 kernel prints
at boot, and the kernel starts.
|