Skip to content

Commit 73b20c8

Browse files
rmurphy-armtorvalds
authored andcommitted
arm64: mm: implement pte_devmap support
In order for things like get_user_pages() to work on ZONE_DEVICE memory, we need a software PTE bit to identify device-backed PFNs. Hook this up along with the relevant helpers to join in with ARCH_HAS_PTE_DEVMAP. [[email protected]: build fixes] Link: http://lkml.kernel.org/r/13026c4e64abc17133bbfa07d7731ec6691c0bcd.1559050949.git.robin.murphy@arm.com Link: http://lkml.kernel.org/r/817d92886fc3b33bcbf6e105ee83a74babb3a5aa.1558547956.git.robin.murphy@arm.com Signed-off-by: Robin Murphy <[email protected]> Acked-by: Will Deacon <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dan Williams <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Jerome Glisse <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Oliver O'Halloran <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1759673 commit 73b20c8

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

arch/arm64/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config ARM64
2424
select ARCH_HAS_KCOV
2525
select ARCH_HAS_KEEPINITRD
2626
select ARCH_HAS_MEMBARRIER_SYNC_CORE
27+
select ARCH_HAS_PTE_DEVMAP
2728
select ARCH_HAS_PTE_SPECIAL
2829
select ARCH_HAS_SETUP_DMA_OPS
2930
select ARCH_HAS_SET_DIRECT_MAP

arch/arm64/include/asm/pgtable-prot.h

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define PTE_WRITE (PTE_DBM) /* same as DBM (51) */
1717
#define PTE_DIRTY (_AT(pteval_t, 1) << 55)
1818
#define PTE_SPECIAL (_AT(pteval_t, 1) << 56)
19+
#define PTE_DEVMAP (_AT(pteval_t, 1) << 57)
1920
#define PTE_PROT_NONE (_AT(pteval_t, 1) << 58) /* only when !PTE_VALID */
2021

2122
#ifndef __ASSEMBLY__

arch/arm64/include/asm/pgtable.h

+21
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
7979
#define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE))
8080
#define pte_user_exec(pte) (!(pte_val(pte) & PTE_UXN))
8181
#define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT))
82+
#define pte_devmap(pte) (!!(pte_val(pte) & PTE_DEVMAP))
8283

8384
#define pte_cont_addr_end(addr, end) \
8485
({ unsigned long __boundary = ((addr) + CONT_PTE_SIZE) & CONT_PTE_MASK; \
@@ -206,6 +207,11 @@ static inline pmd_t pmd_mkcont(pmd_t pmd)
206207
return __pmd(pmd_val(pmd) | PMD_SECT_CONT);
207208
}
208209

210+
static inline pte_t pte_mkdevmap(pte_t pte)
211+
{
212+
return set_pte_bit(pte, __pgprot(PTE_DEVMAP));
213+
}
214+
209215
static inline void set_pte(pte_t *ptep, pte_t pte)
210216
{
211217
WRITE_ONCE(*ptep, pte);
@@ -388,6 +394,11 @@ static inline int pmd_protnone(pmd_t pmd)
388394

389395
#define pmd_mkhuge(pmd) (__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT))
390396

397+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
398+
#define pmd_devmap(pmd) pte_devmap(pmd_pte(pmd))
399+
#endif
400+
#define pmd_mkdevmap(pmd) pte_pmd(pte_mkdevmap(pmd_pte(pmd)))
401+
391402
#define __pmd_to_phys(pmd) __pte_to_phys(pmd_pte(pmd))
392403
#define __phys_to_pmd_val(phys) __phys_to_pte_val(phys)
393404
#define pmd_pfn(pmd) ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT)
@@ -673,6 +684,16 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
673684
{
674685
return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty);
675686
}
687+
688+
static inline int pud_devmap(pud_t pud)
689+
{
690+
return 0;
691+
}
692+
693+
static inline int pgd_devmap(pgd_t pgd)
694+
{
695+
return 0;
696+
}
676697
#endif
677698

678699
/*

0 commit comments

Comments
 (0)