From nobody Thu Apr 9 10:54:34 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2509AECAAD1 for ; Thu, 1 Sep 2022 01:33:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232604AbiIABdF (ORCPT ); Wed, 31 Aug 2022 21:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbiIABc4 (ORCPT ); Wed, 31 Aug 2022 21:32:56 -0400 Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F0EB155A6F for ; Wed, 31 Aug 2022 18:32:53 -0700 (PDT) Received: from coburn.home.jannau.net (p54acc2ba.dip0.t-ipconnect.de [84.172.194.186]) by soltyk.jannau.net (Postfix) with ESMTPSA id 1CBC726EF4D; Thu, 1 Sep 2022 03:25:22 +0200 (CEST) From: Janne Grunau To: iommu@lists.linux.dev Cc: Konrad Dybcio , asahi@lists.linux.dev, Sven Peter , Alyssa Rosenzweig , Hector Martin , Joerg Roedel , Will Deacon , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/5] iommu/io-pgtable: Add DART subpage protection support Date: Thu, 1 Sep 2022 03:25:17 +0200 Message-Id: <20220901012519.7167-4-j@jannau.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220901012519.7167-1-j@jannau.net> References: <20220901012519.7167-1-j@jannau.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sven Peter DART allows to only expose a subpage to the device. While this is an optional feature on the M1 DARTs the new ones present on the Pro/Max models require this field in every PTE. Signed-off-by: Sven Peter Signed-off-by: Janne Grunau --- (no changes since v3) Changes in v3: - apply change to io-pgtable-dart.c drivers/iommu/io-pgtable-dart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dar= t.c index 43ef375812e6..659dd9e83d2c 100644 --- a/drivers/iommu/io-pgtable-dart.c +++ b/drivers/iommu/io-pgtable-dart.c @@ -14,6 +14,7 @@ #define pr_fmt(fmt) "dart io-pgtable: " fmt =20 #include +#include #include #include #include @@ -40,6 +41,9 @@ #define DART_PTES_PER_TABLE(d) \ (DART_GRANULE(d) >> ilog2(sizeof(dart_iopte))) =20 +#define APPLE_DART_PTE_SUBPAGE_START GENMASK_ULL(63, 52) +#define APPLE_DART_PTE_SUBPAGE_END GENMASK_ULL(51, 40) + #define APPLE_DART1_PADDR_MASK GENMASK_ULL(35, 12) =20 /* Apple DART1 protection bits */ @@ -109,6 +113,10 @@ static int dart_init_pte(struct dart_io_pgtable *data, return -EEXIST; } =20 + /* subpage protection: always allow access to the entire page */ + pte |=3D FIELD_PREP(APPLE_DART_PTE_SUBPAGE_START, 0); + pte |=3D FIELD_PREP(APPLE_DART_PTE_SUBPAGE_END, 0xfff); + pte |=3D APPLE_DART1_PTE_PROT_SP_DIS; pte |=3D APPLE_DART_PTE_VALID; =20 --=20 2.35.1