aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/mm/fixmap.c
diff options
context:
space:
mode:
authorSven Schnelle <svens@stackframe.org>2019-04-04 21:14:08 +0200
committerHelge Deller <deller@gmx.de>2019-05-03 23:47:38 +0200
commitccfbc68d41c2db8f5e88128427fb5bfe3855ff9b (patch)
tree836e66257a79c236cfc6b3a1a6d1f6e377102c40 /arch/parisc/mm/fixmap.c
parent17d9822d4b4c1bfeb14971d9a2639698e7f5b1eb (diff)
downloadkernel_replicant_linux-ccfbc68d41c2db8f5e88128427fb5bfe3855ff9b.tar.gz
kernel_replicant_linux-ccfbc68d41c2db8f5e88128427fb5bfe3855ff9b.tar.bz2
kernel_replicant_linux-ccfbc68d41c2db8f5e88128427fb5bfe3855ff9b.zip
parisc: add set_fixmap()/clear_fixmap()
These functions will be used for adding code patching functions later. Signed-off-by: Sven Schnelle <svens@stackframe.org> Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'arch/parisc/mm/fixmap.c')
-rw-r--r--arch/parisc/mm/fixmap.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/parisc/mm/fixmap.c b/arch/parisc/mm/fixmap.c
new file mode 100644
index 000000000000..c8d41b54fb19
--- /dev/null
+++ b/arch/parisc/mm/fixmap.c
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * fixmaps for parisc
+ *
+ * Copyright (c) 2019 Sven Schnelle <svens@stackframe.org>
+ */
+
+#include <linux/kprobes.h>
+#include <linux/mm.h>
+#include <asm/cacheflush.h>
+#include <asm/fixmap.h>
+
+void set_fixmap(enum fixed_addresses idx, phys_addr_t phys)
+{
+ unsigned long vaddr = __fix_to_virt(idx);
+ pgd_t *pgd = pgd_offset_k(vaddr);
+ pmd_t *pmd = pmd_offset(pgd, vaddr);
+ pte_t *pte;
+
+ if (pmd_none(*pmd))
+ pmd = pmd_alloc(NULL, pgd, 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 clear_fixmap(enum fixed_addresses idx)
+{
+ unsigned long vaddr = __fix_to_virt(idx);
+ pgd_t *pgd = pgd_offset_k(vaddr);
+ pmd_t *pmd = pmd_offset(pgd, vaddr);
+ pte_t *pte = pte_offset_kernel(pmd, vaddr);
+
+ pte_clear(&init_mm, vaddr, pte);
+
+ flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
+}