diff options
author | Mostafa Saleh <smostafa@google.com> | 2024-12-15 20:04:11 +0000 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2024-12-19 15:41:27 +0000 |
commit | b7b8a63055572f5baa78c1d9d048aad750b02ba5 (patch) | |
tree | 8c04b69d6f1cb4f4ebef00c231e0b272c512818b | |
parent | 376ce8b35ed15d5deee57bdecd8449f6a4df4c42 (diff) |
iommu/io-pgtable-arm: Fix cfg reading in arm_lpae_concat_mandatory()
The newly introduced arm_lpae_concat_mandatory() function reads the
ias/oas fields from the 'io_pgtable_cfg' copy embedded inside the
'arm_lpae_io_pgtable' structure. However, this copy is not set until
later in alloc_io_pgtable_ops() after the alloc() function has been
called.
Use the address sizes passed in the 'io_pgtable_cfg' structure when
deciding whether or not to concatenate the PGD.
Fixes: 4dcac8407fe1 ("iommu/io-pgtable-arm: Fix stage-2 concatenation with 16K")
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Link: https://lore.kernel.org/r/20241215200412.561400-1-smostafa@google.com
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | drivers/iommu/io-pgtable-arm.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index c1b62c7d81ba..7e53ee51270b 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -232,12 +232,13 @@ static inline int arm_lpae_max_entries(int i, struct arm_lpae_io_pgtable *data) * c) 42 bits PA size with 4K: use level 1 instead of level 0 (8 tables for ias = oas) * d) 48 bits PA size with 16K: use level 1 instead of level 0 (2 tables for ias = oas) */ -static inline bool arm_lpae_concat_mandatory(struct arm_lpae_io_pgtable *data) +static inline bool arm_lpae_concat_mandatory(struct io_pgtable_cfg *cfg, + struct arm_lpae_io_pgtable *data) { - unsigned int ias = data->iop.cfg.ias; - unsigned int oas = data->iop.cfg.oas; + unsigned int ias = cfg->ias; + unsigned int oas = cfg->oas; - /* Covers 1 and 2.d */ + /* Covers 1 and 2.d */ if ((ARM_LPAE_GRANULE(data) == SZ_16K) && (data->start_level == 0)) return (oas == 48) || (ias == 48); @@ -1033,7 +1034,7 @@ arm_64_lpae_alloc_pgtable_s2(struct io_pgtable_cfg *cfg, void *cookie) if (!data) return NULL; - if (arm_lpae_concat_mandatory(data)) { + if (arm_lpae_concat_mandatory(cfg, data)) { if (WARN_ON((ARM_LPAE_PGD_SIZE(data) / sizeof(arm_lpae_iopte)) > ARM_LPAE_S2_MAX_CONCAT_PAGES)) return NULL; |