Page MenuHomeFreeBSD

bhyve: do not show the fwcfg device in the guest's user interface
AcceptedPublic

Authored by wanpengqian_gmail.com on Fri, Oct 2, 5:56 AM.
Tags
None
Referenced Files
F176272992: D60224.id189954.diff
Sat, Oct 17, 2:10 PM
Unknown Object (File)
Sat, Oct 17, 3:14 AM
Unknown Object (File)
Fri, Oct 16, 10:41 PM
Unknown Object (File)
Fri, Oct 16, 9:31 PM
Unknown Object (File)
Thu, Oct 15, 10:14 PM
Unknown Object (File)
Thu, Oct 15, 10:13 PM
Unknown Object (File)
Thu, Oct 15, 4:28 PM
Unknown Object (File)
Thu, Oct 15, 2:56 PM

Details

Reviewers
corvink
bnovkov
markj
Group Reviewers
bhyve
Summary

Windows has no driver for the fwcfg device (QEMU0002) and lists it in
Device Manager as an unknown device. Give it _STA 0x0B (present,
enabled, functioning, not shown in the user interface), which is what
QEMU does.

Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Sponsored by: keelos.dev

Test Plan

main (f958aa7e7), FreeBSD guest started with -o lpc.fwcfg=qemu, acpidump -d in the guest:

before

Device (FWCF)
{
    Name (_HID, "QEMU0002")  // _HID: Hardware ID
    Name (_STA, 0x0F)  // _STA: Status

after

Name (_STA, 0x0B)  // _STA: Status

With the same change on FreeBSD 14.5: a Windows guest with a TPM (which needs lpc.fwcfg=qemu) listed "Unknown device" (ACPI\QEMU0002) in Device Manager before and does not after. Linux's qemu_fw_cfg driver still attaches to the device (/sys/firmware/qemu_fw_cfg), as it does on QEMU.

The TPM device, the other user of acpi_device, keeps _STA 0x0F.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 78237
Build 75120: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Fri, Oct 2, 12:29 PM
markj added a subscriber: markj.
markj added inline comments.
usr.sbin/bhyve/acpi_device.c
199–203

It'd be nice to define symbolic constants for these bits.

wanpengqian_gmail.com edited the test plan for this revision. (Show Details)

Build _STA from ACPICA's ACPI_STA_DEVICE_* constants (markj)

This revision now requires review to proceed.Thu, Oct 15, 5:14 AM

Thanks, done: _STA is now built from ACPICA's ACPI_STA_DEVICE_PRESENT/ENABLED/FUNCTIONING/UI bits (acpi_device.h already includes acpi.h).

This revision is now accepted and ready to land.Thu, Oct 15, 6:28 PM

Just a side note: There's a driver for Windows [1]. However, it's not very useful because it drives the VMCoreInfo device which isn't implemented in bhyve [2]. Honestly, I don't even know if it refuses to load due to the missing fwcfg device. There's also a dummy driver which should load [3].

[1] https://github.com/virtio-win/kvm-guest-drivers-windows/blob/d92b9c073ec1108f51846d0bd109c5796b46fd36/fwcfg64/fwcfg.inf
[2] https://www.qemu.org/docs/master/specs/vmcoreinfo.html
[3] https://github.com/virtio-win/kvm-guest-drivers-windows/blob/d92b9c073ec1108f51846d0bd109c5796b46fd36/fwcfg/qemufwcfg.inf

Thanks for the pointers. _STA 0x0B only clears the "show in UI" bit, so the device is still enumerated: anyone who wants qemufwcfg.inf (or fwcfg64, if bhyve ever grows VMCoreInfo) can still install it, and it shows up under "Show hidden devices". It just no longer appears as an unknown device by default, which is what QEMU does too.