From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760018AbdADNdS (ORCPT ); Wed, 4 Jan 2017 08:33:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37248 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757664AbdADNcd (ORCPT ); Wed, 4 Jan 2017 08:32:33 -0500 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, drjones@redhat.com, linux-kernel@vger.kernel.org, pranav.sawargaonkar@gmail.com, iommu@lists.linux-foundation.org, punit.agrawal@arm.com, diana.craciun@nxp.com, gpkulkarni@gmail.com, shankerd@codeaurora.org, bharat.bhushan@nxp.com, geethasowjanya.akula@gmail.com Subject: [PATCH v5 00/17] KVM PCIe/MSI passthrough on ARM/ARM64 and IOVA reserved regions Date: Wed, 4 Jan 2017 13:32:09 +0000 Message-Id: <1483536746-2725-1-git-send-email-eric.auger@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 04 Jan 2017 13:32:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following LPC discussions, we now report reserved regions through iommu-group sysfs reserved_regions attribute file. Reserved regions are populated through the IOMMU get_resv_region callback (former get_dm_regions), now implemented by amd-iommu, intel-iommu and arm-smmu: - the intel-iommu reports the [0xfee00000 - 0xfeefffff] MSI window as an IOMMU_RESV_NOMAP reserved region. - the amd-iommu reports device direct mapped regions, the MSI region and HT regions. - the arm-smmu reports the MSI window (arbitrarily located at 0x8000000 and 1MB large). Unsafe interrupt assignment is tested by enumerating all MSI irq domains and checking MSI remapping is supported in the above hierarchy. This check is done in case we detect the iommu translates MSI (an IOMMU_RESV_MSI window exists). Otherwise the IRQ remapping capability is checked at IOMMU level. Obviously this is a defensive IRQ safety assessment: Assuming there are several MSI controllers in the system and at least one does not implement IRQ remapping, the assignment will be considered as unsafe (even if this controller is not acessible from the assigned devices). The series integrates a not officially posted patch from Robin: "iommu/dma: Allow MSI-only cookies". Best Regards Eric Git: complete series available at https://github.com/eauger/linux/tree/v4.10-rc2-reserved-v5 History: RFCv4 -> PATCHv5 - fix IRQ security assessment by looking at irq domain parents - check DOMAIN_BUS_FSL_MC_MSI irq domains - AMD MSI and HT regions are exposed in iommu group sysfs RFCv3 -> RFCv4: - arm-smmu driver does not register PCI host bridge windows as reserved regions anymore - Implement reserved region get/put callbacks also in arm-smmuv3 - take the iommu_group lock on iommu_get_group_resv_regions - add a type field in iommu_resv_region instead of using prot - init the region list_head in iommu_alloc_resv_region, also add type parameter - iommu_insert_resv_region manage overlaps and sort reserved windows - address IRQ safety assessment by enumerating all the MSI irq domains and checking the MSI_REMAP flag - update Documentation/ABI/testing/sysfs-kernel-iommu_groups RFC v2 -> v3: - switch to an iommu-group sysfs API - use new dummy allocator provided by Robin - dummy allocator initialized by vfio-iommu-type1 after enumerating the reserved regions - at the moment ARM MSI base address/size is left unchanged compared to v2 - we currently report reserved regions and not usable IOVA regions as requested by Alex RFC v1 -> v2: - fix intel_add_reserved_regions - add mutex lock/unlock in vfio_iommu_type1 Eric Auger (17): iommu/dma: Allow MSI-only cookies iommu: Rename iommu_dm_regions into iommu_resv_regions iommu: Add a new type field in iommu_resv_region iommu: iommu_alloc_resv_region iommu: Only map direct mapped regions iommu: iommu_get_group_resv_regions iommu: Implement reserved_regions iommu-group sysfs file iommu/vt-d: Implement reserved region get/put callbacks iommu/amd: Declare MSI and HT regions as reserved IOVA regions iommu/arm-smmu: Implement reserved region get/put callbacks iommu/arm-smmu-v3: Implement reserved region get/put callbacks irqdomain: Add IRQ_DOMAIN_FLAG_MSI_REMAP value irqdomain: irq_domain_check_msi_remap irqchip/gicv3-its: Sets IRQ_DOMAIN_FLAG_MSI_REMAP vfio/type1: Allow transparent MSI IOVA allocation vfio/type1: Check MSI remapping at irq domain level iommu/arm-smmu: Do not advertise IOMMU_CAP_INTR_REMAP anymore drivers/iommu/amd_iommu.c | 54 +++++++++----- drivers/iommu/arm-smmu-v3.c | 30 +++++++- drivers/iommu/arm-smmu.c | 30 +++++++- drivers/iommu/dma-iommu.c | 116 ++++++++++++++++++++++++------ drivers/iommu/intel-iommu.c | 50 +++++++++---- drivers/iommu/iommu.c | 152 ++++++++++++++++++++++++++++++++++++--- drivers/irqchip/irq-gic-v3-its.c | 1 + drivers/vfio/vfio_iommu_type1.c | 34 ++++++++- include/linux/dma-iommu.h | 7 ++ include/linux/iommu.h | 46 ++++++++---- include/linux/irqdomain.h | 4 ++ kernel/irq/irqdomain.c | 41 +++++++++++ 12 files changed, 481 insertions(+), 84 deletions(-) -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Auger Subject: [PATCH v5 00/17] KVM PCIe/MSI passthrough on ARM/ARM64 and IOVA reserved regions Date: Wed, 4 Jan 2017 13:32:09 +0000 Message-ID: <1483536746-2725-1-git-send-email-eric.auger@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: drjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, punit.agrawal-5wv7dgnIgG8@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, geethasowjanya.akula-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, pranav.sawargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, shankerd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org, gpkulkarni-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org To: eric.auger-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, eric.auger.pro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, christoffer.dall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, marc.zyngier-5wv7dgnIgG8@public.gmane.org, robin.murphy-5wv7dgnIgG8@public.gmane.org, alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, will.deacon-5wv7dgnIgG8@public.gmane.org, joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org, tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org, jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: kvm.vger.kernel.org Following LPC discussions, we now report reserved regions through iommu-group sysfs reserved_regions attribute file. Reserved regions are populated through the IOMMU get_resv_region callback (former get_dm_regions), now implemented by amd-iommu, intel-iommu and arm-smmu: - the intel-iommu reports the [0xfee00000 - 0xfeefffff] MSI window as an IOMMU_RESV_NOMAP reserved region. - the amd-iommu reports device direct mapped regions, the MSI region and HT regions. - the arm-smmu reports the MSI window (arbitrarily located at 0x8000000 and 1MB large). Unsafe interrupt assignment is tested by enumerating all MSI irq domains and checking MSI remapping is supported in the above hierarchy. This check is done in case we detect the iommu translates MSI (an IOMMU_RESV_MSI window exists). Otherwise the IRQ remapping capability is checked at IOMMU level. Obviously this is a defensive IRQ safety assessment: Assuming there are several MSI controllers in the system and at least one does not implement IRQ remapping, the assignment will be considered as unsafe (even if this controller is not acessible from the assigned devices). The series integrates a not officially posted patch from Robin: "iommu/dma: Allow MSI-only cookies". Best Regards Eric Git: complete series available at https://github.com/eauger/linux/tree/v4.10-rc2-reserved-v5 History: RFCv4 -> PATCHv5 - fix IRQ security assessment by looking at irq domain parents - check DOMAIN_BUS_FSL_MC_MSI irq domains - AMD MSI and HT regions are exposed in iommu group sysfs RFCv3 -> RFCv4: - arm-smmu driver does not register PCI host bridge windows as reserved regions anymore - Implement reserved region get/put callbacks also in arm-smmuv3 - take the iommu_group lock on iommu_get_group_resv_regions - add a type field in iommu_resv_region instead of using prot - init the region list_head in iommu_alloc_resv_region, also add type parameter - iommu_insert_resv_region manage overlaps and sort reserved windows - address IRQ safety assessment by enumerating all the MSI irq domains and checking the MSI_REMAP flag - update Documentation/ABI/testing/sysfs-kernel-iommu_groups RFC v2 -> v3: - switch to an iommu-group sysfs API - use new dummy allocator provided by Robin - dummy allocator initialized by vfio-iommu-type1 after enumerating the reserved regions - at the moment ARM MSI base address/size is left unchanged compared to v2 - we currently report reserved regions and not usable IOVA regions as requested by Alex RFC v1 -> v2: - fix intel_add_reserved_regions - add mutex lock/unlock in vfio_iommu_type1 Eric Auger (17): iommu/dma: Allow MSI-only cookies iommu: Rename iommu_dm_regions into iommu_resv_regions iommu: Add a new type field in iommu_resv_region iommu: iommu_alloc_resv_region iommu: Only map direct mapped regions iommu: iommu_get_group_resv_regions iommu: Implement reserved_regions iommu-group sysfs file iommu/vt-d: Implement reserved region get/put callbacks iommu/amd: Declare MSI and HT regions as reserved IOVA regions iommu/arm-smmu: Implement reserved region get/put callbacks iommu/arm-smmu-v3: Implement reserved region get/put callbacks irqdomain: Add IRQ_DOMAIN_FLAG_MSI_REMAP value irqdomain: irq_domain_check_msi_remap irqchip/gicv3-its: Sets IRQ_DOMAIN_FLAG_MSI_REMAP vfio/type1: Allow transparent MSI IOVA allocation vfio/type1: Check MSI remapping at irq domain level iommu/arm-smmu: Do not advertise IOMMU_CAP_INTR_REMAP anymore drivers/iommu/amd_iommu.c | 54 +++++++++----- drivers/iommu/arm-smmu-v3.c | 30 +++++++- drivers/iommu/arm-smmu.c | 30 +++++++- drivers/iommu/dma-iommu.c | 116 ++++++++++++++++++++++++------ drivers/iommu/intel-iommu.c | 50 +++++++++---- drivers/iommu/iommu.c | 152 ++++++++++++++++++++++++++++++++++++--- drivers/irqchip/irq-gic-v3-its.c | 1 + drivers/vfio/vfio_iommu_type1.c | 34 ++++++++- include/linux/dma-iommu.h | 7 ++ include/linux/iommu.h | 46 ++++++++---- include/linux/irqdomain.h | 4 ++ kernel/irq/irqdomain.c | 41 +++++++++++ 12 files changed, 481 insertions(+), 84 deletions(-) -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: eric.auger@redhat.com (Eric Auger) Date: Wed, 4 Jan 2017 13:32:09 +0000 Subject: [PATCH v5 00/17] KVM PCIe/MSI passthrough on ARM/ARM64 and IOVA reserved regions Message-ID: <1483536746-2725-1-git-send-email-eric.auger@redhat.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Following LPC discussions, we now report reserved regions through iommu-group sysfs reserved_regions attribute file. Reserved regions are populated through the IOMMU get_resv_region callback (former get_dm_regions), now implemented by amd-iommu, intel-iommu and arm-smmu: - the intel-iommu reports the [0xfee00000 - 0xfeefffff] MSI window as an IOMMU_RESV_NOMAP reserved region. - the amd-iommu reports device direct mapped regions, the MSI region and HT regions. - the arm-smmu reports the MSI window (arbitrarily located at 0x8000000 and 1MB large). Unsafe interrupt assignment is tested by enumerating all MSI irq domains and checking MSI remapping is supported in the above hierarchy. This check is done in case we detect the iommu translates MSI (an IOMMU_RESV_MSI window exists). Otherwise the IRQ remapping capability is checked at IOMMU level. Obviously this is a defensive IRQ safety assessment: Assuming there are several MSI controllers in the system and at least one does not implement IRQ remapping, the assignment will be considered as unsafe (even if this controller is not acessible from the assigned devices). The series integrates a not officially posted patch from Robin: "iommu/dma: Allow MSI-only cookies". Best Regards Eric Git: complete series available at https://github.com/eauger/linux/tree/v4.10-rc2-reserved-v5 History: RFCv4 -> PATCHv5 - fix IRQ security assessment by looking at irq domain parents - check DOMAIN_BUS_FSL_MC_MSI irq domains - AMD MSI and HT regions are exposed in iommu group sysfs RFCv3 -> RFCv4: - arm-smmu driver does not register PCI host bridge windows as reserved regions anymore - Implement reserved region get/put callbacks also in arm-smmuv3 - take the iommu_group lock on iommu_get_group_resv_regions - add a type field in iommu_resv_region instead of using prot - init the region list_head in iommu_alloc_resv_region, also add type parameter - iommu_insert_resv_region manage overlaps and sort reserved windows - address IRQ safety assessment by enumerating all the MSI irq domains and checking the MSI_REMAP flag - update Documentation/ABI/testing/sysfs-kernel-iommu_groups RFC v2 -> v3: - switch to an iommu-group sysfs API - use new dummy allocator provided by Robin - dummy allocator initialized by vfio-iommu-type1 after enumerating the reserved regions - at the moment ARM MSI base address/size is left unchanged compared to v2 - we currently report reserved regions and not usable IOVA regions as requested by Alex RFC v1 -> v2: - fix intel_add_reserved_regions - add mutex lock/unlock in vfio_iommu_type1 Eric Auger (17): iommu/dma: Allow MSI-only cookies iommu: Rename iommu_dm_regions into iommu_resv_regions iommu: Add a new type field in iommu_resv_region iommu: iommu_alloc_resv_region iommu: Only map direct mapped regions iommu: iommu_get_group_resv_regions iommu: Implement reserved_regions iommu-group sysfs file iommu/vt-d: Implement reserved region get/put callbacks iommu/amd: Declare MSI and HT regions as reserved IOVA regions iommu/arm-smmu: Implement reserved region get/put callbacks iommu/arm-smmu-v3: Implement reserved region get/put callbacks irqdomain: Add IRQ_DOMAIN_FLAG_MSI_REMAP value irqdomain: irq_domain_check_msi_remap irqchip/gicv3-its: Sets IRQ_DOMAIN_FLAG_MSI_REMAP vfio/type1: Allow transparent MSI IOVA allocation vfio/type1: Check MSI remapping at irq domain level iommu/arm-smmu: Do not advertise IOMMU_CAP_INTR_REMAP anymore drivers/iommu/amd_iommu.c | 54 +++++++++----- drivers/iommu/arm-smmu-v3.c | 30 +++++++- drivers/iommu/arm-smmu.c | 30 +++++++- drivers/iommu/dma-iommu.c | 116 ++++++++++++++++++++++++------ drivers/iommu/intel-iommu.c | 50 +++++++++---- drivers/iommu/iommu.c | 152 ++++++++++++++++++++++++++++++++++++--- drivers/irqchip/irq-gic-v3-its.c | 1 + drivers/vfio/vfio_iommu_type1.c | 34 ++++++++- include/linux/dma-iommu.h | 7 ++ include/linux/iommu.h | 46 ++++++++---- include/linux/irqdomain.h | 4 ++ kernel/irq/irqdomain.c | 41 +++++++++++ 12 files changed, 481 insertions(+), 84 deletions(-) -- 1.9.1