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
This commit is contained in:
Neel Natu 2013-03-11 17:36:37 +00:00
parent 5fd81be1fc
commit 4b5e84f615
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=248171

View file

@ -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;