1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * fixmaps for parisc
4 *
5 * Copyright (c) 2019 Sven Schnelle <svens@stackframe.org>
6 */
7
8 #include <linux/kprobes.h>
9 #include <linux/mm.h>
10 #include <asm/cacheflush.h>
11 #include <asm/fixmap.h>
12
set_fixmap(enum fixed_addresses idx,phys_addr_t phys)13 void notrace set_fixmap(enum fixed_addresses idx, phys_addr_t phys)
14 {
15 unsigned long vaddr = __fix_to_virt(idx);
16 pgd_t *pgd = pgd_offset_k(vaddr);
17 pmd_t *pmd = pmd_offset(pgd, vaddr);
18 pte_t *pte;
19
20 if (pmd_none(*pmd))
21 pmd = pmd_alloc(NULL, pgd, vaddr);
22
23 pte = pte_offset_kernel(pmd, vaddr);
24 if (pte_none(*pte))
25 pte = pte_alloc_kernel(pmd, vaddr);
26
27 set_pte_at(&init_mm, vaddr, pte, __mk_pte(phys, PAGE_KERNEL_RWX));
28 flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
29 }
30
clear_fixmap(enum fixed_addresses idx)31 void notrace clear_fixmap(enum fixed_addresses idx)
32 {
33 unsigned long vaddr = __fix_to_virt(idx);
34 pgd_t *pgd = pgd_offset_k(vaddr);
35 pmd_t *pmd = pmd_offset(pgd, vaddr);
36 pte_t *pte = pte_offset_kernel(pmd, vaddr);
37
38 if (WARN_ON(pte_none(*pte)))
39 return;
40
41 pte_clear(&init_mm, vaddr, pte);
42
43 flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
44 }
45