xen/pci: reserve MCFG areas earlier
authorIgor Druzhinin <igor.druzhinin@citrix.com>
Thu, 12 Sep 2019 18:31:51 +0000 (19:31 +0100)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Thu, 12 Sep 2019 19:02:55 +0000 (15:02 -0400)
commita4098bc6eed5e31e0391bcc068e61804c98138df
tree6c0914a86c90832ea2c7f944d2c5645e5ffb623e
parente6fa0dc86734f99b037b36b8682133efc2b6e16b
xen/pci: reserve MCFG areas earlier

If MCFG area is not reserved in E820, Xen by default will defer its usage
until Dom0 registers it explicitly after ACPI parser recognizes it as
a reserved resource in DSDT. Having it reserved in E820 is not
mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2)
and firmware is free to keep a hole in E820 in that place. Xen doesn't know
what exactly is inside this hole since it lacks full ACPI view of the
platform therefore it's potentially harmful to access MCFG region
without additional checks as some machines are known to provide
inconsistent information on the size of the region.

Now xen_mcfg_late() runs after acpi_init() which is too late as some basic
PCI enumeration starts exactly there as well. Trying to register a device
prior to MCFG reservation causes multiple problems with PCIe extended
capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are
no convenient hooks for us to subscribe to so register MCFG areas earlier
upon the first invocation of xen_add_device(). It should be safe to do once
since all the boot time buses must have their MCFG areas in MCFG table
already and we don't support PCI bus hot-plug.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
drivers/xen/pci.c