Skip to content

Commit

Permalink
powerpc/32: drop get_pteptr()
Browse files Browse the repository at this point in the history
Commit 8d30c14 ("powerpc/mm: Rework I$/D$ coherency (v3)") and
commit 90ac19a ("[POWERPC] Abolish iopa(), mm_ptov(),
io_block_mapping() from arch/powerpc") removed the use of get_pteptr()
outside of mm/pgtable_32.c

In mm/pgtable_32.c, the only user of get_pteptr() is change_page_attr()
which operates on kernel context and on lowmem pages only.

Make virt_to_kpte() available outside of mm/mem.c and use it instead
of get_pteptr(), and drop get_pteptr()

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/788378c6c3ba5c5298caab7c7f95e6c3c88244b8.1578558199.git.christophe.leroy@c-s.fr
  • Loading branch information
chleroy authored and mpe committed Feb 25, 2020
1 parent 0b1c524 commit 2efc7c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 42 deletions.
5 changes: 5 additions & 0 deletions arch/powerpc/include/asm/pgtable.h
Expand Up @@ -51,6 +51,11 @@ static inline pmd_t *pmd_ptr_k(unsigned long va)
{
return pmd_offset(pud_offset(pgd_offset_k(va), va), va);
}

static inline pte_t *virt_to_kpte(unsigned long vaddr)
{
return pte_offset_kernel(pmd_ptr_k(vaddr), vaddr);
}
#endif

#include <asm/tlbflush.h>
Expand Down
5 changes: 0 additions & 5 deletions arch/powerpc/mm/mem.c
Expand Up @@ -66,11 +66,6 @@ pte_t *kmap_pte;
EXPORT_SYMBOL(kmap_pte);
pgprot_t kmap_prot;
EXPORT_SYMBOL(kmap_prot);

static inline pte_t *virt_to_kpte(unsigned long vaddr)
{
return pte_offset_kernel(pmd_ptr_k(vaddr), vaddr);
}
#endif

pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
Expand Down
39 changes: 2 additions & 37 deletions arch/powerpc/mm/pgtable_32.c
Expand Up @@ -121,55 +121,20 @@ void __init mapin_ram(void)
}
}

/* Scan the real Linux page tables and return a PTE pointer for
* a virtual address in a context.
* Returns true (1) if PTE was found, zero otherwise. The pointer to
* the PTE pointer is unmodified if PTE is not found.
*/
static int
get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep, pmd_t **pmdp)
{
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *pte;
int retval = 0;

pgd = pgd_offset(mm, addr & PAGE_MASK);
if (pgd) {
pud = pud_offset(pgd, addr & PAGE_MASK);
if (pud && pud_present(*pud)) {
pmd = pmd_offset(pud, addr & PAGE_MASK);
if (pmd_present(*pmd)) {
pte = pte_offset_map(pmd, addr & PAGE_MASK);
if (pte) {
retval = 1;
*ptep = pte;
if (pmdp)
*pmdp = pmd;
/* XXX caller needs to do pte_unmap, yuck */
}
}
}
}
return(retval);
}

static int __change_page_attr_noflush(struct page *page, pgprot_t prot)
{
pte_t *kpte;
pmd_t *kpmd;
unsigned long address;

BUG_ON(PageHighMem(page));
address = (unsigned long)page_address(page);

if (v_block_mapped(address))
return 0;
if (!get_pteptr(&init_mm, address, &kpte, &kpmd))
kpte = virt_to_kpte(address);
if (!kpte)
return -EINVAL;
__set_pte_at(&init_mm, address, kpte, mk_pte(page, prot), 0);
pte_unmap(kpte);

return 0;
}
Expand Down

0 comments on commit 2efc7c0

Please sign in to comment.