mirror of
https://github.com/torvalds/linux.git
synced 2026-11-25 07:52:34 +00:00
All architectures define pte_index() as (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1) and all architectures define pte_offset_kernel() as an entry in the array of PTEs indexed by the pte_index(). For the most architectures the pte_offset_kernel() implementation relies on the availability of pmd_page_vaddr() that converts a PMD entry value to the virtual address of the page containing PTEs array. Let's move x86 definitions of the PTE accessors to the generic place in <linux/pgtable.h> and then simply drop the respective definitions from the other architectures. The architectures that didn't provide pmd_page_vaddr() are updated to have that defined. The generic implementation of pte_offset_kernel() can be overridden by an architecture and alpha makes use of this because it has special ordering requirements for its version of pte_offset_kernel(). [[email protected]: v2] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: update] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: update] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: fix x86 warning] [[email protected]: fix powerpc build] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Stephen Rothwell <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Chris Zankel <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Guo Ren <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Helge Deller <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Ley Foon Tan <[email protected]> Cc: Mark Salter <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Matt Turner <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Nick Hu <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Rich Felker <[email protected]> Cc: Russell King <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vincent Chen <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yoshinori Sato <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
87 lines
1.8 KiB
C
87 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
*/
|
|
|
|
#ifndef _ASM_RISCV_PGTABLE_64_H
|
|
#define _ASM_RISCV_PGTABLE_64_H
|
|
|
|
#include <linux/const.h>
|
|
|
|
#define PGDIR_SHIFT 30
|
|
/* Size of region mapped by a page global directory */
|
|
#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
|
|
#define PGDIR_MASK (~(PGDIR_SIZE - 1))
|
|
|
|
#define PMD_SHIFT 21
|
|
/* Size of region mapped by a page middle directory */
|
|
#define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
|
|
#define PMD_MASK (~(PMD_SIZE - 1))
|
|
|
|
/* Page Middle Directory entry */
|
|
typedef struct {
|
|
unsigned long pmd;
|
|
} pmd_t;
|
|
|
|
#define pmd_val(x) ((x).pmd)
|
|
#define __pmd(x) ((pmd_t) { (x) })
|
|
|
|
#define PTRS_PER_PMD (PAGE_SIZE / sizeof(pmd_t))
|
|
|
|
static inline int pud_present(pud_t pud)
|
|
{
|
|
return (pud_val(pud) & _PAGE_PRESENT);
|
|
}
|
|
|
|
static inline int pud_none(pud_t pud)
|
|
{
|
|
return (pud_val(pud) == 0);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
static inline void pud_clear(pud_t *pudp)
|
|
{
|
|
set_pud(pudp, __pud(0));
|
|
}
|
|
|
|
static inline unsigned long pud_page_vaddr(pud_t pud)
|
|
{
|
|
return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
|
|
}
|
|
|
|
static inline struct page *pud_page(pud_t pud)
|
|
{
|
|
return pfn_to_page(pud_val(pud) >> _PAGE_PFN_SHIFT);
|
|
}
|
|
|
|
static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t prot)
|
|
{
|
|
return __pmd((pfn << _PAGE_PFN_SHIFT) | pgprot_val(prot));
|
|
}
|
|
|
|
static inline unsigned long _pmd_pfn(pmd_t pmd)
|
|
{
|
|
return pmd_val(pmd) >> _PAGE_PFN_SHIFT;
|
|
}
|
|
|
|
#define pmd_ERROR(e) \
|
|
pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
|
|
|
|
#endif /* _ASM_RISCV_PGTABLE_64_H */
|