From patchwork Tue Jun 6 12:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13269046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5FE9C7EE24 for ; Tue, 6 Jun 2023 12:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=N/AKLzQ4luYpea8PmGy9MZskGazRucq1SYbGFo0vNdE=; b=SJ0 48AVJippYeFSp9ZM6Ss2T6dUuiwX4llPuCYDIc0RVaMwKsL+BJui24++Pp7Wdr2+0fKI0MleIum8B ZB/8EdeNDRMIHJ/PEc+PGWQ79rxCGnPTzKba7MlQZf3093j7zGEIi9XbTKOxjgR46i/qZ5eczOOxq Q2qM9Gakd+McY0ZN3aE1jLOp51neP8xU7MeYYsiZ79bLOYhKLGTvDPmm255TclMwxE1HxFUEcLSiK seqtRQLSqNDSiZddUJz59OrSsrM+sauudorcgpZYktMUtmyoAKoglqhgDH8udObTHlgM953DCPUCB c+fkjnMdi5q20Y0rJikaBSGQsLq8oMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6VV7-001YWq-0C; Tue, 06 Jun 2023 12:09:25 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6VV4-001YUM-1s for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 12:09:24 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-56536dd5f79so97902447b3.3 for ; Tue, 06 Jun 2023 05:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686053358; x=1688645358; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=nnyvtjh+kF3RLE+cug+CO0eM4y0oqNNfVmWbOcSnIjQ=; b=utkX65Vz0L6sR2kZ/cV8/Bs95MrkpKlOYv55JrePCNTvQTBAgFotFEAPUv6jg38AXp pPL3iz7Ctht5pHtoRtBxwvw9x2NfbiqVTKpH2ZNeguEbnOsevwaiOBVDfxeOXEONADZ2 DcmayF+B0d7NbXxLFqYu5iprNU0JTO5D03WCzRj83Hzfx3cVFfrlTxjUf7ltPXdwUf7k RyHBqhu2S/M83S/KCELU8K0i9QH1/vAIzQPKdQMc5oOsm5Bn5Y4Z0DaAOpgdKXj/XIux 6eaZI5eRA+8QJuJImLEteMOOIXGGVJz2OAbBfK0GjVcUQQ35CBdkE3LyH0rgUwR31OxJ g/sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686053358; x=1688645358; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nnyvtjh+kF3RLE+cug+CO0eM4y0oqNNfVmWbOcSnIjQ=; b=Kq0+YHo+4obZAK5fmEkLNQOg3iPl7qg6jpz1mpLsY30XILebZeb7Kg2atgp3Eae0Ri vnwkExTvSi2Q8IoCIkl7qZgNfTJ4L7V2/VgASI8VmwfWKahZgoaSZ/3NzG8vJ+8ErswG WXw6zdGVkpfuG2B1FNTJE4cZJk8LQJe7sNbx1iwTmIB+nqDc7Kls5zLjgNbM6J3YeL3R iDI00XiF2mMi8mmjKiHyCkmOwr27elBm21noIyjw3cxltXyo0oTPZ1K0CquIQLwGawVR sepXJAN+b7nADHBelOzQ3BXXTli1KCYXDat1A6cX1aQ2d2Wuc9nKbwHSeEkFpWznb68C 6gPQ== X-Gm-Message-State: AC+VfDzda0jNa0zUjviKu4ZqNcxs1fFeJkNvrU/CsJWucrwqyzSOmY9k +ncQ1gjxWTlzdCCLhkQqDgryZmtOdLvr X-Google-Smtp-Source: ACHHUZ6aSekWgWC0uGTChOHJuA02dRoV0LxXIWREsHrUrDfzJsBIcspGSrMwdLO1U5pFvSvOs25/Qr7k3QY6 X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:a615:63d5:b54e:6919]) (user=mshavit job=sendgmr) by 2002:a5b:5ca:0:b0:b9d:b6cd:2dfd with SMTP id w10-20020a5b05ca000000b00b9db6cd2dfdmr958857ybp.8.1686053358499; Tue, 06 Jun 2023 05:09:18 -0700 (PDT) Date: Tue, 6 Jun 2023 20:07:36 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230606120854.4170244-1-mshavit@google.com> Subject: [PATCH v2 00/18] Add PASID support to SMMUv3 unmanaged domains From: Michael Shavit To: Will Deacon , Robin Murphy , Joerg Roedel Cc: Michael Shavit , jean-philippe@linaro.org, nicolinc@nvidia.com, jgg@nvidia.com, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_050922_616829_3A573DCE X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, This patch series implements the set_dev_pasid operation for DMA and UNMANAGED iommu domains. As a first step, the patch series refactors stage 1 domains so that they describe a single CD entry. On attach, stage 1 domains are inserted into a CD table that is now owned by the arm_smmu_master struct. Note that this does not preclude from attaching domains that represent a CD table, such as for the proposed iommufd NESTED domains. The patch series also heavily refactors the arm-smmu-v3-sva implementation. The first set of clean-up patches were enabled by earlier changes in the iommu pasid framework. Later patches take advantage of the arm-smmu-v3 changes and makes use of its set_dev_pasid implementation. This patch series is also available on gerrit with Jean's SMMU test engine patches rebased on top: https://linux-review.googlesource.com/id/I0fcd9adc058d1c58a12d2599cc82fba73da7697a This allowed testing of basic SVA functionality (e.g.: attaching, page fault handling, and detaching). Thanks, Michael Shavit Changelog v2: * Reworded cover letter and commits based on v1 feedback. * Added SVA clean-up and refactor. * Split and reworked iommu/arm-smmu-v3: Move cdtable to arm_smmu_master * A few other small bug fixes and cosmetics. v1: https://lore.kernel.org/all/20230510205054.2667898-1-mshavit@google.com/ Michael Shavit (18): iommu/arm-smmu-v3: Move ctx_desc out of s1_cfg iommu/arm-smmu-v3: Add smmu_s1_cfg to smmu_master iommu/arm-smmu-v3: Refactor write_strtab_ent iommu/arm-smmu-v3: Refactor write_ctx_desc iommu/arm-smmu-v3: Use the master-owned s1_cfg iommu/arm-smmu-v3: Simplify arm_smmu_enable_ats iommu/arm-smmu-v3: Keep track of attached ssids iommu/arm-smmu-v3: Add helper for atc invalidation iommu/arm-smmu-v3: Implement set_dev_pasid iommu/arm-smmu-v3-sva: Remove bond refcount iommu/arm-smmu-v3-sva: Clean unused iommu_sva iommu/arm-smmu-v3-sva: Remove arm_smmu_bond iommu/arm-smmu-v3-sva: Add check when enabling sva iommu/arm-smmu-v3: Support domains with shared CDs iommu/arm-smmu-v3: Allow more re-use for SVA iommu/arm-smmu-v3-sva: Attach S1_SHARED_CD domain iommu/arm-smmu-v3-sva: Alloc notifier for {smmu,mn} iommu/arm-smmu-v3-sva: Remove atc_inv_domain_ssid .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 164 +++--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 493 ++++++++++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 62 ++- 3 files changed, 457 insertions(+), 262 deletions(-) base-commit: 884fe9da1b7ccbea31b118f902fbc78f58366b4a