rumpkernel and bhyve: triple faults

Martin Lucina martin at lucina.net
Sat Mar 10 22:55:51 UTC 2018


Hi,

On Friday, 09.03.2018 at 18:45, Fabian Freyer wrote:
> On 6 Mar 2018, at 7:45, Fabian Freyer wrote:
> > Tracking down bios_crtc_base, I find that it’s loaded in
> > rumprun/platform/hw/arch/amd64/locore.S:70:
> >
> > 	/* save BIOS data area values */
> > 	movw BIOS_COM1_BASE, %bx
> > 	movw %bx, bios_com1_base
> > 	movw BIOS_CRTC_BASE, %bx
> > 	movw %bx, bios_crtc_base
> >
> > Where BIOS_CRTC_BASE is 0x463 and BIOS_COM1_BASE is 0x400. Checking the bhyve
> > device node in /dev/vmm with xxd(1), I find the words at these addresses to be
> > Uninitialised:
> >
> > 00000400: 0000                                     ..
> > 00000483: 0000                                     ..
> >
> > I’m not sure where to go from here. Is this a bug in bhyve(4), should these
> > values be initialised somehow, or should I patch rumpkernel(7) to skip this check
> > when running on bhyve(4)?

You probably want to use a serial console rather than VGA on bhyve in any
case, so you'll want to add the appropriate checks to hypervisor.c and
cons.c.

> I’ve chased this bug down a bit further to what I believe is an issue with the
> rumprun toolchain I am building on FreeBSD with the misc/rumprun port [1].
> 
> objdump -t helloer-rumprun.elf list a number of symbols in the *COM* section, which
> holds unallocated C external variables [2]:
> 
> objdump -t helloer-rumprun.elf | grep \*COM\*
> 00000001 l     O *COM*   00000001 pic1mask
> 00000004 l     O *COM*     00000004 pgalloc_totalkb
> 00000004 l     O *COM*     00000004 pgalloc_usedkb
> 00001000 l     O *COM*     00000020 multiboot_cmdline
> 00000002 l     O *COM*     00000002 bios_crtc_base
> 00000001 l     O *COM*     00000001 pic2mask
> 00000002 l     O *COM*     00000002 bios_com1_base
> 
> As the pagetable in pagetable.s maps the first page as non-present, accessing any
> of these will result in a fault. I’m pretty sure that these shouldn’t be undefined.
> 
> A build on Linux (which boots fine) shows these not to be uninitialised:
> 00000000003e3480 g     O .bss	0000000000000002 bios_com1_base
> 00000000003e44a0 g     O .bss	0000000000000002 bios_crtc_base

When you write "which boots fine", I presume you're referring to booting on
bhyve?

> Further down the rabbit hole, this goes on in rumprun.o:
> 
> On Linux, bios_crtc_base is not a local symbol:
> 0000000000000002       O *COM*  0000000000000002 bios_crtc_base
> 0000000000000002       O *COM*  0000000000000002 bios_com1_base
> 
> While on FreeBSD, they are marked as local:
> 0000000000000002 l     O *COM*  0000000000000002 bios_crtc_base
> 0000000000000002 l     O *COM*  0000000000000002 bios_com1_base

That seems wrong. Can you try and force the toolchain to use the more
recent GNU ld from devel/binutils and see if that fixes the problem?

-mato


More information about the freebsd-virtualization mailing list