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)
committerAlexandre Ghiti <alexghiti@rivosinc.com>
Tue, 1 Apr 2025 07:03:03 +0000 (07:03 +0000)
commit83d78ac677b9fdd8ea763507c6fe02d6bf415f3a
tree4bb7ae78dd8786289d205070653c3ce4465f6c08
parenta3313375e88e0075b9048eba15e5eb4dbf93f60e
riscv: Fix hugetlb retrieval of number of ptes in case of !present pte

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>
arch/riscv/mm/hugetlbpage.c