xen/pci: Install vpci handlers on x86 and fix error paths
authorBertrand Marquis <bertrand.marquis@arm.com>
Wed, 20 Oct 2021 15:22:52 +0000 (17:22 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 20 Oct 2021 15:22:52 +0000 (17:22 +0200)
commit118da371d1ff5d8432fa299544b1ea5e7e3710f0
tree33c3efa72ca54879d4e15313e98755e912b85858
parentc12731493ae39640c4e44d9fe2029c3165f9f429
xen/pci: Install vpci handlers on x86 and fix error paths

Xen might not be able to discover at boot time all devices or some devices
might appear after specific actions from dom0.
In this case dom0 can use the PHYSDEVOP_pci_device_add to signal some
PCI devices to Xen.
As those devices where not known from Xen before, the vpci handlers must
be properly installed during pci_device_add for x86 PVH Dom0, in the
same way as what is done currently on arm (where Xen does not detect PCI
devices but relies on Dom0 to declare them all the time).

So this patch is removing the ifdef protecting the call to
vpci_add_handlers and the comment which was arm specific.

vpci_add_handlers is called on during pci_device_add which can be called
at runtime through hypercall physdev_op.
Remove __hwdom_init as the call is not limited anymore to hardware
domain init and fix linker script to only keep vpci_array in rodata
section.

Add missing vpci handlers cleanup during pci_device_remove and in case
of error with iommu during pci_device_add.

Move code adding the domain to the pdev domain_list as vpci_add_handlers
needs this to be set and remove it from the list in the error path.

Exit early of vpci_remove_device if the domain has no vpci support.

Add empty static inline for vpci_remove_device when CONFIG_VPCI is not
defined.

Add an ASSERT in vpci_add_handlers to check that the function is not
called twice for the same device.

Fixes: d59168dc05 ("xen/arm: Enable the existing x86 virtual PCI support for ARM")
Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/xen.lds.S
xen/arch/x86/xen.lds.S
xen/drivers/passthrough/pci.c
xen/drivers/vpci/vpci.c
xen/include/xen/vpci.h