From patchwork Tue Aug 20 18:09:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 11104465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABBD314DB for ; Tue, 20 Aug 2019 18:11:58 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8789220644 for ; Tue, 20 Aug 2019 18:11:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bcg3fhaI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8789220644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i08aA-00060y-48; Tue, 20 Aug 2019 18:10:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i08a9-00060o-0p for xen-devel@lists.xenproject.org; Tue, 20 Aug 2019 18:10:09 +0000 X-Inumbo-ID: bdc691c0-c375-11e9-9ab1-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bdc691c0-c375-11e9-9ab1-bc764e2007e4; Tue, 20 Aug 2019 18:10:08 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id l1so5979515lji.12 for ; Tue, 20 Aug 2019 11:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=oJraUBmFwkj43+du2EZPgxhK4S7KLGIqOfh5xeLm7Dc=; b=bcg3fhaIl58XOfWZ9T7NBRrH2IGU0YghKlkEd9LZm5h1u8XsY6qbE114JEBcu77Ik/ /C0tvjMBHM5sSmNeKqS5NTK8xgnFuMh6YR+pOTaiYoUUfQXO07iX5FcRG+N9fi7ij33d 4skeRFAv2E0CV9jjx+f+TkPeix/8Itn/O9jNUv+DbRqnX+5dy68EZ+bfIvhL23wAHK6+ FP//rl927S+89AX3S3vi78CfuuSV3WX1nA5vRUuzKScp2zz07fXvMk8FhJBFS4+CO7rN ZLWq8WXDwvsVSQuMQ4FTb75WUez2/HNqCh015HTlT9I6ZjhZayApxlqppxYUT6XSxTft Q74g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oJraUBmFwkj43+du2EZPgxhK4S7KLGIqOfh5xeLm7Dc=; b=bX+/IcfToxI2FtJHRblksN+b6I+Kzc+UY4mcJTdrrljZOrMpb2xMXRjRiw967coai1 rRdr6ix7j6BQ0JzqOxAW5V6Wv6IgEp8TiBVLwyurS9yCCjtJ0sF00zQyRK1iF1AHDieI H14jtQDlHqQQbmArctCN/O+1nW4gzPO+Syp2a3pbI7Afy8t00EfWSYmvYTlCIFx1TMle NDYdO/f4ezT+16QwycHBeKENwoZekWRHikaSv2gsKOPap/meWWeA9PDlV5VmoblyRJE0 6NyAfC7nBEbq5HOliwCt5UfRRO1WsZTh0Sg2WfloUh9M65RMWVDGzxEjWDOIZg8DDjVH Mv5Q== X-Gm-Message-State: APjAAAU8iXnvZbmx54DEDHSrPkC0KZ+01pE7bcm1Q1Zx6IPrEYNYER6L +GCKzBRnWqijP3w9WYXQYOGSnrjh X-Google-Smtp-Source: APXvYqzrQzMfM+1D3FiqlmpXL0krtwjdV+T1UwmP0cf/+nUYllN3rkQ6RL69d7aSx7kgbT1IchNKLQ== X-Received: by 2002:a2e:3109:: with SMTP id x9mr9102289ljx.19.1566324606642; Tue, 20 Aug 2019 11:10:06 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id f6sm2900642lja.16.2019.08.20.11.10.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Aug 2019 11:10:05 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Tue, 20 Aug 2019 21:09:39 +0300 Message-Id: <1566324587-3442-1-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH V3 0/8] iommu/arm: Add Renesas IPMMU-VMSA support + Linux's iommu_fwspec X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org, Volodymyr_Babchuk@epam.com, Yoshihiro Shimoda MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Tyshchenko The purpose of this patch series is to add IPMMU-VMSA support to Xen on ARM. Besides new IOMMU driver, this series contains "iommu_fwspec" support and new API iommu_add_dt_device() for adding DT device to IOMMU and many other things. The IPMMU-VMSA is VMSA-compatible I/O Memory Management Unit (IOMMU) which provides address translation and access protection functionalities to processing units and interconnect networks. Please note, this driver is supposed to work only with newest Gen3 SoCs revisions which IPMMU hardware supports stage 2 translation table format and is able to use CPU's P2M table as is if one is 3-level page table (up to 40 bit IPA). ---------- This driver is based on Linux's IPMMU-VMSA driver from Renesas BSP: https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/tree/drivers/iommu/ipmmu-vmsa.c?h=v4.14.75-ltsi/rcar-3.9.6 and Xen's SMMU driver: xen/drivers/passthrough/arm/smmu.c Although Xen driver has a lot in common with Linux driver, it is not a "direct ported" copy and should be treated as such. The major differences compare to the Linux driver are: 1. Stage 1/Stage 2 translation. Linux driver supports Stage 1 translation only (with Stage 1 translation table format). It manages page table by itself. But Xen driver supports Stage 2 translation (with Stage 2 translation table format) to be able to share the P2M with the CPU. Stage 1 translation is always bypassed in Xen driver. So, Xen driver is supposed to be used with newest Gen3 SoC revisions only (H3 ES3.0, M3-W+, etc.) which IPMMU H/W supports stage 2 translation table format. 2. AArch64 support. Linux driver uses VMSAv8-32 mode, while Xen driver enables Armv8 VMSAv8-64 mode to cover up to 40 bit input address. 3. Context bank (sets of page table) usage. In Xen, each context bank is mapped to one Xen domain. So, all devices being pass throughed to the same Xen domain share the same context bank. 4. IPMMU device tracking. In Xen, all IOMMU devices are managed by single driver instance. So, driver uses global list to keep track of registered IPMMU devices. ---------- Series was tested on Gen3 H3 ES3.0 based boards using current staging (248faa6 xen/arm: add reserved-memory regions to the dom0 memory node) in a system with several DMA masters being assigned to different guest domains. Guest domain reboot, destroy/create are functional. Please note, the series depends on Julien's patch (on review): https://lists.xenproject.org/archives/html/xen-devel/2019-08/msg01924.html You can find the whole series (+ Julien's patch) here: repo: https://github.com/otyshchenko1/xen.git branch: ipmmu_upstream3 You can find previous discussions here: [V1] https://lists.xenproject.org/archives/html/xen-devel/2019-06/msg01755.html [V2] https://lists.xenproject.org/archives/html/xen-devel/2019-08/msg00253.html Oleksandr Tyshchenko (8): iommu/arm: Add iommu_helpers.c file to keep common for IOMMUs stuff iommu/arm: Add ability to handle deferred probing request xen/common: Introduce _xrealloc function xen/common: Introduce xrealloc_flex_struct() helper macros iommu/arm: Add lightweight iommu_fwspec support iommu: Add of_xlate callback iommu/arm: Introduce iommu_add_dt_device API iommu/arm: Add Renesas IPMMU-VMSA support xen/arch/arm/domain_build.c | 11 + xen/arch/arm/platforms/Kconfig | 1 + xen/common/xmalloc_tlsf.c | 45 + xen/drivers/passthrough/Kconfig | 13 + xen/drivers/passthrough/arm/Makefile | 3 +- xen/drivers/passthrough/arm/iommu.c | 114 ++- xen/drivers/passthrough/arm/iommu_fwspec.c | 94 ++ xen/drivers/passthrough/arm/iommu_helpers.c | 84 ++ xen/drivers/passthrough/arm/ipmmu-vmsa.c | 1359 +++++++++++++++++++++++++++ xen/drivers/passthrough/arm/smmu.c | 48 +- xen/include/asm-arm/device.h | 7 +- xen/include/asm-arm/iommu.h | 18 + xen/include/asm-arm/iommu_fwspec.h | 68 ++ xen/include/xen/device_tree.h | 7 + xen/include/xen/iommu.h | 10 + xen/include/xen/xmalloc.h | 13 + 16 files changed, 1843 insertions(+), 52 deletions(-) create mode 100644 xen/drivers/passthrough/arm/iommu_fwspec.c create mode 100644 xen/drivers/passthrough/arm/iommu_helpers.c create mode 100644 xen/drivers/passthrough/arm/ipmmu-vmsa.c create mode 100644 xen/include/asm-arm/iommu_fwspec.h