summaryrefslogtreecommitdiffstats
path: root/arch/riscv/mm/hugetlbpage.c
diff options
context:
space:
mode:
authorAlexandre Ghiti <alexghiti@rivosinc.com>2023-04-28 14:01:20 +0200
committerPalmer Dabbelt <palmer@rivosinc.com>2023-06-01 18:15:37 -0700
commit6966d7988c4fb6af3e395868e9800c07f9e98a30 (patch)
tree2293c2710a82671789b062a21b366eb30f687837 /arch/riscv/mm/hugetlbpage.c
parent835e5ac3f98e78eca5c512bd48bd1880b90c4eb1 (diff)
downloadlinux-6966d7988c4fb6af3e395868e9800c07f9e98a30.tar.gz
linux-6966d7988c4fb6af3e395868e9800c07f9e98a30.tar.bz2
linux-6966d7988c4fb6af3e395868e9800c07f9e98a30.zip
riscv: Implement missing huge_ptep_get
huge_ptep_get must be reimplemented in order to go through all the PTEs of a NAPOT region: this is needed because the HW can update the A/D bits of any of the PTE that constitutes the NAPOT region. Fixes: 82a1a1f3bfb6 ("riscv: mm: support Svnapot in hugetlb page") Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20230428120120.21620-2-alexghiti@rivosinc.com Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/mm/hugetlbpage.c')
-rw-r--r--arch/riscv/mm/hugetlbpage.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c
index 238d00bdac14..e0ef56dc57b9 100644
--- a/arch/riscv/mm/hugetlbpage.c
+++ b/arch/riscv/mm/hugetlbpage.c
@@ -3,6 +3,30 @@
#include <linux/err.h>
#ifdef CONFIG_RISCV_ISA_SVNAPOT
+pte_t huge_ptep_get(pte_t *ptep)
+{
+ unsigned long pte_num;
+ int i;
+ pte_t orig_pte = ptep_get(ptep);
+
+ if (!pte_present(orig_pte) || !pte_napot(orig_pte))
+ return orig_pte;
+
+ pte_num = napot_pte_num(napot_cont_order(orig_pte));
+
+ for (i = 0; i < pte_num; i++, ptep++) {
+ pte_t pte = ptep_get(ptep);
+
+ if (pte_dirty(pte))
+ orig_pte = pte_mkdirty(orig_pte);
+
+ if (pte_young(pte))
+ orig_pte = pte_mkyoung(orig_pte);
+ }
+
+ return orig_pte;
+}
+
pte_t *huge_pte_alloc(struct mm_struct *mm,
struct vm_area_struct *vma,
unsigned long addr,