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: 13286734 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 E0D5DEB64D8 for ; Wed, 21 Jun 2023 06:43:41 +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=Qn5fFER/qpzO1dhJBnpavtfjPtsTfm6gv830zBJB+9I=; b=2GS 7cDkqH+Ssj3EQghRJToxdbVsAW67CCSmASl5uEFKKu9qhoM2jWndji3CXm/wQ8e9jagOvMvuFc595 MM+zwCv6q8eJR0Uycsrr+DJxVQSQrelzBePUBcky+bV0UbeM6lErhzDy55RCdUfWpdSndh9nhvmGG pu97FtUMf2P6kVxHHyZ4dcTfDHLsk7wPvAhKxiMBhXqMbdY6mzHxPypyqY/rvpji//GI3vK6F2Z9P 66IqjwDRIDWlZhoasIByow9kpMh4D0oKnpB1AOnYmm2vLOZS2Jur6lZH5oHvHR863+53IahQihVKL 4KKbSFpDIUfdRQbL8jMSfQrW/yjA7Xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBrYm-00DRzC-0c; Wed, 21 Jun 2023 06:43:20 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBrYi-00DRxy-2e for linux-arm-kernel@lists.infradead.org; Wed, 21 Jun 2023 06:43:18 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bd5f9d084c9so6154115276.3 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=j1ua450vEzxXnv/mMwncJYcC1YJlp4LIEX3EXPvLBqGxlhaayzf0gCfNINTndJPSLg JLebcdpTJh+mz2kUyZeXZfwgYGhlutnGjkw6PMP/PGuNHl29raMZYMxAr+Bn+6eAzfFm b3gqQVdxGA1opBN2y94iX2ptrYR+7qqjl5elcACqFOZQPJMy+YXLR5wDn3aMNZe835+U VlSu6jzh4UPaTViyka97JaDIaU5CGpgJ+zlWFbKClqy10a4OSMteZPi3wLqttol5RSZB +ALYuKhLenV0mELLg7whYvt02HjWH5gPrL/2S3gXhK/DoOj3xgFITO7cafN/vnhMTrzH EifA== X-Gm-Message-State: AC+VfDznuwXP9pNAEsXf2044vgM4GkQ4zI+IpiyvMwce9sGrGdcUhpVG 7s97AMx7WJnfVDgvrya7aNOZlH8Jh9dP X-Google-Smtp-Source: ACHHUZ6ljJYeciVzTvS9xoX/3PR67Fy5ykTR3WoOGW9eRFKPwUjz57O17oDvVrhXJl36yuTa6IcVVX4qLFLu 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230620_234316_865983_F753EF85 X-CRM114-Status: GOOD ( 14.07 ) 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. 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