xen/arm: fix SBDF calculation for vPCI MMIO handlers
authorOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Tue, 2 Nov 2021 11:20:41 +0000 (13:20 +0200)
committerJulien Grall <jgrall@amazon.com>
Wed, 3 Nov 2021 18:15:21 +0000 (18:15 +0000)
commit3231ddf9dc384a386df43fd1c0a0bcbba9d79569
tree7225e15d59c8bbf5825d0f4f335ece1857190ce7
parentf6507f1a11cb91f527c7ffdffb8e35289a58d0f5
xen/arm: fix SBDF calculation for vPCI MMIO handlers

While in vPCI MMIO trap handlers for the guest PCI host bridge it is not
enough for SBDF translation to simply call VPCI_ECAM_BDF(info->gpa) as
the base address may not be aligned in the way that the translation
always work. If not adjusted with respect to the base address it may not be
able to properly convert SBDF.
Fix this by adjusting the gpa with respect to the host bridge base address
in a way as it is done for x86.

Please note, that this change is not strictly required given the current
value of GUEST_VPCI_ECAM_BASE which has bits 0 to 27 clear, but could cause
issues if such value is changed, or when handlers for dom0 ECAM
regions are added as those will be mapped over existing hardware
regions that could use non-aligned base addresses.

Fixes: d59168dc05a5 ("xen/arm: Enable the existing x86 virtual PCI support for ARM")
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/arm/vpci.c