diff mbox series

[v2,kvmtool,12/30] vfio/pci: Don't assume that only even numbered BARs are 64bit

Message ID 20200123134805.1993-13-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series Add reassignable BARs and PCIE 1.1 support | expand

Commit Message

Alexandru Elisei Jan. 23, 2020, 1:47 p.m. UTC
Not all devices have the bottom 32 bits of a 64 bit BAR in an even
numbered BAR. For example, on an NVIDIA Quadro P400, BARs 1 and 3 are
64bit. Remove this assumption.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 vfio/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andre Przywara Jan. 30, 2020, 2:50 p.m. UTC | #1
On Thu, 23 Jan 2020 13:47:47 +0000
Alexandru Elisei <alexandru.elisei@arm.com> wrote:

> Not all devices have the bottom 32 bits of a 64 bit BAR in an even
> numbered BAR. For example, on an NVIDIA Quadro P400, BARs 1 and 3 are
> 64bit. Remove this assumption.
>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  vfio/pci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/vfio/pci.c b/vfio/pci.c
> index bbb8469c8d93..1bdc20038411 100644
> --- a/vfio/pci.c
> +++ b/vfio/pci.c
> @@ -920,8 +920,10 @@ static int vfio_pci_configure_dev_regions(struct kvm *kvm,
>
>  for (i = VFIO_PCI_BAR0_REGION_INDEX; i <= VFIO_PCI_BAR5_REGION_INDEX; ++i) {
>  /* Ignore top half of 64-bit BAR */
> -if (i % 2 && is_64bit)
> +if (is_64bit) {
> +is_64bit = false;
>  continue;
> +}
>
>  ret = vfio_pci_configure_bar(kvm, vdev, i);
>  if (ret)

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
diff mbox series

Patch

diff --git a/vfio/pci.c b/vfio/pci.c
index bbb8469c8d93..1bdc20038411 100644
--- a/vfio/pci.c
+++ b/vfio/pci.c
@@ -920,8 +920,10 @@  static int vfio_pci_configure_dev_regions(struct kvm *kvm,
 
 	for (i = VFIO_PCI_BAR0_REGION_INDEX; i <= VFIO_PCI_BAR5_REGION_INDEX; ++i) {
 		/* Ignore top half of 64-bit BAR */
-		if (i % 2 && is_64bit)
+		if (is_64bit) {
+			is_64bit = false;
 			continue;
+		}
 
 		ret = vfio_pci_configure_bar(kvm, vdev, i);
 		if (ret)