Add stream ID to MSI write
PATCH 1/1 Add stream ID to MSI write
GICv3 ITS distinguishes between devices by using hardwired device IDs passed on the bus. This patch implements passing these IDs in qemu.
SMMU is also known to use stream IDs, therefore this addition can also be useful for implementing platforms with SMMU.
Unfortunately currently qemu does not seem to have such thing as bus number, therefore we use only devfn. This is OK for platforms with only one PCI bus instance. Perhaps additional property should be implemented when we emulate some GICv3-based machine with more than one bus.
--- hw/pci/msix.c | 4 +++- include/exec/memattrs.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
hw/pci/msix.c +3 -1
@@ -433,6 +433,7 @@ int msix_enabled(PCIDevice *dev)void msix_notify (PCIDevice *dev,unsigned vector) {MSIMessage msg; +MemTxAttrs attrs = {};if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])return ;
@@ -442,9 +443,10 @@ void msix_notify(PCIDevice *dev, unsigned vector) } msg =msix_get_message (dev, vector); + attrs.stream_id = dev->devfn;/* TODO: Add bus number here */ address_space_stl_le (&dev->bus_master_as, msg.address, msg.data, -MEMTXATTRS_UNSPECIFIED ,NULL ); + attrs,NULL ); }void msix_reset (PCIDevice *dev)
include/exec/memattrs.h +2 -0
@@ -33,6 +33,8 @@ typedef struct MemTxAttrs { unsigned int secure:1;/* Memory access is usermode (unprivileged) */ unsigned int user:1; +/* Stream ID (for MSI for example) */ + unsigned int stream_id:16; } MemTxAttrs;/* Bus masters which don't specify any attributes will get this,
Signature · 1 line
1.9.5.msysgit.0
Quoted 10 lines · Pavel Fedin
GICv3 ITS distinguishes between devices by using hardwired device IDs passed on the bus. This patch implements passing these IDs in qemu.
SMMU is also known to use stream IDs, therefore this addition can also be useful for implementing platforms with SMMU.
Unfortunately currently qemu does not seem to have such thing as bus number, therefore we use only devfn. This is OK for platforms with only one PCI bus instance. Perhaps additional property should be implemented when we emulate some GICv3-based machine with more than one bus.Signed-off-by Pavel Fedin <[email protected]>
There's pci_bus_num.
Quoted 45 lines
--- hw/pci/msix.c | 4 +++- include/exec/memattrs.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)hw/pci/msix.c +3
-1@@ -433,6 +433,7 @@ int msix_enabled(PCIDevice *dev)void msix_notify (PCIDevice *dev,unsigned vector) {MSIMessage msg; +MemTxAttrs attrs = {};if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])return ;@@ -442,9 +443,10 @@ void msix_notify(PCIDevice *dev, unsigned vector) } msg =msix_get_message (dev, vector); + attrs.stream_id = dev->devfn;/* TODO: Add bus number here */ address_space_stl_le (&dev->bus_master_as, msg.address, msg.data, -MEMTXATTRS_UNSPECIFIED ,NULL ); + attrs,NULL ); }void msix_reset (PCIDevice *dev)include/exec/memattrs.h +2
-0@@ -33,6 +33,8 @@ typedef struct MemTxAttrs { unsigned int secure:1;/* Memory access is usermode (unprivileged) */ unsigned int user:1; +/* Stream ID (for MSI for example) */ + unsigned int stream_id:16; } MemTxAttrs;/* Bus masters which don't specify any attributes will get this, Signature · 1 line
1.9.5.msysgit.0