dm: passthru: enable pba emulation for msix

Normally, for devices support MSI-X, PBA is passed-through to guest.
However, PBA and MSI-X table share the same bar, and part of PBA and
MSI-X table may share a same page for some devices.
If that is the case, the part of PBA within the page should be emulated
rather than passed-through.
This patch adds PBA emulation support for MSI-X.

Tracked-On: #1222
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Binbin Wu 2018-09-30 09:53:47 +08:00 committed by wenlingz
parent 57abc88b15
commit 244bce756b

View File

@ -46,18 +46,6 @@
#include "pci_core.h"
#include "acpi.h"
#ifndef _PATH_DEVPCI
#define _PATH_DEVPCI "/dev/pci"
#endif
#ifndef _PATH_DEVIO
#define _PATH_DEVIO "/dev/io"
#endif
#ifndef _PATH_MEM
#define _PATH_MEM "/dev/mem"
#endif
#ifndef PCI_COMMAND_INTX_DISABLE
#define PCI_COMMAND_INTX_DISABLE ((uint16_t)0x400)
#endif
@ -81,8 +69,8 @@
*/
#define AUDIO_NHLT_HACK 1
/* TODO: Add support for IO BAR of PTDev */
static int iofd = -1;
static int memfd = -1;
/* reference count for libpciaccess init/deinit */
static int pciaccess_ref_cnt;
@ -662,14 +650,14 @@ init_msix_table(struct vmctx *ctx, struct passthru_dev *ptdev, uint64_t base)
else
dev->msix.pba_page_offset = table_offset +
table_size - 4096;
dev->msix.pba_page = mmap(NULL, 4096, PROT_READ |
PROT_WRITE, MAP_SHARED, memfd, start +
dev->msix.pba_page_offset);
if (dev->msix.pba_page == MAP_FAILED) {
warn(
"Failed to map PBA page for MSI-X on %x/%x/%x",
b, s, f);
return -1;
error = pci_device_map_range(ptdev->phys_dev,
base + dev->msix.pba_page_offset, 4096,
PCI_DEV_MAP_FLAG_WRITABLE, &dev->msix.pba_page);
if (error) {
warnx(
"Failed to map PBA page for MSI-X on %x/%x/%x.",
b, s, f);
return error;
}
}
}