OS-6694: bhyve uart emulation does not handle 4 byte requests

Details

Issue Type:Bug
Priority:4 - Normal
Status:Resolved
Created at:2018-02-25T19:15:14.716Z
Updated at:2018-03-16T18:29:12.643Z

People

Created by:Former user
Reported by:Former user
Assigned to:Former user

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2018-03-16T18:29:12.629Z)

Fix Versions

2018-03-29 Old Man's House (Release Date: 2018-03-29)

Labels

bhyve

Description

uefi debug statements write 4 bytes at a time. lpc_uart_io_handler() only handles one or two bytes at a time, causing uefi debug output to crash bhyve.

+ /usr/sbin/amd64/bhyve -m 2g -c 1 -l com1,stdio -l com2,socket,/tmp/sock -H -s 0,hostbridge -s 1,lpc -s 3,virtio-blk,/dev/zvol/rdsk/zones/lba-debug -l bootrom,/zones/uefi-csm-rom.bin lba-debug
Unhandled outl 0x03f8 at 0xf4190
                                Abort (core dumped)

Comments

Comment by Former user
Created at 2018-02-25T19:20:30.349Z

A bit of dtrace shows:

...
 51  -> emulate_inout                                         0
 51    -> vie_size2mask                                       0
 51    <- vie_size2mask                              4294967295
 51    -> lpc_uart_io_handler                                 0
 51     | lpc_uart_io_handler:entry           ctx: 7a5f70 vcpu: 0 in: 0, port: 1016, bytes: 4
 51    <- lpc_uart_io_handler                        4294967295
 51  <- emulate_inout                                4294967295
#!/usr/sbin/dtrace -Fs

pid$target:a.out:emulate_inout:entry
{
	self->interest = 1;
}

pid$target:a.out::entry,
pid$target:a.out::return
/self->interest/
{
	trace(arg1);
}

pid$target::lpc_uart_io_handler:entry
{
	printf("ctx: %x vcpu: %d in: %d, port: %d, bytes: %d",
		arg0, arg1, arg2, arg3, arg4);
}

pid$target:a.out:emulate_inout:return
{
	self->interest = 0;
}


Comment by Former user
Created at 2018-02-27T19:32:35.292Z

Fix is ready to go, waiting for dev-bhyve merge to master to complete before pushing.

https://github.com/mgerdts/illumos-joyent/commits/OS-6694


Comment by Former user
Created at 2018-03-16T18:00:10.322Z
Updated at 2018-03-16T18:01:23.696Z

Tested fix with using debug rom that I built. I copied that to <zoneroot>/uefi-csm-rom-debug-com1-info.bin then:

zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0> add attr
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0:attr> set name=bootrom
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0:attr> set type=string
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0:attr> set value="/uefi-csm-rom-debug-com1-info.bin"
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0:attr> info
attr:
        name: bootrom
        type: string
        value: /uefi-csm-rom-debug-com1-info.bin
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0:attr> end
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0> verify
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0> commit
zonecfg:79062669-e229-e55d-960d-9b18d0fed8d0> exit

On booting the guest, I saw a bunch of debug output from UEFI on the console while grub was running.

[NOTICE: Zone booting up]
XXX CsmMain() Regs->X.AX=0x0
XXX CsmLegacy16InitializeYourself()
XXX ESegmentInitializePool() Base 0xE0000 Max 0xEFFFF
XXX FSegmentInitializePool() Base 0xFBFA0 Max 0xFFFFF
XXX CsmMain() Regs->X.AX=0x6
...

Details on building a debug bootrom are at https://mgerdts.github.io/2018/02/25/uefi-debug-in-bhyve.html.

Other guests that did not have bootrom customized booted just fine.


Comment by Jira Bot
Created at 2018-03-16T18:27:14.635Z

illumos-joyent commit 37c3d9c0c52dc69f6c31123761894a1c85149f8c (branch master, by Mike Gerdts)

OS-6694 bhyve uart emulation does not handle 4 byte requests
Reviewed by: John Levon <john.levon@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>