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>
This commit is contained in:
parent
17d9822d4b
commit
ccfbc68d41
|
@ -15,17 +15,34 @@
|
|||
* from areas congruently mapped with user space. It is 8MB large
|
||||
* and must be 16MB aligned */
|
||||
#define TMPALIAS_MAP_START ((__PAGE_OFFSET) - 16*1024*1024)
|
||||
|
||||
#define FIXMAP_SIZE (FIX_BITMAP_COUNT << PAGE_SHIFT)
|
||||
#define FIXMAP_START (TMPALIAS_MAP_START - FIXMAP_SIZE)
|
||||
/* This is the kernel area for all maps (vmalloc, dma etc.) most
|
||||
* usually, it extends up to TMPALIAS_MAP_START. Virtual addresses
|
||||
* 0..GATEWAY_PAGE_SIZE are reserved for the gateway page */
|
||||
#define KERNEL_MAP_START (GATEWAY_PAGE_SIZE)
|
||||
#define KERNEL_MAP_END (TMPALIAS_MAP_START)
|
||||
#define KERNEL_MAP_END (FIXMAP_START)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
|
||||
enum fixed_addresses {
|
||||
/* Support writing RO kernel text via kprobes, jump labels, etc. */
|
||||
FIX_TEXT_POKE0,
|
||||
FIX_BITMAP_COUNT
|
||||
};
|
||||
|
||||
extern void *parisc_vmalloc_start;
|
||||
#define PCXL_DMA_MAP_SIZE (8*1024*1024)
|
||||
#define VMALLOC_START ((unsigned long)parisc_vmalloc_start)
|
||||
#define VMALLOC_END (KERNEL_MAP_END)
|
||||
|
||||
#define __fix_to_virt(_x) (FIXMAP_START + ((_x) << PAGE_SHIFT))
|
||||
|
||||
void set_fixmap(enum fixed_addresses idx, phys_addr_t phys);
|
||||
void clear_fixmap(enum fixed_addresses idx);
|
||||
|
||||
#endif /*__ASSEMBLY__*/
|
||||
|
||||
#endif /*_ASM_FIXMAP_H*/
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
# Makefile for arch/parisc/mm
|
||||
#
|
||||
|
||||
obj-y := init.o fault.o ioremap.o
|
||||
obj-y := init.o fault.o ioremap.o fixmap.o
|
||||
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -622,15 +622,19 @@ void __init mem_init(void)
|
|||
* But keep code for debugging purposes.
|
||||
*/
|
||||
printk("virtual kernel memory layout:\n"
|
||||
" vmalloc : 0x%px - 0x%px (%4ld MB)\n"
|
||||
" memory : 0x%px - 0x%px (%4ld MB)\n"
|
||||
" .init : 0x%px - 0x%px (%4ld kB)\n"
|
||||
" .data : 0x%px - 0x%px (%4ld kB)\n"
|
||||
" .text : 0x%px - 0x%px (%4ld kB)\n",
|
||||
" vmalloc : 0x%px - 0x%px (%4ld MB)\n"
|
||||
" fixmap : 0x%px - 0x%px (%4ld kB)\n"
|
||||
" memory : 0x%px - 0x%px (%4ld MB)\n"
|
||||
" .init : 0x%px - 0x%px (%4ld kB)\n"
|
||||
" .data : 0x%px - 0x%px (%4ld kB)\n"
|
||||
" .text : 0x%px - 0x%px (%4ld kB)\n",
|
||||
|
||||
(void*)VMALLOC_START, (void*)VMALLOC_END,
|
||||
(VMALLOC_END - VMALLOC_START) >> 20,
|
||||
|
||||
(void *)FIXMAP_START, (void *)(FIXMAP_START + FIXMAP_SIZE),
|
||||
(unsigned long)(FIXMAP_SIZE / 1024),
|
||||
|
||||
__va(0), high_memory,
|
||||
((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
|
||||
|
||||
|
|
Loading…
Reference in New Issue