Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sven Schnelle and committed by
Helge Deller
ccfbc68d 17d9822d

+69 -7
+18 -1
arch/parisc/include/asm/fixmap.h
··· 15 15 * from areas congruently mapped with user space. It is 8MB large 16 16 * and must be 16MB aligned */ 17 17 #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) 18 21 /* This is the kernel area for all maps (vmalloc, dma etc.) most 19 22 * usually, it extends up to TMPALIAS_MAP_START. Virtual addresses 20 23 * 0..GATEWAY_PAGE_SIZE are reserved for the gateway page */ 21 24 #define KERNEL_MAP_START (GATEWAY_PAGE_SIZE) 22 - #define KERNEL_MAP_END (TMPALIAS_MAP_START) 25 + #define KERNEL_MAP_END (FIXMAP_START) 23 26 24 27 #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 + 25 36 extern void *parisc_vmalloc_start; 26 37 #define PCXL_DMA_MAP_SIZE (8*1024*1024) 27 38 #define VMALLOC_START ((unsigned long)parisc_vmalloc_start) 28 39 #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 + 29 46 #endif /*__ASSEMBLY__*/ 30 47 31 48 #endif /*_ASM_FIXMAP_H*/
+1 -1
arch/parisc/mm/Makefile
··· 2 2 # Makefile for arch/parisc/mm 3 3 # 4 4 5 - obj-y := init.o fault.o ioremap.o 5 + obj-y := init.o fault.o ioremap.o fixmap.o 6 6 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
+41
arch/parisc/mm/fixmap.c
··· 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 + }
+9 -5
arch/parisc/mm/init.c
··· 622 622 * But keep code for debugging purposes. 623 623 */ 624 624 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", 630 631 631 632 (void*)VMALLOC_START, (void*)VMALLOC_END, 632 633 (VMALLOC_END - VMALLOC_START) >> 20, 634 + 635 + (void *)FIXMAP_START, (void *)(FIXMAP_START + FIXMAP_SIZE), 636 + (unsigned long)(FIXMAP_SIZE / 1024), 633 637 634 638 __va(0), high_memory, 635 639 ((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,