Skip to content

Commit

Permalink
mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t *
Browse files Browse the repository at this point in the history
No functional change in this patch.

[[email protected]: m68k build error reported by kernel robot]
  Link: https://lkml.kernel.org/r/[email protected]

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q@mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Joel Fernandes <[email protected]>
Cc: Kalesh Singh <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kvaneesh authored and torvalds committed Jul 8, 2021
1 parent 9cf6fa2 commit dc4875f
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions arch/arm64/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
return __p4d_to_phys(p4d);
}

static inline unsigned long p4d_page_vaddr(p4d_t p4d)
static inline pud_t *p4d_pgtable(p4d_t p4d)
{
return (unsigned long)__va(p4d_page_paddr(p4d));
return (pud_t *)__va(p4d_page_paddr(p4d));
}

/* Find an entry in the frst-level page table. */
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ ia64_phys_addr_valid (unsigned long addr)
#define p4d_bad(p4d) (!ia64_phys_addr_valid(p4d_val(p4d)))
#define p4d_present(p4d) (p4d_val(p4d) != 0UL)
#define p4d_clear(p4dp) (p4d_val(*(p4dp)) = 0UL)
#define p4d_page_vaddr(p4d) ((unsigned long) __va(p4d_val(p4d) & _PFN_MASK))
#define p4d_pgtable(p4d) ((pud_t *) __va(p4d_val(p4d) & _PFN_MASK))
#define p4d_page(p4d) virt_to_page((p4d_val(p4d) + PAGE_OFFSET))
#endif

Expand Down
4 changes: 2 additions & 2 deletions arch/mips/include/asm/pgtable-64.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ static inline void p4d_clear(p4d_t *p4dp)
p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
}

static inline unsigned long p4d_page_vaddr(p4d_t p4d)
static inline pud_t *p4d_pgtable(p4d_t p4d)
{
return p4d_val(p4d);
return (pud_t *)p4d_val(p4d);
}

#define p4d_phys(p4d) virt_to_phys((void *)p4d_val(p4d))
Expand Down
5 changes: 4 additions & 1 deletion arch/powerpc/include/asm/book3s/64/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,10 @@ extern struct page *p4d_page(p4d_t p4d);
/* Pointers in the page table tree are physical addresses */
#define __pgtable_ptr_val(ptr) __pa(ptr)

#define p4d_page_vaddr(p4d) __va(p4d_val(p4d) & ~P4D_MASKED_BITS)
static inline pud_t *p4d_pgtable(p4d_t p4d)
{
return (pud_t *)__va(p4d_val(p4d) & ~P4D_MASKED_BITS);
}

static inline pmd_t *pud_pgtable(pud_t pud)
{
Expand Down
6 changes: 5 additions & 1 deletion arch/powerpc/include/asm/nohash/64/pgtable-4k.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@
#define p4d_none(p4d) (!p4d_val(p4d))
#define p4d_bad(p4d) (p4d_val(p4d) == 0)
#define p4d_present(p4d) (p4d_val(p4d) != 0)
#define p4d_page_vaddr(p4d) (p4d_val(p4d) & ~P4D_MASKED_BITS)

#ifndef __ASSEMBLY__

static inline pud_t *p4d_pgtable(p4d_t p4d)
{
return (pud_t *) (p4d_val(p4d) & ~P4D_MASKED_BITS);
}

static inline void p4d_clear(p4d_t *p4dp)
{
*p4dp = __p4d(0);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/mm/book3s64/radix_pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ static void __meminit remove_pagetable(unsigned long start, unsigned long end)
continue;
}

pud_base = (pud_t *)p4d_page_vaddr(*p4d);
pud_base = p4d_pgtable(*p4d);
remove_pud_table(pud_base, addr, next);
free_pud_table(pud_base, p4d);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/mm/pgtable_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct page *p4d_page(p4d_t p4d)
VM_WARN_ON(!p4d_huge(p4d));
return pte_page(p4d_pte(p4d));
}
return virt_to_page(p4d_page_vaddr(p4d));
return virt_to_page(p4d_pgtable(p4d));
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/include/asm/pgtable_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ static inline pmd_t *pud_pgtable(pud_t pud)
#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0UL)
#define pud_present(pud) (pud_val(pud) != 0U)
#define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
#define p4d_page_vaddr(p4d) \
((unsigned long) __va(p4d_val(p4d)))
#define p4d_pgtable(p4d) \
((pud_t *) __va(p4d_val(p4d)))
#define p4d_present(p4d) (p4d_val(p4d) != 0U)
#define p4d_clear(p4dp) (p4d_val(*(p4dp)) = 0UL)

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,9 @@ static inline int p4d_present(p4d_t p4d)
return p4d_flags(p4d) & _PAGE_PRESENT;
}

static inline unsigned long p4d_page_vaddr(p4d_t p4d)
static inline pud_t *p4d_pgtable(p4d_t p4d)
{
return (unsigned long)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
return (pud_t *)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
}

/*
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)
spin_lock(pgt_lock);

if (!p4d_none(*p4d_ref) && !p4d_none(*p4d))
BUG_ON(p4d_page_vaddr(*p4d)
!= p4d_page_vaddr(*p4d_ref));
BUG_ON(p4d_pgtable(*p4d)
!= p4d_pgtable(*p4d_ref));

if (p4d_none(*p4d))
set_p4d(p4d, *p4d_ref);
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/pgtable-nop4d.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
#define __p4d(x) ((p4d_t) { __pgd(x) })

#define pgd_page(pgd) (p4d_page((p4d_t){ pgd }))
#define pgd_page_vaddr(pgd) (p4d_page_vaddr((p4d_t){ pgd }))
#define pgd_page_vaddr(pgd) ((unsigned long)(p4d_pgtable((p4d_t){ pgd })))

/*
* allocating and freeing a p4d is trivial: the 1-entry p4d is
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/pgtable-nopud.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
#define __pud(x) ((pud_t) { __p4d(x) })

#define p4d_page(p4d) (pud_page((pud_t){ p4d }))
#define p4d_page_vaddr(p4d) (pud_pgtable((pud_t){ p4d }))
#define p4d_pgtable(p4d) ((pud_t *)(pud_pgtable((pud_t){ p4d })))

/*
* allocating and freeing a pud is trivial: the 1-entry pud is
Expand Down
2 changes: 1 addition & 1 deletion include/linux/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
#ifndef pud_offset
static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
{
return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
return p4d_pgtable(*p4d) + pud_index(address);
}
#define pud_offset pud_offset
#endif
Expand Down

0 comments on commit dc4875f

Please sign in to comment.