Skip to content

Commit c29fc62

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Fix wrong usage of lm_alias() when splitting a huge linear mapping
lm_alias() can only be used on kernel mappings since it explicitly uses __pa_symbol(), so simply fix this by checking where the address belongs to before. Fixes: 311cd2f ("riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge linear mappings") Reported-by: [email protected] Closes: https://lore.kernel.org/linux-riscv/[email protected]/ Signed-off-by: Alexandre Ghiti <[email protected]> Reviewed-by: Charlie Jenkins <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 420370f commit c29fc62

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/riscv/mm/pageattr.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,13 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask,
305305
goto unlock;
306306
}
307307
} else if (is_kernel_mapping(start) || is_linear_mapping(start)) {
308-
lm_start = (unsigned long)lm_alias(start);
309-
lm_end = (unsigned long)lm_alias(end);
308+
if (is_kernel_mapping(start)) {
309+
lm_start = (unsigned long)lm_alias(start);
310+
lm_end = (unsigned long)lm_alias(end);
311+
} else {
312+
lm_start = start;
313+
lm_end = end;
314+
}
310315

311316
ret = split_linear_mapping(lm_start, lm_end);
312317
if (ret)

0 commit comments

Comments
 (0)