From patchwork Wed Jun 14 15:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 13280152 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 53F38EB64D9 for ; Wed, 14 Jun 2023 15:43:52 +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=ijZz0B+ofjtkSypwm0+lNFDjI9Wzd+xrMaN3YCrIQQk=; b=J+P I9bbui8kV3U/OEBK3aFwcZFHONTAzrdgazSGUPS+Xf+6Mufgmi/VcM2iYN2P9xKD3HQ0AhdEi/+59 8V/BDISKE9fso6Bh8EYd2NUR6xfNjy9ggaz4Y+eMZmLlQdK1d1R3mHNdOFj1zb0PMBYkIEFOuu0j/ /sKRRz0uv5dND+ZBGbiIePP+7fNOn96DLB+/Bk1oooj0YhXH1VqK2N7cpGjaieGFpXjncuGWfSXIx hysm1hN9LTs8cSHA2gO8SpAIYmO0FngVEsXjeRgcI81aZDMhoGX5xaKqrlgav4WfLiTaiCaPjlEtH kSIvS9QUrOJQuYFxIO8WOQZFfXzR4FA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9Sei-00C67u-0r; Wed, 14 Jun 2023 15:43:32 +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 1q9Sef-00C67O-13 for linux-arm-kernel@lists.infradead.org; Wed, 14 Jun 2023 15:43:30 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-561eb6c66f6so11394107b3.0 for ; Wed, 14 Jun 2023 08:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686757407; x=1689349407; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=mAfUZAOawoyT8CZyBzszrXXIQaEA3XJLD6s2UAVMv7M=; b=klcb7noUuAhdnyf4XlxZkBVy6m4Tak9FnBDCYLv6vayg10s9lLLt3qPnVLxLMx4V/h pzPnayfvfuzQEUOB5XX/2G4ghnontqIKTbMe/zek+dZYqjblajQdwzG5A5/4xyYyQv0d uNT6JXsDQ4tSPqvuddMCl0Qt2DTW0J2AIZ9hpB9C/p7k2dqijFS2u2wBiti+po7ZBLXc EUD2/i+KUUbqSkgvN3ngtvMFkwb8ug7x3Ak6EEbKeN8Lm1RGfOZajT7aoy+JasZ6nVLM be92jLBxtpRiPyw9LnERbrec0UvRLfJPdL+sInjK5bYmS+0vcPh/N9mBFQSxzlY0jGVK J6jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686757407; x=1689349407; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mAfUZAOawoyT8CZyBzszrXXIQaEA3XJLD6s2UAVMv7M=; b=WvTckE46FkCVfj/QZRv0ECaUcioB6qdijYCWRj2HzXLeR6+KoVvICjdzKlcA372Mqp Lz4a5GTZDx1m7BcTiVzY7HQEtwy+6z0/Yww7JkhgulfDV+DkzBHDi6obD0+snKE2Xj3b 2k5qLh1y2hEpSAnBhsQ0baXcqDwHETJM5N4ksDzozaWiZs3zPe+QmTgejcA++VHiQ9xc OW9NrY6MnOP4nADyjgSpC00wi/e++uBQRATVvz1ggN34j1d0KMw/2eA5o1YHNn7Sbnfr KeXqEk9XwwIDXBJjia8wh2HlEUaAhq+A4PGbOeClIsEitr9JQnyBlaNq5LBuJNDxXYWz he3w== X-Gm-Message-State: AC+VfDxdTk6mIV0g2HLubkk3Mn+CZQ8cQvXh1sIBayZ1lbcnEflOcDXd LXOpCLuLyGbQirPef1xuasU5Jr93CVkg X-Google-Smtp-Source: ACHHUZ7xIpowVbdQXt1AFVkmjdLe/ViKNLhbx2+GqU5cx7xGsa3h+wqyu0XBexhlSmG0mpwgu06VfPb3ROLc X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:c6e6:49bf:5c44:5965]) (user=mshavit job=sendgmr) by 2002:a81:b64a:0:b0:56c:fffd:49db with SMTP id h10-20020a81b64a000000b0056cfffd49dbmr1019861ywk.7.1686757406946; Wed, 14 Jun 2023 08:43:26 -0700 (PDT) Date: Wed, 14 Jun 2023 23:41:52 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230614154304.2860121-1-mshavit@google.com> Subject: [PATCH v3 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-20230614_084329_383334_149098C7 X-CRM114-Status: GOOD ( 13.42 ) 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 so that the SVA implementation can further take advantages of the changes introduced here. 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 v3: * 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