mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-09 19:10:45 +01:00
The powerpc 32-bit implementation of pgtable has nice shortcuts for accessing kernel PMD and PTE for a given virtual address. Make these helpers available for all architectures. [[email protected]: microblaze: fix page table traversal in setup_rt_frame()] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: s/pmd_ptr_k/pmd_off_k/ in various powerpc places] Signed-off-by: Mike Rapoport <[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]>
45 lines
1.0 KiB
C
45 lines
1.0 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* fixmaps for parisc
|
|
*
|
|
* Copyright (c) 2019 Sven Schnelle <[email protected]>
|
|
*/
|
|
|
|
#include <linux/kprobes.h>
|
|
#include <linux/mm.h>
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/fixmap.h>
|
|
|
|
void notrace set_fixmap(enum fixed_addresses idx, phys_addr_t phys)
|
|
{
|
|
unsigned long vaddr = __fix_to_virt(idx);
|
|
pgd_t *pgd = pgd_offset_k(vaddr);
|
|
p4d_t *p4d = p4d_offset(pgd, vaddr);
|
|
pud_t *pud = pud_offset(p4d, vaddr);
|
|
pmd_t *pmd = pmd_offset(pud, vaddr);
|
|
pte_t *pte;
|
|
|
|
if (pmd_none(*pmd))
|
|
pmd = pmd_alloc(NULL, pud, vaddr);
|
|
|
|
pte = pte_offset_kernel(pmd, vaddr);
|
|
if (pte_none(*pte))
|
|
pte = pte_alloc_kernel(pmd, vaddr);
|
|
|
|
set_pte_at(&init_mm, vaddr, pte, __mk_pte(phys, PAGE_KERNEL_RWX));
|
|
flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
|
|
}
|
|
|
|
void notrace clear_fixmap(enum fixed_addresses idx)
|
|
{
|
|
unsigned long vaddr = __fix_to_virt(idx);
|
|
pte_t *pte = virt_to_kpte(vaddr);
|
|
|
|
if (WARN_ON(pte_none(*pte)))
|
|
return;
|
|
|
|
pte_clear(&init_mm, vaddr, pte);
|
|
|
|
flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
|
|
}
|