Linux-RISC-V Archive on
 help / color / Atom feed
* [PATCH v15 07/23] riscv: mm: Add p?d_leaf() definitions
       [not found] <>
@ 2019-11-01 14:09 ` Steven Price
  0 siblings, 0 replies; only message in thread
From: Steven Price @ 2019-11-01 14:09 UTC (permalink / raw)
  To: Andrew Morton, linux-mm
  Cc: Mark Rutland, Peter Zijlstra, Catalin Marinas, Dave Hansen,
	Zong Li, H. Peter Anvin, linux-riscv, Will Deacon, Liang, Kan,
	Alexandre Ghiti, x86, Steven Price, Ingo Molnar, Palmer Dabbelt,
	Albert Ou, Arnd Bergmann, Jérôme Glisse,
	Borislav Petkov, Andy Lutomirski, Paul Walmsley, Thomas Gleixner,
	linux-arm-kernel, Ard Biesheuvel, linux-kernel, James Morse

walk_page_range() is going to be allowed to walk page tables other than
those of user space. For this it needs to know when it has reached a
'leaf' entry in the page tables. This information is provided by the
p?d_leaf() functions/macros.

For riscv a page is a leaf page when it has a read, write or execute bit
set on it.

CC: Palmer Dabbelt <>
CC: Albert Ou <>
Reviewed-by: Alexandre Ghiti <>
Reviewed-by: Zong Li <>
Acked-by: Paul Walmsley <> # for arch/riscv
Signed-off-by: Steven Price <>
 arch/riscv/include/asm/pgtable-64.h | 7 +++++++
 arch/riscv/include/asm/pgtable.h    | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h
index 74630989006d..4c4d2c65ba6c 100644
--- a/arch/riscv/include/asm/pgtable-64.h
+++ b/arch/riscv/include/asm/pgtable-64.h
@@ -43,6 +43,13 @@ static inline int pud_bad(pud_t pud)
 	return !pud_present(pud);
+#define pud_leaf	pud_leaf
+static inline int pud_leaf(pud_t pud)
+	return pud_present(pud) &&
+	       (pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
 static inline void set_pud(pud_t *pudp, pud_t pud)
 	*pudp = pud;
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 7255f2d8395b..3aa972dda75a 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -130,6 +130,13 @@ static inline int pmd_bad(pmd_t pmd)
 	return !pmd_present(pmd);
+#define pmd_leaf	pmd_leaf
+static inline int pmd_leaf(pmd_t pmd)
+	return pmd_present(pmd) &&
+	       (pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
 static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
 	*pmdp = pmd;

linux-riscv mailing list

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <>
2019-11-01 14:09 ` [PATCH v15 07/23] riscv: mm: Add p?d_leaf() definitions Steven Price

Linux-RISC-V Archive on

Archives are clonable:
	git clone --mirror linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ \
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone