HomeFreeBSD

bhyve: ignore low bits of CFGADR

Description

bhyve: ignore low bits of CFGADR

Bhyve could emulate wrong PCI registers.
In the best case, the guest reads wrong registers and the device driver would
report some errors.
In the worst case, the guest writes to wrong PCI registers and could brick
hardware when using PCI passthrough.

According to Intels specification, low bits of CFGADR should be
ignored. Some OS like linux may rely on it. Otherwise, bhyve could
emulate a wrong PCI register.

E.g.
If linux would like to read 2 bytes from offset 0x02, following would
happen.
linux:
outl 0x80000002 at CFGADR
inw at CFGDAT + 2
bhyve:
cfgoff = 0x80000002 & 0xFF = 0x02
coff = cfgoff + (port - CFGDAT) = 0x02 + 0x02 = 0x04
Bhyve would emulate the register at offset 0x04 not 0x02.

Reviewed By: bhyve, grehan
Differential Revision: https://reviews.freebsd.org/D31819
Sponsored by: Beckhoff Automation GmbH & Co. KG

Details

Provenance
c.koehne_beckhoff.comAuthored on Oct 15 2021, 7:25 AM
manuCommitted on Oct 15 2021, 7:29 AM
Reviewer
bhyve
Differential Revision
D31819: bhyve: ignore low bits of CFGADR
Parents
R10:6495766acfb2: nfscl: Restructure nfscl_freeopen() slightly
Branches
Unknown
Tags
Unknown