qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] vfio failure with intel 760p 128GB nvme
@ 2018-12-01 18:52 Dongli Zhang
  2018-12-01 19:29 ` Alex Williamson
  0 siblings, 1 reply; 7+ messages in thread
From: Dongli Zhang @ 2018-12-01 18:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: keith.busch, alex.williamson

Hi,

I obtained below error when assigning an intel 760p 128GB nvme to guest via
vfio on my desktop:

qemu-system-x86_64: -device vfio-pci,host=0000:01:00.0: vfio 0000:01:00.0: failed to add PCI capability 0x11[0x50]@0xb0: table & pba overlap, or they don't fit in BARs, or don't align


This is because the msix table is overlapping with pba. According to below
'lspci -vv' from host, the distance between msix table offset and pba offset is
only 0x100, although there are 22 entries supported (22 entries need 0x160).
Looks qemu supports at most 0x800.

# sudo lspci -vv
... ...
01:00.0 Non-Volatile memory controller: Intel Corporation Device f1a6 (rev 03) (prog-if 02 [NVM Express])
	Subsystem: Intel Corporation Device 390b
... ...
	Capabilities: [b0] MSI-X: Enable- Count=22 Masked-
		Vector table: BAR=0 offset=00002000
		PBA: BAR=0 offset=00002100



A patch below could workaround the issue and passthrough nvme successfully.

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 5c7bd96..54fc25e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1510,6 +1510,11 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
     msix->pba_offset = pba & ~PCI_MSIX_FLAGS_BIRMASK;
     msix->entries = (ctrl & PCI_MSIX_FLAGS_QSIZE) + 1;
 
+    if (msix->table_bar == msix->pba_bar &&
+        msix->table_offset + msix->entries * PCI_MSIX_ENTRY_SIZE > msix->pba_offset) {
+        msix->entries = (msix->pba_offset - msix->table_offset) / PCI_MSIX_ENTRY_SIZE;
+    }
+
     /*
      * Test the size of the pba_offset variable and catch if it extends outside
      * of the specified BAR. If it is the case, we need to apply a hardware


Would you please help confirm if this can be regarded as bug in qemu, or issue
with nvme hardware? Should we fix thin in qemu, or we should never use such buggy
hardware with vfio?

Thank you very much!

Dongli Zhang

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

end of thread, other threads:[~2018-12-27 15:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-01 18:52 [Qemu-devel] vfio failure with intel 760p 128GB nvme Dongli Zhang
2018-12-01 19:29 ` Alex Williamson
2018-12-02  1:29   ` Dongli Zhang
2018-12-27 12:30     ` Dongli Zhang
2018-12-27 14:20       ` Alex Williamson
2018-12-27 15:15         ` Dongli Zhang
2018-12-27 12:32     ` Dongli Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).