From ffd13a2fe14eb01c10186eda5a638bb44f8b2306 Mon Sep 17 00:00:00 2001 From: liujunming Date: Thu, 18 Mar 2021 20:46:20 +0800 Subject: [PATCH] hv: vpci: fix msi enable issue under some cases In VT-d scenario, if MSI interrupt has been enabled, vCPU writes the content in MSI registers, and all bits of the content are read-only. In this case, hypervisor code will call enable_disable_msi(vdev, false), which will disable MSI. And there's no chance to call remap_vmsi. This is wrong behavior, which will result in the disable of MSI. Tracked-On: #5847 Reviewed-by: Li Fei1 Signed-off-by: liujunming --- hypervisor/dm/vpci/vmsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypervisor/dm/vpci/vmsi.c b/hypervisor/dm/vpci/vmsi.c index cd8c3fa10..a6e878e81 100644 --- a/hypervisor/dm/vpci/vmsi.c +++ b/hypervisor/dm/vpci/vmsi.c @@ -107,10 +107,10 @@ void write_vmsi_cap_reg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, static const uint8_t msi_ro_mask[0xEU] = { 0xffU, 0xffU, 0x8eU, 0xffU }; uint32_t msgctrl, old, ro_mask = ~0U; - enable_disable_msi(vdev, false); - (void)memcpy_s((void *)&ro_mask, bytes, (void *)&msi_ro_mask[offset - vdev->msi.capoff], bytes); if (ro_mask != ~0U) { + enable_disable_msi(vdev, false); + old = pci_vdev_read_vcfg(vdev, offset, bytes); pci_vdev_write_vcfg(vdev, offset, bytes, (old & ro_mask) | (val & ~ro_mask));