Skip to content

Commit 5cbe079

Browse files
ZideChen0NanlinXie
authored andcommitted
hv: MSI-X Message Address write fix
Some PCI devices can not accept DWORD write to the MSI-X Table though PCI Spec allows it: PCI Spec 3.0 6.8.3.2 MSI-X Configuration: Specifically, software is always permitted to fill in the Message Address and Message Upper Address fields with a single QWORD write. Tracked-On: #1568 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent dbe156e commit 5cbe079

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

hypervisor/dm/vpci/msix.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static int vmsix_remap_entry(struct pci_vdev *vdev, uint32_t index, bool enable)
4848
{
4949
struct msix_table_entry *pentry;
5050
struct ptdev_msi_info info;
51+
volatile uint32_t *ptr32;
5152
uint64_t hva;
5253
int ret;
5354

@@ -63,7 +64,15 @@ static int vmsix_remap_entry(struct pci_vdev *vdev, uint32_t index, bool enable)
6364
/* Write the table entry to the physical structure */
6465
hva = vdev->msix.mmio_hva + vdev->msix.table_offset;
6566
pentry = (struct msix_table_entry *)hva + index;
66-
pentry->addr = info.pmsi_addr;
67+
68+
/*
69+
* PCI 3.0 Spec allows writing to Message Address and Message Upper Address
70+
* fields with a single QWORD write, but some hardware can accept 32 bits
71+
* write only
72+
*/
73+
ptr32 = (uint32_t *)&pentry->addr;
74+
ptr32[0] = (uint32_t)info.pmsi_addr;
75+
ptr32[1] = (info.pmsi_addr >> 32U);
6776
pentry->data = info.pmsi_data;
6877
pentry->vector_control = vdev->msix.tables[index].vector_control;
6978

0 commit comments

Comments
 (0)