@@ -49,6 +49,7 @@ config RISCV
select GENERIC_IRQ_MULTI_HANDLER
select ARCH_HAS_PTE_SPECIAL
select HAVE_EBPF_JIT if 64BIT
+ select ARCH_HAS_ZONE_DEVICE
config MMU
def_bool y
@@ -30,9 +30,11 @@
#define _PAGE_GLOBAL (1 << 5) /* Global */
#define _PAGE_ACCESSED (1 << 6) /* Set by hardware on any access */
#define _PAGE_DIRTY (1 << 7) /* Set by hardware on any write */
-#define _PAGE_SOFT (1 << 8) /* Reserved for software */
+#define _PAGE_SOFT1 (1 << 8) /* Reserved for software */
+#define _PAGE_SOFT2 (1 << 9) /* Reserved for software */
-#define _PAGE_SPECIAL _PAGE_SOFT
+#define _PAGE_SPECIAL _PAGE_SOFT1
+#define _PAGE_DEVMAP _PAGE_SOFT2
#define _PAGE_TABLE _PAGE_PRESENT
/*
@@ -41,6 +43,8 @@
*/
#define _PAGE_PROT_NONE _PAGE_READ
+#define __HAVE_ARCH_PTE_DEVMAP
+
#define _PAGE_PFN_SHIFT 10
/* Set of bits to preserve across pte_modify() */
@@ -248,6 +248,11 @@ static inline int pte_special(pte_t pte)
return pte_val(pte) & _PAGE_SPECIAL;
}
+static inline int pte_devmap(pte_t pte)
+{
+ return pte_val(pte) & _PAGE_DEVMAP;
+}
+
/* static inline pte_t pte_rdprotect(pte_t pte) */
static inline pte_t pte_wrprotect(pte_t pte)
@@ -289,6 +294,11 @@ static inline pte_t pte_mkspecial(pte_t pte)
return __pte(pte_val(pte) | _PAGE_SPECIAL);
}
+static inline pte_t pte_mkdevmap(pte_t pte)
+{
+ return __pte(pte_val(pte) | _PAGE_SPECIAL | _PAGE_DEVMAP);
+}
+
/* Modify page protection bits */
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
{
Use the 2nd software bit in the PTE as the devmap bit and add the appropriate accessors. This also allows us to set ARCH_HAS_ZONE_DEVICE. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Anup Patel <anup.patel@wdc.com> Cc: Zong Li <zong@andestech.com> Cc: Guo Ren <ren_guo@c-sky.com> Cc: "Stefan O'Rear" <sorear2@gmail.com> --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/pgtable-bits.h | 8 ++++++-- arch/riscv/include/asm/pgtable.h | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-)