All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] VFIO update 2021-07-13 (for v6.1)
@ 2021-07-13 21:29 Alex Williamson
  2021-07-13 21:29 ` [PULL 1/3] vfio: Fix CID 1458134 in vfio_register_ram_discard_listener() Alex Williamson
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Alex Williamson @ 2021-07-13 21:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pankaj Gupta, Eduardo Habkost, Michael S. Tsirkin,
	David Hildenbrand, Pankaj Gupta, Peter Xu,
	Dr. David Alan Gilbert, Auger Eric, alex.williamson, Cai Huoqing,
	teawater, Paolo Bonzini, Igor Mammedov, Marek Kedzierski,
	Wei Yang

The following changes since commit 961fef0ace0b2a997544deec2f01981b9c9c96e3:

  Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20210712' into staging (2021-07-13 17:51:50 +0100)

are available in the Git repository at:

  git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20210713.0

for you to fetch changes up to fefc1861d4ba8b9b4d7153dc6b359a65468d15cb:

  vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor (2021-07-13 11:31:14 -0600)

----------------------------------------------------------------
VFIO update 2021-07-13

 * Coverity fix to discard listener (David Hildenbrand)

 * MSI-X PBA quirk for BAIDU VFs, additional helper use cases (Cai Huoqing)

----------------------------------------------------------------
Cai Huoqing (2):
      vfio/pci: Change to use vfio_pci_is()
      vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor

David Hildenbrand (1):
      vfio: Fix CID 1458134 in vfio_register_ram_discard_listener()

 hw/vfio/common.c         |  3 ++-
 hw/vfio/pci.c            | 12 ++++++++++--
 include/hw/pci/pci_ids.h |  3 +++
 3 files changed, 15 insertions(+), 3 deletions(-)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PULL 1/3] vfio: Fix CID 1458134 in vfio_register_ram_discard_listener()
  2021-07-13 21:29 [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Alex Williamson
@ 2021-07-13 21:29 ` Alex Williamson
  2021-07-13 21:29 ` [PULL 2/3] vfio/pci: Change to use vfio_pci_is() Alex Williamson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2021-07-13 21:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pankaj Gupta, Eduardo Habkost, Michael S. Tsirkin,
	David Hildenbrand, Dr. David Alan Gilbert, Peter Xu,
	Pankaj Gupta, Auger Eric, alex.williamson, teawater,
	Igor Mammedov, Paolo Bonzini, Marek Kedzierski, Wei Yang

From: David Hildenbrand <david@redhat.com>

  CID 1458134:  Integer handling issues  (BAD_SHIFT)
    In expression "1 << ctz64(container->pgsizes)", left shifting by more
    than 31 bits has undefined behavior.  The shift amount,
    "ctz64(container->pgsizes)", is 64.

Commit 5e3b981c330c ("vfio: Support for RamDiscardManager in the !vIOMMU
case") added an assertion that our granularity is at least as big as the
page size.

Although unlikely, we could have a page size that does not fit into
32 bit. In that case, we'd try shifting by more than 31 bit.

Let's use 1ULL instead and make sure we're not shifting by more than 63
bit by asserting that any bit in container->pgsizes is set.

Fixes: CID 1458134
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Auger Eric <eric.auger@redhat.com>
Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
Cc: teawater <teawaterz@linux.alibaba.com>
Cc: Marek Kedzierski <mkedzier@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com>
Link: https://lore.kernel.org/r/20210712083135.15755-1-david@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/vfio/common.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 3f0d11136081..8728d4d5c2e2 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -783,7 +783,8 @@ static void vfio_register_ram_discard_listener(VFIOContainer *container,
                                                                 section->mr);
 
     g_assert(vrdl->granularity && is_power_of_2(vrdl->granularity));
-    g_assert(vrdl->granularity >= 1 << ctz64(container->pgsizes));
+    g_assert(container->pgsizes &&
+             vrdl->granularity >= 1ULL << ctz64(container->pgsizes));
 
     ram_discard_listener_init(&vrdl->listener,
                               vfio_ram_discard_notify_populate,




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL 2/3] vfio/pci: Change to use vfio_pci_is()
  2021-07-13 21:29 [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Alex Williamson
  2021-07-13 21:29 ` [PULL 1/3] vfio: Fix CID 1458134 in vfio_register_ram_discard_listener() Alex Williamson
