Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1910688rwn; Fri, 16 Sep 2022 02:46:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4caA2riO4uoAa1//1jniacE1JdTeMcfTh08A9MeYrVTUpF7M0RZfCGRGEFkL0f3JDrj419 X-Received: by 2002:a17:902:f604:b0:172:ffa5:2ed9 with SMTP id n4-20020a170902f60400b00172ffa52ed9mr3850759plg.7.1663321574827; Fri, 16 Sep 2022 02:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663321574; cv=none; d=google.com; s=arc-20160816; b=jg9t52jsywwCfjTE+VZcehGBGeqqISj1VxZ0WA8NUpNGzPgJydEoVAgkINh5Emy1Oy pzfmMXUbjQbd8OG8DA7uqy12ETn9iqhrjD+HMfWJG07m9tvusDDYdt2Hy7o/CbXxrvdD yzUfzmHsn490Laph7F454AK3e9GOccSTmpBYRDgAB5W9NwQ1PdHnkpDlT99ZQkimMNTu C+IadWmDcZNKfmMiqZw0mvOtethGyAjgpR5Y2zKVTE3UC0o0zn9OncBm2WT65WHoWGx0 uNry8WNonBOFEBd3pWNB0inWgrismK8c6QYn2EOQR210ndVkFjaUMh6cSaW1hpkwsDeQ U8vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=U/W2jMdZGU+sMvzhnKYkQ5jL6vEWpK9WYB7rA8M9OKw=; b=Qx1k56gWgjUIuD4KYTeQJElmVb7qOstDfivyolSxilYimqgSppFRFOtcRNYKh06vEn 2sajuvclptpysIQ3VpK3DooUgOZ+yftt9ilF/sBiDAL+X+zN3yxrtcc8h0ARXYfxEQtK sm5Q7HN+ikTunSnjtN+zY/NEBXKf902c5ot2yrrVkJQKrD8o9lLeTsimF8lHzM/6OoA8 mSqdsBeZnSvyNAJfOk6d/kXYKbvVorpZHnU4xqsn/MBbxl2e93Urf/wagLf9uN5JX6lx TXJMb+u5dF7BUEFaPZAmlEruCkWpa4diPmcOGKDTD8Xenb+meKrpTjAdvuvq3ofUkStc 0YFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a056a00130800b0052d4197336fsi21386624pfu.370.2022.09.16.02.46.01; Fri, 16 Sep 2022 02:46:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbiIPJmF (ORCPT + 99 others); Fri, 16 Sep 2022 05:42:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiIPJl5 (ORCPT ); Fri, 16 Sep 2022 05:41:57 -0400 Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA17A6C52 for ; Fri, 16 Sep 2022 02:41:56 -0700 (PDT) Received: from robin.home.jannau.net (unknown [91.200.110.112]) by soltyk.jannau.net (Postfix) with ESMTPSA id 487A326F075; Fri, 16 Sep 2022 11:41:55 +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 v5 3/5] iommu/io-pgtable: Add DART subpage protection support Date: Fri, 16 Sep 2022 11:41:50 +0200 Message-Id: <20220916094152.87137-4-j@jannau.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916094152.87137-1-j@jannau.net> References: <20220916094152.87137-1-j@jannau.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 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-dart.c index 312d40528748..665a52e5c9b0 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 #include +#include #include #include #include @@ -40,6 +41,9 @@ #define DART_PTES_PER_TABLE(d) \ (DART_GRANULE(d) >> ilog2(sizeof(dart_iopte))) +#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) /* Apple DART1 protection bits */ @@ -108,6 +112,10 @@ static int dart_init_pte(struct dart_io_pgtable *data, return -EEXIST; } + /* subpage protection: always allow access to the entire page */ + pte |= FIELD_PREP(APPLE_DART_PTE_SUBPAGE_START, 0); + pte |= FIELD_PREP(APPLE_DART_PTE_SUBPAGE_END, 0xfff); + pte |= APPLE_DART1_PTE_PROT_SP_DIS; pte |= APPLE_DART_PTE_VALID; -- 2.35.1