Skip to content

Commit 6966d79

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
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: 82a1a1f ("riscv: mm: support Svnapot in hugetlb page") Signed-off-by: Alexandre Ghiti <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 835e5ac commit 6966d79

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

arch/riscv/include/asm/hugetlb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
3636
unsigned long addr, pte_t *ptep,
3737
pte_t pte, int dirty);
3838

39+
#define __HAVE_ARCH_HUGE_PTEP_GET
40+
pte_t huge_ptep_get(pte_t *ptep);
41+
3942
pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags);
4043
#define arch_make_huge_pte arch_make_huge_pte
4144

arch/riscv/mm/hugetlbpage.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@
33
#include <linux/err.h>
44

55
#ifdef CONFIG_RISCV_ISA_SVNAPOT
6+
pte_t huge_ptep_get(pte_t *ptep)
7+
{
8+
unsigned long pte_num;
9+
int i;
10+
pte_t orig_pte = ptep_get(ptep);
11+
12+
if (!pte_present(orig_pte) || !pte_napot(orig_pte))
13+
return orig_pte;
14+
15+
pte_num = napot_pte_num(napot_cont_order(orig_pte));
16+
17+
for (i = 0; i < pte_num; i++, ptep++) {
18+
pte_t pte = ptep_get(ptep);
19+
20+
if (pte_dirty(pte))
21+
orig_pte = pte_mkdirty(orig_pte);
22+
23+
if (pte_young(pte))
24+
orig_pte = pte_mkyoung(orig_pte);
25+
}
26+
27+
return orig_pte;
28+
}
29+
630
pte_t *huge_pte_alloc(struct mm_struct *mm,
731
struct vm_area_struct *vma,
832
unsigned long addr,

0 commit comments

Comments
 (0)