Skip to content

Commit d8fe365

Browse files
svenpeter42joergroedel
authored andcommitted
iommu/io-pgtable: Add DART subpage protection support
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> Signed-off-by: Janne Grunau <j@jannau.net> Reviewed-by: Rob Herring <robh@kernel.org> Acked-by: Hector Martin <marcan@marcan.st> Link: https://lore.kernel.org/r/20220916094152.87137-4-j@jannau.net Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 745ef10 commit d8fe365

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/iommu/io-pgtable-dart.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define pr_fmt(fmt) "dart io-pgtable: " fmt
1515

1616
#include <linux/atomic.h>
17+
#include <linux/bitfield.h>
1718
#include <linux/bitops.h>
1819
#include <linux/io-pgtable.h>
1920
#include <linux/kernel.h>
@@ -40,6 +41,9 @@
4041
#define DART_PTES_PER_TABLE(d) \
4142
(DART_GRANULE(d) >> ilog2(sizeof(dart_iopte)))
4243

44+
#define APPLE_DART_PTE_SUBPAGE_START GENMASK_ULL(63, 52)
45+
#define APPLE_DART_PTE_SUBPAGE_END GENMASK_ULL(51, 40)
46+
4347
#define APPLE_DART1_PADDR_MASK GENMASK_ULL(35, 12)
4448

4549
/* Apple DART1 protection bits */
@@ -107,6 +111,10 @@ static int dart_init_pte(struct dart_io_pgtable *data,
107111
return -EEXIST;
108112
}
109113

114+
/* subpage protection: always allow access to the entire page */
115+
pte |= FIELD_PREP(APPLE_DART_PTE_SUBPAGE_START, 0);
116+
pte |= FIELD_PREP(APPLE_DART_PTE_SUBPAGE_END, 0xfff);
117+
110118
pte |= APPLE_DART1_PTE_PROT_SP_DIS;
111119
pte |= APPLE_DART_PTE_VALID;
112120

0 commit comments

Comments
 (0)