powerpc/mm: add pte helpers to query and change pte flags
In order to avoid using generic _PAGE_XXX flags in powerpc core functions, define helpers for all needed flags: - pte_mkuser() and pte_mkprivileged() to set/unset and/or unset/set _PAGE_USER and/or _PAGE_PRIVILEGED - pte_hashpte() to check if _PAGE_HASHPTE is set. - pte_ci() check if cache is inhibited (already existing on book3s/64) - pte_exprotect() to protect against execution - pte_exec() and pte_mkexec() to query and set page execution - pte_mkpte() to set _PAGE_PTE flag. - pte_hw_valid() to check _PAGE_PRESENT since pte_present does something different on book3s/64. On book3s/32 there is no exec protection, so pte_mkexec() and pte_exprotect() are nops and pte_exec() returns always true. Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:

committed by
Michael Ellerman

parent
aa9cd505e3
commit
daba790242
@@ -19,6 +19,9 @@ static inline int pte_read(pte_t pte) { return 1; }
|
||||
static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
|
||||
static inline int pte_special(pte_t pte) { return pte_val(pte) & _PAGE_SPECIAL; }
|
||||
static inline int pte_none(pte_t pte) { return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; }
|
||||
static inline bool pte_hashpte(pte_t pte) { return false; }
|
||||
static inline bool pte_ci(pte_t pte) { return pte_val(pte) & _PAGE_NO_CACHE; }
|
||||
static inline bool pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_EXEC; }
|
||||
static inline pgprot_t pte_pgprot(pte_t pte) { return __pgprot(pte_val(pte) & PAGE_PROT_BITS); }
|
||||
|
||||
#ifdef CONFIG_NUMA_BALANCING
|
||||
@@ -44,6 +47,11 @@ static inline int pte_present(pte_t pte)
|
||||
return pte_val(pte) & _PAGE_PRESENT;
|
||||
}
|
||||
|
||||
static inline bool pte_hw_valid(pte_t pte)
|
||||
{
|
||||
return pte_val(pte) & _PAGE_PRESENT;
|
||||
}
|
||||
|
||||
/*
|
||||
* We only find page table entry in the last level
|
||||
* Hence no need for other accessors
|
||||
@@ -77,6 +85,11 @@ static inline unsigned long pte_pfn(pte_t pte) {
|
||||
return pte_val(pte) >> PTE_RPN_SHIFT; }
|
||||
|
||||
/* Generic modifiers for PTE bits */
|
||||
static inline pte_t pte_exprotect(pte_t pte)
|
||||
{
|
||||
return __pte(pte_val(pte) & ~_PAGE_EXEC);
|
||||
}
|
||||
|
||||
static inline pte_t pte_mkclean(pte_t pte)
|
||||
{
|
||||
return __pte(pte_val(pte) & ~(_PAGE_DIRTY | _PAGE_HWWRITE));
|
||||
@@ -87,6 +100,11 @@ static inline pte_t pte_mkold(pte_t pte)
|
||||
return __pte(pte_val(pte) & ~_PAGE_ACCESSED);
|
||||
}
|
||||
|
||||
static inline pte_t pte_mkpte(pte_t pte)
|
||||
{
|
||||
return pte;
|
||||
}
|
||||
|
||||
static inline pte_t pte_mkspecial(pte_t pte)
|
||||
{
|
||||
return __pte(pte_val(pte) | _PAGE_SPECIAL);
|
||||
@@ -97,6 +115,16 @@ static inline pte_t pte_mkhuge(pte_t pte)
|
||||
return __pte(pte_val(pte) | _PAGE_HUGE);
|
||||
}
|
||||
|
||||
static inline pte_t pte_mkprivileged(pte_t pte)
|
||||
{
|
||||
return __pte((pte_val(pte) & ~_PAGE_USER) | _PAGE_PRIVILEGED);
|
||||
}
|
||||
|
||||
static inline pte_t pte_mkuser(pte_t pte)
|
||||
{
|
||||
return __pte((pte_val(pte) & ~_PAGE_PRIVILEGED) | _PAGE_USER);
|
||||
}
|
||||
|
||||
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
|
||||
{
|
||||
return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
|
||||
|
Reference in New Issue
Block a user