acrn-hypervisor/hypervisor/arch
Alexander Merritt f8f9a2d55e HV: refactor device_to_dmaru
On server platforms, DMAR DRHD device scope entries may contain PCI
bridges.

Bridges in the DRHD device scope indicate this IOMMU translates for all
devices on the hierarchy below that bridge.

ACRN is unaware of bridge types in the device scope, and adds these
directly to its internal representation of a DRHD. When looking up a BDF
within these DRHD entries, device_to_dmaru assumes all entries are
Endpoints, comparing BDF to BDF. Thus device to DMAR unit fails, because
it treats a bridge as an Endpoint type.

This change leverages prior patches by converting a BDF to the
associated device DRHD index, and uses that index to obtain the correct
DRHD state.

Handling a bridge in other ways may require maintaining a bus list for
each, or replacing each bridge in the dev scope with a set of all device
BDFs underneath it. Server platforms can have hundreds of PCI devices,
thus making the device scope artificially large is unwieldy.

v3->v2
        Fixed MISRA-c deviations

v2->v1
	Added code comments for possible reasons why pci_lookup_drhd_for_pbdf
	returns -1U

Tracked-On: #4134
Signed-off-by: Alexander Merritt <alex.merritt@intel.com>
2019-12-10 09:52:17 +08:00
..
x86 HV: refactor device_to_dmaru 2019-12-10 09:52:17 +08:00