From: Janne Grunau <j@jannau.net>
To: iommu@lists.linux-foundation.org
Cc: devicetree@vger.kernel.org, Robin Murphy <robin.murphy@arm.com>,
Hector Martin <marcan@marcan.st>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Will Deacon <will@kernel.org>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: [PATCH v2 2/4] iommu/io-pgtable: Add DART subpage protection support
Date: Tue, 3 May 2022 08:22:59 +0200 [thread overview]
Message-ID: <20220503062301.20872-3-j@jannau.net> (raw)
In-Reply-To: <20220503062301.20872-1-j@jannau.net>
From: Sven Peter <sven@svenpeter.dev>
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 <sven@svenpeter.dev>
---
drivers/iommu/io-pgtable-arm.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 94ff319ae8ac..71570bbc9096 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -10,6 +10,7 @@
#define pr_fmt(fmt) "arm-lpae io-pgtable: " fmt
#include <linux/atomic.h>
+#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/io-pgtable.h>
#include <linux/kernel.h>
@@ -133,6 +134,9 @@
#define APPLE_DART_PTE_PROT_NO_WRITE (1<<7)
#define APPLE_DART_PTE_PROT_NO_READ (1<<8)
+#define APPLE_DART_PTE_SUBPAGE_START GENMASK_ULL(63, 52)
+#define APPLE_DART_PTE_SUBPAGE_END GENMASK_ULL(51, 40)
+
/* IOPTE accessors */
#define iopte_deref(pte,d) __va(iopte_to_paddr(pte, d))
@@ -273,6 +277,12 @@ static void __arm_lpae_init_pte(struct arm_lpae_io_pgtable *data,
else
pte |= ARM_LPAE_PTE_TYPE_BLOCK;
+ if (data->iop.fmt == APPLE_DART) {
+ /* 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);
+ }
+
for (i = 0; i < num_entries; i++)
ptep[i] = pte | paddr_to_iopte(paddr + i * sz, data);
--
2.35.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-03 6:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-03 6:22 [PATCH v2 0/4] iommu: M1 Pro/Max DART support Janne Grunau
2022-05-03 6:22 ` [PATCH v2 1/4] dt-bindings: iommu: dart: add t6000 compatible Janne Grunau
2022-05-03 6:22 ` Janne Grunau [this message]
2022-05-03 6:23 ` [PATCH v2 3/4] iommu/io-pgtable: Add DART PTE support for t6000 Janne Grunau
2022-05-03 6:23 ` [PATCH v2 4/4] iommu: dart: Support t6000 variant Janne Grunau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220503062301.20872-3-j@jannau.net \
--to=j@jannau.net \
--cc=alyssa@rosenzweig.io \
--cc=devicetree@vger.kernel.org \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=mark.kettenis@xs4all.nl \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox