powerpc/mm: use pte helpers in generic code
Get rid of platform specific _PAGE_XXXX in powerpc common code and use helpers instead. mm/dump_linuxpagetables.c will be handled separately 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
34eb138ed7
commit
26973fa5ac
@@ -44,20 +44,13 @@ static inline int is_exec_fault(void)
|
||||
static inline int pte_looks_normal(pte_t pte)
|
||||
{
|
||||
|
||||
#if defined(CONFIG_PPC_BOOK3S_64)
|
||||
if ((pte_val(pte) & (_PAGE_PRESENT | _PAGE_SPECIAL)) == _PAGE_PRESENT) {
|
||||
if (pte_present(pte) && !pte_special(pte)) {
|
||||
if (pte_ci(pte))
|
||||
return 0;
|
||||
if (pte_user(pte))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return (pte_val(pte) &
|
||||
(_PAGE_PRESENT | _PAGE_SPECIAL | _PAGE_NO_CACHE | _PAGE_USER |
|
||||
_PAGE_PRIVILEGED)) ==
|
||||
(_PAGE_PRESENT | _PAGE_USER);
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct page *maybe_pte_to_page(pte_t pte)
|
||||
@@ -117,7 +110,7 @@ static pte_t set_pte_filter(pte_t pte)
|
||||
struct page *pg;
|
||||
|
||||
/* No exec permission in the first place, move on */
|
||||
if (!(pte_val(pte) & _PAGE_EXEC) || !pte_looks_normal(pte))
|
||||
if (!pte_exec(pte) || !pte_looks_normal(pte))
|
||||
return pte;
|
||||
|
||||
/* If you set _PAGE_EXEC on weird pages you're on your own */
|
||||
@@ -137,7 +130,7 @@ static pte_t set_pte_filter(pte_t pte)
|
||||
}
|
||||
|
||||
/* Else, we filter out _PAGE_EXEC */
|
||||
return __pte(pte_val(pte) & ~_PAGE_EXEC);
|
||||
return pte_exprotect(pte);
|
||||
}
|
||||
|
||||
static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
|
||||
@@ -150,7 +143,7 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
|
||||
* if necessary. Also if _PAGE_EXEC is already set, same deal,
|
||||
* we just bail out
|
||||
*/
|
||||
if (dirty || (pte_val(pte) & _PAGE_EXEC) || !is_exec_fault())
|
||||
if (dirty || pte_exec(pte) || !is_exec_fault())
|
||||
return pte;
|
||||
|
||||
#ifdef CONFIG_DEBUG_VM
|
||||
@@ -176,7 +169,7 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
|
||||
set_bit(PG_arch_1, &pg->flags);
|
||||
|
||||
bail:
|
||||
return __pte(pte_val(pte) | _PAGE_EXEC);
|
||||
return pte_mkexec(pte);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PPC_BOOK3S */
|
||||
@@ -191,10 +184,10 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
|
||||
* Make sure hardware valid bit is not set. We don't do
|
||||
* tlb flush for this update.
|
||||
*/
|
||||
VM_WARN_ON(pte_val(*ptep) & _PAGE_PRESENT);
|
||||
VM_WARN_ON(pte_hw_valid(*ptep));
|
||||
|
||||
/* Add the pte bit when trying to set a pte */
|
||||
pte = __pte(pte_val(pte) | _PAGE_PTE);
|
||||
pte = pte_mkpte(pte);
|
||||
|
||||
/* Note: mm->context.id might not yet have been assigned as
|
||||
* this context might not have been activated yet when this
|
||||
|
Reference in New Issue
Block a user