summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve/pci_passthru.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-03-11 17:36:37 +0000
committerneel <neel@FreeBSD.org>2013-03-11 17:36:37 +0000
commitc92442accdb43d9e4c23e8caf1bc0cd35c7a9409 (patch)
treed90834066b805f4c9590eabada032fdb405e94a6 /usr.sbin/bhyve/pci_passthru.c
parent0b0a5d2fe0a4de3957980af2bef27f9eb6b21768 (diff)
downloadFreeBSD-src-c92442accdb43d9e4c23e8caf1bc0cd35c7a9409.zip
FreeBSD-src-c92442accdb43d9e4c23e8caf1bc0cd35c7a9409.tar.gz
Convert the offset into the bar that contains the MSI-X table to an offset
into the MSI-X table before using it to calculate the table index. In the common case where the MSI-X table is located at the begining of the BAR these two offsets are identical and thus the code was working by accident. This change will fix the case where the MSI-X table is located in the middle or at the end of the BAR that contains it. Obtained from: NetApp
Diffstat (limited to 'usr.sbin/bhyve/pci_passthru.c')
-rw-r--r--usr.sbin/bhyve/pci_passthru.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c
index 08a9a58..43c542d 100644
--- a/usr.sbin/bhyve/pci_passthru.c
+++ b/usr.sbin/bhyve/pci_passthru.c
@@ -279,6 +279,7 @@ msix_table_read(struct passthru_softc *sc, uint64_t offset, int size)
int index;
pi = sc->psc_pi;
+ offset -= pi->pi_msix.table_offset;
index = offset / MSIX_TABLE_ENTRY_SIZE;
if (index >= pi->pi_msix.table_count)
@@ -323,6 +324,8 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc,
int error, index;
pi = sc->psc_pi;
+ offset -= pi->pi_msix.table_offset;
+
index = offset / MSIX_TABLE_ENTRY_SIZE;
if (index >= pi->pi_msix.table_count)
return;
OpenPOWER on IntegriCloud