[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 10/18] intel_iommu: Add support for PCI MSI r
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [PATCH v5 10/18] intel_iommu: Add support for PCI MSI remap |
Date: |
Thu, 28 Apr 2016 16:06:15 +0800 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Thu, Apr 28, 2016 at 09:32:17AM +0200, Jan Kiszka wrote:
> On 2016-04-28 09:05, Peter Xu wrote:
> > This patch enables interrupt remapping for PCI devices.
> >
> > To play the trick, one memory region "iommu_ir" is added as child region
> > of the original iommu memory region, covering range 0xfeeXXXXX (which is
> > the address range for APIC). All the writes to this range will be taken
> > as MSI, and translation is carried out only when IR is enabled.
> >
> > Idea suggested by Paolo Bonzini.
>
> This still lacks source (device ID) identification, right? Were did the
> memory write attribute thing go? Given that you actually introduce a
> separate MSI target address space for the IOAPIC (btw, once there will
> be more than one instance, like on real hw today) and that you will need
> yet another one for each HPET, why not address this with a common scheme
> now, ie. by transmitting the source ID along the write via that attribute?
Yes, it still lacks verification for SID. Currently there are two
ways to implement it. One is to use MemAttrs and provide
write_with_attrs() rather than write(). The other one is to keep
using write(), but instead passing in VTDAddressSpace rather than
IntelIOMMUState when init each IR memory region:
-----------------
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 7122e5b..6493093 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2205,6 +2205,9 @@ static void vtd_mem_ir_write(void *opaque, hwaddr addr,
int ret = 0;
MSIMessage from = {0}, to = {0};
+ VTDAddressSpace *as = opaque;
+ /* Do whatever we want using as->bus and as->devfn... */
+
from.address = (uint64_t) addr + VTD_INTERRUPT_ADDR_FIRST;
from.data = (uint32_t) value;
@@ -2276,7 +2279,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s,
PCIBus *bus, int devfn)
memory_region_init_iommu(&vtd_dev_as->iommu, OBJECT(s),
&s->iommu_ops, "intel_iommu", UINT64_MAX);
memory_region_init_io(&vtd_dev_as->iommu_ir, OBJECT(s),
- &vtd_mem_ir_ops, s, "intel_iommu_ir",
+ &vtd_mem_ir_ops, vtd_dev_as, "intel_iommu_ir",
VTD_INTERRUPT_ADDR_SIZE);
memory_region_add_subregion(&vtd_dev_as->iommu,
VTD_INTERRUPT_ADDR_FIRST,
&vtd_dev_as->iommu_ir);
-----------------
If to use the above method, we'll need no scheme change. But now
since MemAttrs is ready (it's ready, right?), maybe I should start
to use it, which is the standard way to do.
Thanks to point out. Will make the change in v6.
-- peterx
- [Qemu-devel] [PATCH v5 02/18] intel_iommu: allow queued invalidation for IR, (continued)
- [Qemu-devel] [PATCH v5 02/18] intel_iommu: allow queued invalidation for IR, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 03/18] intel_iommu: set IR bit for ECAP register, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 04/18] acpi: add DMAR scope definition for root IOAPIC, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 05/18] intel_iommu: define interrupt remap table addr register, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 06/18] intel_iommu: handle interrupt remap enable, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 08/18] intel_iommu: provide helper function vtd_get_iommu, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 07/18] intel_iommu: define several structs for IOMMU IR, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 09/18] intel_iommu: add IR translation faults defines, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 10/18] intel_iommu: Add support for PCI MSI remap, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 11/18] q35: ioapic: add support for emulated IOAPIC IR, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 13/18] intel_iommu: add support for split irqchip, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 12/18] ioapic: introduce ioapic_entry_parse() helper, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 14/18] q35: add "intremap" parameter to enable IR, Peter Xu, 2016/04/28
- [Qemu-devel] [PATCH v5 15/18] intel_iommu: introduce IEC notifiers, Peter Xu, 2016/04/28