riscv: Check the virtual alignment before choosing a map size
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Wed, 7 Jun 2023 12:58:51 +0000 (14:58 +0200)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 7 Jun 2023 14:14:00 +0000 (07:14 -0700)
commit49a0a3731596fc004db6eec3fc674d92a09ef383
tree2543e3d91f5625e2391a631db74c4c56b500fb63
parent25abe0db92437fde463204c3e4eb5a71b62d6e5d
riscv: Check the virtual alignment before choosing a map size

We used to only check the alignment of the physical address to decide
which mapping would fit for a certain region of the linear mapping, but
it is not enough since the virtual address must also be aligned, so check
that too.

Fixes: 3335068f8721 ("riscv: Use PUD/P4D/PGD pages for the linear mapping")
Reported-by: Song Shuai <songshuaishuai@tinylab.org>
Link: https://lore.kernel.org/linux-riscv/tencent_7C3B580B47C1B17C16488EC1@qq.com/
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20230607125851.63370-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/mm/init.c