]> xenbits.xensource.com Git - xen.git/commit
xen/pci: detect when BARs are not suitably positioned
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 3 Feb 2022 12:13:19 +0000 (13:13 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 3 Feb 2022 12:13:19 +0000 (13:13 +0100)
commit75cc460a1b8cfd8e5d2c4302234ee194defe4872
tree5dbc36cbc4de4b0928486e0bab11a7315c740f0d
parentd055114f6db3e4bd57b6d832a03445f0f9c598bc
xen/pci: detect when BARs are not suitably positioned

One of the boxes where I was attempting to boot Xen in PVH dom0 mode
has quirky firmware, as it will handover with a PCI device with memory
decoding enabled and a BAR of size 4K at address 0. Such BAR overlaps
with a RAM range on the e820.

This interacts badly with the dom0 PVH build, as BARs will be setup on
the p2m before RAM, so if there's a BAR positioned over a RAM region
it will trigger a domain crash when the dom0 builder attempts to
populate that region with a regular RAM page.

It's in general a very bad idea to have a BAR overlapping with any
memory region defined in the memory map, so add some sanity checks for
devices that are added with memory decoding enabled in order to assure
that BARs are not placed on top of memory regions defined in the
memory map. If overlaps are detected just disable the memory decoding
bit for the device and expect the hardware domain to properly position
the BAR.

Note apply_quirks must be called before check_pdev so that ignore_bars
is set when calling the later. PCI_HEADER_{NORMAL,BRIDGE}_NR_BARS
needs to be moved into pci_regs.h so it's defined even in the absence
of vPCI.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm.c
xen/drivers/passthrough/pci.c
xen/include/xen/mm.h
xen/include/xen/pci_regs.h
xen/include/xen/vpci.h