Page MenuHomeFreeBSD

bhyve: Treat the COMMAND register for PCI passthru devices as emulated
ClosedPublic

Authored by jhb on Jul 29 2024, 8:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 3:13 AM
Unknown Object (File)
Tue, Nov 19, 3:12 AM
Unknown Object (File)
Tue, Nov 19, 3:12 AM
Unknown Object (File)
Tue, Nov 19, 2:52 AM
Unknown Object (File)
Wed, Nov 6, 11:03 PM
Unknown Object (File)
Tue, Nov 5, 1:39 AM
Unknown Object (File)
Mon, Oct 28, 4:56 AM
Unknown Object (File)
Oct 4 2024, 9:47 PM

Details

Summary

Don't pass through writes of the command register through to the
physical device. These registers do not need to be in sync, and in
some cases (e.g. when the guest is sizing the BAR and temporarily
disables decoding), the states need to diverge.

PR: 205549
Sponsored by: Chelsio Communications

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Jul 29 2024, 8:44 PM

Shouldn't we set the command register to a known good value or do we expect that the host always sets a good value? If the host disables mem/io decoding for some reason, we're unable to read any values from the BARs MMIO space.

Shouldn't we set the command register to a known good value or do we expect that the host always sets a good value? If the host disables mem/io decoding for some reason, we're unable to read any values from the BARs MMIO space.

No, this is the responsibility of the host kernel and in particular the ppt(4) driver. For example, when the ppt(4) driver maps the physical BARs via bus_alloc_resource() with RF_ACTIVE, that enables the relevant decoding bits in the command register. Similarly, the host kernel takes clear of setting/clearing INTxDIS as needed when enabling/disabling MSI interrupts. I hadn't really realized this until yesterday, but ppt(4)'s actions as a device driver is what determines the correct values of the physical command register. For example, during guest boot while the guest is messing with the guest BARs to size the BAR, etc. the physical BAR remains unchanged and should remain enabled the entire time.

This revision is now accepted and ready to land.Jul 31 2024, 6:15 AM