From 4ade4473aea9b70e15280717e60cef83d04ad8d6 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Mon, 21 Sep 2020 17:01:24 +0800 Subject: [PATCH] hv: bugfix in function 'write_vmsix_cap_reg()' - Fix bug when setting input 'offset' before calling 'pci_vdev_read_cfg()' and 'pci_pdev_write_cfg()' Tracked-On: #5407 Signed-off-by: Yonghua Huang Reviewed-by: Li, Fei Reviewed-by: Wang, Yu1 Acked-by: Eddie Dong --- hypervisor/dm/vpci/vmsix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypervisor/dm/vpci/vmsix.c b/hypervisor/dm/vpci/vmsix.c index 156abbc7f..3d4858d97 100644 --- a/hypervisor/dm/vpci/vmsix.c +++ b/hypervisor/dm/vpci/vmsix.c @@ -136,7 +136,7 @@ void write_vmsix_cap_reg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, (void)memcpy_s((void *)&ro_mask, bytes, (void *)&msix_ro_mask[offset - vdev->msix.capoff], bytes); if (ro_mask != ~0U) { - old = pci_vdev_read_vcfg(vdev, vdev->msix.capoff, bytes); + old = pci_vdev_read_vcfg(vdev, offset, bytes); pci_vdev_write_vcfg(vdev, offset, bytes, (old & ro_mask) | (val & ~ro_mask)); msgctrl = pci_vdev_read_vcfg(vdev, vdev->msix.capoff + PCIR_MSIX_CTRL, 2U); @@ -144,7 +144,7 @@ void write_vmsix_cap_reg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, if ((msgctrl & PCIM_MSIXCTRL_MSIX_ENABLE) != 0U) { enable_disable_pci_intx(vdev->pdev->bdf, false); } - pci_pdev_write_cfg(vdev->pdev->bdf, offset, 2U, msgctrl); + pci_pdev_write_cfg(vdev->pdev->bdf, vdev->msix.capoff + PCIR_MSIX_CTRL, 2U, msgctrl); } }