@ 2021-07-13 21:29 ` Alex Williamson
  2021-07-13 21:30 ` [PULL 3/3] vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor Alex Williamson
  2021-07-14 19:45 ` [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2021-07-13 21:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.williamson, Cai Huoqing

From: Cai Huoqing <caihuoqing@baidu.com>

Make use of vfio_pci_is() helper function.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210713014831.742-1-caihuoqing@baidu.com
[aw: commit log wording]
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/vfio/pci.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index ab4077aad23e..971273fd458b 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3058,14 +3058,14 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
         }
     }
 
-    if (vdev->vendor_id == PCI_VENDOR_ID_NVIDIA) {
+    if (vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID)) {
         ret = vfio_pci_nvidia_v100_ram_init(vdev, errp);
         if (ret && ret != -ENODEV) {
             error_report("Failed to setup NVIDIA V100 GPU RAM");
         }
     }
 
-    if (vdev->vendor_id == PCI_VENDOR_ID_IBM) {
+    if (vfio_pci_is(vdev, PCI_VENDOR_ID_IBM, PCI_ANY_ID)) {
         ret = vfio_pci_nvlink2_init(vdev, errp);
         if (ret && ret != -ENODEV) {
             error_report("Failed to setup NVlink2 bridge");




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL 3/3] vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor
  2021-07-13 21:29 [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Alex Williamson
  2021-07-13 21:29 ` [PULL 1/3] vfio: Fix CID 1458134 in vfio_register_ram_discard_listener() Alex Williamson
  2021-07-13 21:29 ` [PULL 2/3] vfio/pci: Change to use vfio_pci_is() Alex Williamson
@ 2021-07-13 21:30 ` Alex Williamson
  2021-07-14 19:45 ` [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2021-07-13 21:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.williamson, Cai Huoqing

From: Cai Huoqing <caihuoqing@baidu.com>

Fix pba_offset initialization value for BAIDU KUNLUN Virtual
Function device. The KUNLUN hardware returns an incorrect
value for the VF PBA offset, and add a quirk to instead
return a hardcoded value of 0xb400.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210713093743.942-1-caihuoqing@baidu.com
[aw: comment & whitespace tuning]
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/vfio/pci.c            |    8 ++++++++
 include/hw/pci/pci_ids.h |    3 +++
 2 files changed, 11 insertions(+)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 971273fd458b..e1ea1d8a23b5 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1499,6 +1499,14 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
         if (vdev->vendor_id == PCI_VENDOR_ID_CHELSIO &&
             (vdev->device_id & 0xff00) == 0x5800) {
             msix->pba_offset = 0x1000;
+        /*
+         * BAIDU KUNLUN Virtual Function devices for KUNLUN AI processor
+         * return an incorrect value of 0x460000 for the VF PBA offset while
+         * the BAR itself is only 0x10000.  The correct value is 0xb400.
+         */
+        } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
+                               PCI_DEVICE_ID_KUNLUN_VF)) {
+            msix->pba_offset = 0xb400;
         } else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
             error_setg(errp, "hardware reports invalid configuration, "
                        "MSIX PBA outside of specified BAR");
diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h
index 5c14681b82eb..11abe22d4604 100644
--- a/include/hw/pci/pci_ids.h
+++ b/include/hw/pci/pci_ids.h
@@ -227,6 +227,9 @@
 #define PCI_VENDOR_ID_FREESCALE          0x1957
 #define PCI_DEVICE_ID_MPC8533E           0x0030
 
+#define PCI_VENDOR_ID_BAIDU              0x1d22
+#define PCI_DEVICE_ID_KUNLUN_VF          0x3685
+
 #define PCI_VENDOR_ID_INTEL              0x8086
 #define PCI_DEVICE_ID_INTEL_82378        0x0484
 #define PCI_DEVICE_ID_INTEL_82441        0x1237




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PULL 0/3] VFIO update 2021-07-13 (for v6.1)
  2021-07-13 21:29 [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Alex Williamson
                   ` (2 preceding siblings ...)
  2021-07-13 21:30 ` [PULL 3/3] vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor Alex Williamson
@ 2021-07-14 19:45 ` Peter Maydell
  2021-07-14 20:37   ` Alex Williamson
  3 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2021-07-14 19:45 UTC (permalink / raw)
  To: Alex Williamson
  Cc: Pankaj Gupta, Eduardo Habkost, Michael S. Tsirkin,
	David Hildenbrand, QEMU Developers, Peter Xu, Pankaj Gupta,
	Auger Eric, Cai Huoqing, teawater, Igor Mammedov, Paolo Bonzini,
	Marek Kedzierski, Dr. David Alan Gilbert, Wei Yang

On Tue, 13 Jul 2021 at 22:42, Alex Williamson
<alex.williamson@redhat.com> wrote:
>
> The following changes since commit 961fef0ace0b2a997544deec2f01981b9c9c96e3:
>
>   Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20210712' into staging (2021-07-13 17:51:50 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20210713.0
>
> for you to fetch changes up to fefc1861d4ba8b9b4d7153dc6b359a65468d15cb:
>
>   vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor (2021-07-13 11:31:14 -0600)
>
> ----------------------------------------------------------------
> VFIO update 2021-07-13
>
>  * Coverity fix to discard listener (David Hildenbrand)
>
>  * MSI-X PBA quirk for BAIDU VFs, additional helper use cases (Cai Huoqing)
>
> ----------------------------------------------------------------
> Cai Huoqing (2):
>       vfio/pci: Change to use vfio_pci_is()
>       vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor
>
> David Hildenbrand (1):
>       vfio: Fix CID 1458134 in vfio_register_ram_discard_listener()
>
>  hw/vfio/common.c         |  3 ++-
>  hw/vfio/pci.c            | 12 ++++++++++--
>  include/hw/pci/pci_ids.h |  3 +++
>  3 files changed, 15 insertions(+), 3 deletions(-)

Something seems to have gone wrong with your pullrequest. Specifically,
it appears to be based on commit 961fef0ace0b2a997 "Merge remote-tracking
branch 'remotes/alistair/tags/pull-riscv-to-apply-20210712' into staging",
which is not a commit that has ever been in master and indeed does not
compile on all systems. (This is lucky, because if it had compiled
I might not have noticed the mistake...)

Pull requests should always be based only on commits in master.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PULL 0/3] VFIO update 2021-07-13 (for v6.1)
  2021-07-14 19:45 ` [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Peter Maydell
@ 2021-07-14 20:37   ` Alex Williamson
  0 siblings, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2021-07-14 20:37 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Pankaj Gupta, Eduardo Habkost, Michael S. Tsirkin,
	David Hildenbrand, QEMU Developers, Peter Xu, Pankaj Gupta,
	Auger Eric, Cai Huoqing, teawater, Igor Mammedov, Paolo Bonzini,
	Marek Kedzierski, Dr. David Alan Gilbert, Wei Yang

On Wed, 14 Jul 2021 20:45:40 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:

> On Tue, 13 Jul 2021 at 22:42, Alex Williamson
> <alex.williamson@redhat.com> wrote:
> >
> > The following changes since commit 961fef0ace0b2a997544deec2f01981b9c9c96e3:
> >
> >   Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20210712' into staging (2021-07-13 17:51:50 +0100)
> >
...
> 
> Something seems to have gone wrong with your pullrequest. Specifically,
> it appears to be based on commit 961fef0ace0b2a997 "Merge remote-tracking
> branch 'remotes/alistair/tags/pull-riscv-to-apply-20210712' into staging",
> which is not a commit that has ever been in master and indeed does not
> compile on all systems. (This is lucky, because if it had compiled
> I might not have noticed the mistake...)
> 
> Pull requests should always be based only on commits in master.

Sorry about that, Peter.  I'm glad you caught it.  I'll respin against
current master.  Thanks,

Alex



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-14 20:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 21:29 [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Alex Williamson
2021-07-13 21:29 ` [PULL 1/3] vfio: Fix CID 1458134 in vfio_register_ram_discard_listener() Alex Williamson
2021-07-13 21:29 ` [PULL 2/3] vfio/pci: Change to use vfio_pci_is() Alex Williamson
2021-07-13 21:30 ` [PULL 3/3] vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor Alex Williamson
2021-07-14 19:45 ` [PULL 0/3] VFIO update 2021-07-13 (for v6.1) Peter Maydell
2021-07-14 20:37   ` Alex Williamson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.