]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
riscv: Fix hugetlb retrieval of number of ptes in case of !present pte
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Mon, 17 Mar 2025 07:25:51 +0000 (08:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:37:39 +0000 (14:37 +0200)
commit8db65e4432b20dd8f704d5990031624828f89cee
tree985f6a9cd2a243e8e41cd84e0edde0fd0f10fe4b
parent992678427eff624f917b3f7d9feafb4143190d39
riscv: Fix hugetlb retrieval of number of ptes in case of !present pte

[ Upstream commit 83d78ac677b9fdd8ea763507c6fe02d6bf415f3a ]

Ryan sent a fix [1] for arm64 that applies to riscv too: in some hugetlb
functions, we must not use the pte value to get the size of a mapping
because the pte may not be present.

So use the already present size parameter for huge_pte_clear() and the
newly introduced size parameter for huge_ptep_get_and_clear(). And make
sure to gather A/D bits only on present ptes.

Fixes: 82a1a1f3bfb6 ("riscv: mm: support Svnapot in hugetlb page")
Link: https://lore.kernel.org/all/20250217140419.1702389-1-ryan.roberts@arm.com/
Link: https://lore.kernel.org/r/20250317072551.572169-1-alexghiti@rivosinc.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/mm/hugetlbpage.c