From patchwork Wed Jun 21 06:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 11080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4189545vqr; Wed, 21 Jun 2023 00:47:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pygLWwffA2TpW0CIu/iyKil17oKnuZBsk1MCyQa4pT03SKeEA5GpfZWnXqPgwuc9VfhT4 X-Received: by 2002:a05:6358:f5e:b0:131:6c5:8b43 with SMTP id c30-20020a0563580f5e00b0013106c58b43mr1840575rwj.11.1687333624959; Wed, 21 Jun 2023 00:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687333624; cv=none; d=google.com; s=arc-20160816; b=d4MATRm0p+hB4PSpvV/yAuCEhjzNEyoIPdj3U9sNJfEImxWdK3JHvQ+pWK1ECTGbPI t07JItap8in9OBsEMJ0VtfSzzPC5UO6yZgaZS7ZD7RxWjm/6i9ztCJ9wkxPW2u4K/eTE hAnOeTh4XUjeNllJA22Kp8L0ahXeylb1IgBlQX3PZC28yIOmBC+YNk1cVrTJOTQ8L9m1 glkK+ouvx/cI0Pw1ePaYZOgI1YX1+jmDn6Yv2aBHPKRABuZX1Tt/SjgQFt33KJu4VbRs Rwl6IKoIRC7Az+XJUZQM4qB+oXh5UZ9mideu7YQZVGd0Gmvfw/lXTZ01C8pJ1Yk5hBU8 1xnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=e5OY6M282TnfWEbYmOhDm1hIj4tFoicvaXmqK7/yzuI=; b=GEESMUp46eiihKh3Ard+mVJC4vdbv1BgbLVCWCunagzAkvwqeR4XtIp4kYW24R7G/t Mh/gvxuHEzev//jQdgKkUEC2kbT+ijJxe1XmIguWfADSEbmyblB7TVMQQE5EO/eQApJh kFZYhM7CRqOuEUwV/IVZHB3piZXTfh3EfGmWzdSCdzNa/JKcHjdmVaxk+U4gtUg4qCK+ fGXachOH8e8MgTJcE623hIJpG+LWqAsse1OaANLBKcBlTr/lNXt3iQEn92QQXqWW++ul jF8qm6L812F9vFTN+/gl9JrrYHzxIkZXxg9a94T3t1X0kzZjaGOoKSPTrbNl0WLegr1H 4FEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hBA3ovpm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i28-20020a633c5c000000b005572aaee70esi1475984pgn.231.2023.06.21.00.46.49; Wed, 21 Jun 2023 00:47:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=hBA3ovpm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbjFUGnd (ORCPT + 99 others); Wed, 21 Jun 2023 02:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbjFUGnS (ORCPT ); Wed, 21 Jun 2023 02:43:18 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B0010DB for ; Tue, 20 Jun 2023 23:43:16 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-561eb6c66f6so63731017b3.0 for ; Tue, 20 Jun 2023 23:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687329795; x=1689921795; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=e5OY6M282TnfWEbYmOhDm1hIj4tFoicvaXmqK7/yzuI=; b=hBA3ovpmEWj7N2Mma7LAPU4gXjRFktu7C2uZyug1Mz+u/bNNdHYT6sdAt6Y3Z7QMkE 1w5uHGLCJXqJRZYOfs5OYL/FEUju9H2aI5Jb6Z9IM7WGjnfTx3Upunbyvz6BSG2aZUj9 ggy5bH2lbm4yiNNIKIBgNqB4eYn9DnXxz8Pwyl70xuAXsGmc2S733pRhf8HUpMHODIgE Ve6rhOdziSoBHZaq5AzXhgmkd1eZ4krWNLyMt1qYBzbDu6rCWrYxiZlYecvnyFG3YCMA A0H4P7tiiob6FohRlPzVmgRLagPxRPDpvbbZ368jkVgaENT6RhRU/R7HNq/cmOQOy/aJ 9acg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687329795; x=1689921795; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=e5OY6M282TnfWEbYmOhDm1hIj4tFoicvaXmqK7/yzuI=; b=Nb8w4wf0LUVOxEsXNhj6OwISKYbe3e0/Ek+w7nR+iVqLk5cqgb1UuIsZFeAeJdUy8P 9x0bMSpX5lrC971Xtpl+K9QeOOejqvjPxVfNIlkX5Bv2hxwdhc+Iw64jfAz9EMmmwco8 jdulalAOSwgKEcA+m0LJ+/g+ZAoBNhbToXqG7tcB4hqoWCceh6+CjVUC/k4ObK/nMuyo 8oFosh22Hk7ODicNZMjuQ9T42pH3DdhBeEFfh03I/A10Kc6NCxs0EPmSulWykQmfbCvC fPfpQEmCMGnx5zaOmdHEcam7S4p2DBryXvBWuDSVdqF6QrbbaL6FKhRPXMJaEXsmYtR2 pKmA== X-Gm-Message-State: AC+VfDzSiO0501/g3ifKp9Fn9Wvh42/+22QH03OPEZOIYA0UqtSH/oso UGZIi/bJhrL3EQLqt+ze9oafWub5bblS X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:384f:f7da:c61d:5a3e]) (user=mshavit job=sendgmr) by 2002:a25:748e:0:b0:bac:fd63:b567 with SMTP id p136-20020a25748e000000b00bacfd63b567mr5996641ybc.4.1687329795401; Tue, 20 Jun 2023 23:43:15 -0700 (PDT) Date: Wed, 21 Jun 2023 14:37:12 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230621063825.268890-1-mshavit@google.com> Subject: [PATCH v4 00/13] 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-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769297543353753047?= X-GMAIL-MSGID: =?utf-8?q?1769297543353753047?= Hi all, This patch series implements the set_dev_pasid operation for DMA and UNMANAGED iommu domains. The bulk of the series involves a refactor of 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. This is a pre-requisite to the set_dev_pasid implementation but also results in a conceptually cleaner arm_smmu_domain. Note that this does not preclude from attaching domains that represent a CD table, such as for the proposed iommufd NESTED domains. The last few patches of the series make drive-by cleanups to the smmu SVA implementation. A follow-up patch-series is planned to further take advantage of these refactorings so that the SVA set_dev_pasid implementation can directly rely on the arm-smmu-v3.c's set_dev_pasid implementation. See discussion on patch 14 of the v2 series. This patch series is also available on gerrit with Jean's SMMU test engine patches cherry-picked 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 v4: * Fix build warning and error on patch 07. The error was introduced during a v1->v2 rebase and hidden by patch 09 which removed the offending line. v3: https://lore.kernel.org/all/20230614154304.2860121-1-mshavit@google.com/ * Dropped the bulk of the SVA refactoring to re-work as a follow-up series. * Reworded cover letter to omit dropped changes. * Rebased on 6.4 tip v2: https://lore.kernel.org/all/20230606120854.4170244-1-mshavit@google.com/ * Reworded cover letter and commits based on v1 feedback. * Split and reworked `iommu/arm-smmu-v3: Move cdtable to arm_smmu_master` * Added SVA clean-up and refactor. * A few other small bug fixes and cosmetics. v1: https://lore.kernel.org/all/20230510205054.2667898-1-mshavit@google.com/ Michael Shavit (13): 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/arm-smmu-v3/arm-smmu-v3-sva.c | 156 +++--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 447 ++++++++++++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 49 +- 3 files changed, 414 insertions(+), 238 deletions(-) base-commit: b6dad5178ceaf23f369c3711062ce1f2afc33644