Skip to content

Commit b7b8a63

Browse files
misalehwilldeacon
authored andcommitted
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: 4dcac84 ("iommu/io-pgtable-arm: Fix stage-2 concatenation with 16K") Signed-off-by: Mostafa Saleh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 376ce8b commit b7b8a63

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,13 @@ static inline int arm_lpae_max_entries(int i, struct arm_lpae_io_pgtable *data)
232232
* c) 42 bits PA size with 4K: use level 1 instead of level 0 (8 tables for ias = oas)
233233
* d) 48 bits PA size with 16K: use level 1 instead of level 0 (2 tables for ias = oas)
234234
*/
235-
static inline bool arm_lpae_concat_mandatory(struct arm_lpae_io_pgtable *data)
235+
static inline bool arm_lpae_concat_mandatory(struct io_pgtable_cfg *cfg,
236+
struct arm_lpae_io_pgtable *data)
236237
{
237-
unsigned int ias = data->iop.cfg.ias;
238-
unsigned int oas = data->iop.cfg.oas;
238+
unsigned int ias = cfg->ias;
239+
unsigned int oas = cfg->oas;
239240

240-
/* Covers 1 and 2.d */
241+
/* Covers 1 and 2.d */
241242
if ((ARM_LPAE_GRANULE(data) == SZ_16K) && (data->start_level == 0))
242243
return (oas == 48) || (ias == 48);
243244

@@ -1033,7 +1034,7 @@ arm_64_lpae_alloc_pgtable_s2(struct io_pgtable_cfg *cfg, void *cookie)
10331034
if (!data)
10341035
return NULL;
10351036

1036-
if (arm_lpae_concat_mandatory(data)) {
1037+
if (arm_lpae_concat_mandatory(cfg, data)) {
10371038
if (WARN_ON((ARM_LPAE_PGD_SIZE(data) / sizeof(arm_lpae_iopte)) >
10381039
ARM_LPAE_S2_MAX_CONCAT_PAGES))
10391040
return NULL;

0 commit comments

Comments
 (0)