Skip to content

Commit 4f20c44

Browse files
binbinwu1lijinxia
authored andcommitted
dm: passthru: fix a bug in msix read/write
In current code, when read/write msix table, it first handle the case the offset is in pba range when msix talbe and pba share the same bar. But the code didn't add the condition whether pba bar equals msix table bar. It will cause problems for the passthrugh devices,whose pba and msix table don't share the same bar. Tracked-On: #1209 Signed-off-by: Binbin Wu <binbin.wu@intel.com> Acked-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 60c05ac commit 4f20c44

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

devicemodel/hw/pci/passthrough.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ msix_table_read(struct passthru_dev *ptdev, uint64_t offset, int size)
462462
int index;
463463

464464
dev = ptdev->dev;
465-
if (offset >= dev->msix.pba_offset &&
465+
if (dev->msix.pba_bar == dev->msix.table_bar &&
466+
offset >= dev->msix.pba_offset &&
466467
offset < dev->msix.pba_offset + dev->msix.pba_size) {
467468
switch (size) {
468469
case 1:
@@ -541,7 +542,8 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_dev *ptdev,
541542
int index;
542543

543544
dev = ptdev->dev;
544-
if (offset >= dev->msix.pba_offset &&
545+
if (dev->msix.pba_bar == dev->msix.table_bar &&
546+
offset >= dev->msix.pba_offset &&
545547
offset < dev->msix.pba_offset + dev->msix.pba_size) {
546548
switch (size) {
547549
case 1:

0 commit comments

Comments
 (0)