Skip to content

Commit 50b5bae

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Implement pte_accessible()
Like other architectures, a pte is accessible if it is present or if there is a pending tlb flush and the pte is protnone (which could be the case when a pte is downgraded to protnone before a flush tlb is executed). Signed-off-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 914e618 commit 50b5bae

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/riscv/include/asm/pgtable.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,19 @@ static inline int pte_present(pte_t pte)
350350
return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
351351
}
352352

353+
#define pte_accessible pte_accessible
354+
static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a)
355+
{
356+
if (pte_val(a) & _PAGE_PRESENT)
357+
return true;
358+
359+
if ((pte_val(a) & _PAGE_PROT_NONE) &&
360+
atomic_read(&mm->tlb_flush_pending))
361+
return true;
362+
363+
return false;
364+
}
365+
353366
static inline int pte_none(pte_t pte)
354367
{
355368
return (pte_val(pte) == 0);

0 commit comments

Comments
 (0)