Skip to content

Commit ccfbc68

Browse files
Sven Schnellehdeller
authored andcommitted
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>
1 parent 17d9822 commit ccfbc68

4 files changed

Lines changed: 69 additions & 7 deletions

File tree

‎arch/parisc/include/asm/fixmap.h‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,34 @@
1515
* from areas congruently mapped with user space. It is 8MB large
1616
* and must be 16MB aligned */
1717
#define TMPALIAS_MAP_START ((__PAGE_OFFSET) - 16*1024*1024)
18+
19+
#define FIXMAP_SIZE (FIX_BITMAP_COUNT << PAGE_SHIFT)
20+
#define FIXMAP_START (TMPALIAS_MAP_START - FIXMAP_SIZE)
1821
/* This is the kernel area for all maps (vmalloc, dma etc.) most
1922
* usually, it extends up to TMPALIAS_MAP_START. Virtual addresses
2023
* 0..GATEWAY_PAGE_SIZE are reserved for the gateway page */
2124
#define KERNEL_MAP_START (GATEWAY_PAGE_SIZE)
22-
#define KERNEL_MAP_END (TMPALIAS_MAP_START)
25+
#define KERNEL_MAP_END (FIXMAP_START)
2326

2427
#ifndef __ASSEMBLY__
28+
29+
30+
enum fixed_addresses {
31+
/* Support writing RO kernel text via kprobes, jump labels, etc. */
32+
FIX_TEXT_POKE0,
33+
FIX_BITMAP_COUNT
34+
};
35+
2536
extern void *parisc_vmalloc_start;
2637
#define PCXL_DMA_MAP_SIZE (8*1024*1024)
2738
#define VMALLOC_START ((unsigned long)parisc_vmalloc_start)
2839
#define VMALLOC_END (KERNEL_MAP_END)
40+
41+
#define __fix_to_virt(_x) (FIXMAP_START + ((_x) << PAGE_SHIFT))
42+
43+
void set_fixmap(enum fixed_addresses idx, phys_addr_t phys);
44+
void clear_fixmap(enum fixed_addresses idx);
45+
2946
#endif /*__ASSEMBLY__*/
3047

3148
#endif /*_ASM_FIXMAP_H*/

‎arch/parisc/mm/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# Makefile for arch/parisc/mm
33
#
44

5-
obj-y := init.o fault.o ioremap.o
5+
obj-y := init.o fault.o ioremap.o fixmap.o
66
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o

‎arch/parisc/mm/fixmap.c‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
13+
void 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+
31+
void 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+
pte_clear(&init_mm, vaddr, pte);
39+
40+
flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
41+
}

‎arch/parisc/mm/init.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,15 +622,19 @@ void __init mem_init(void)
622622
* But keep code for debugging purposes.
623623
*/
624624
printk("virtual kernel memory layout:\n"
625-
" vmalloc : 0x%px - 0x%px (%4ld MB)\n"
626-
" memory : 0x%px - 0x%px (%4ld MB)\n"
627-
" .init : 0x%px - 0x%px (%4ld kB)\n"
628-
" .data : 0x%px - 0x%px (%4ld kB)\n"
629-
" .text : 0x%px - 0x%px (%4ld kB)\n",
625+
" vmalloc : 0x%px - 0x%px (%4ld MB)\n"
626+
" fixmap : 0x%px - 0x%px (%4ld kB)\n"
627+
" memory : 0x%px - 0x%px (%4ld MB)\n"
628+
" .init : 0x%px - 0x%px (%4ld kB)\n"
629+
" .data : 0x%px - 0x%px (%4ld kB)\n"
630+
" .text : 0x%px - 0x%px (%4ld kB)\n",
630631

631632
(void*)VMALLOC_START, (void*)VMALLOC_END,
632633
(VMALLOC_END - VMALLOC_START) >> 20,
633634

635+
(void *)FIXMAP_START, (void *)(FIXMAP_START + FIXMAP_SIZE),
636+
(unsigned long)(FIXMAP_SIZE / 1024),
637+
634638
__va(0), high_memory,
635639
((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
636640

0 commit comments

Comments
 (0)