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

microblaze/mm/highmem: Switch to generic kmap atomic

No reason having the same code in every architecture.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20201103095857.777445435@linutronix.de

+8 -88
+1
arch/microblaze/Kconfig
··· 155 155 config HIGHMEM 156 156 bool "High memory support" 157 157 depends on MMU 158 + select KMAP_LOCAL 158 159 help 159 160 The address space of Microblaze processors is only 4 Gigabytes large 160 161 and it has to accommodate user address space, kernel address
+2 -2
arch/microblaze/include/asm/fixmap.h
··· 20 20 #include <asm/page.h> 21 21 #ifdef CONFIG_HIGHMEM 22 22 #include <linux/threads.h> 23 - #include <asm/kmap_types.h> 23 + #include <asm/kmap_size.h> 24 24 #endif 25 25 26 26 #define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) ··· 47 47 FIX_HOLE, 48 48 #ifdef CONFIG_HIGHMEM 49 49 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 50 - FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * num_possible_cpus()) - 1, 50 + FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * num_possible_cpus()) - 1, 51 51 #endif 52 52 __end_of_fixed_addresses 53 53 };
+5 -1
arch/microblaze/include/asm/highmem.h
··· 25 25 #include <linux/uaccess.h> 26 26 #include <asm/fixmap.h> 27 27 28 - extern pte_t *kmap_pte; 29 28 extern pte_t *pkmap_page_table; 30 29 31 30 /* ··· 50 51 #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 51 52 52 53 #define flush_cache_kmaps() { flush_icache(); flush_dcache(); } 54 + 55 + #define arch_kmap_local_post_map(vaddr, pteval) \ 56 + local_flush_tlb_page(NULL, vaddr); 57 + #define arch_kmap_local_post_unmap(vaddr) \ 58 + local_flush_tlb_page(NULL, vaddr); 53 59 54 60 #endif /* __KERNEL__ */ 55 61
-1
arch/microblaze/mm/Makefile
··· 6 6 obj-y := consistent.o init.o 7 7 8 8 obj-$(CONFIG_MMU) += pgtable.o mmu_context.o fault.o 9 - obj-$(CONFIG_HIGHMEM) += highmem.o
-78
arch/microblaze/mm/highmem.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * highmem.c: virtual kernel memory mappings for high memory 4 - * 5 - * PowerPC version, stolen from the i386 version. 6 - * 7 - * Used in CONFIG_HIGHMEM systems for memory pages which 8 - * are not addressable by direct kernel virtual addresses. 9 - * 10 - * Copyright (C) 1999 Gerhard Wichert, Siemens AG 11 - * Gerhard.Wichert@pdb.siemens.de 12 - * 13 - * 14 - * Redesigned the x86 32-bit VM architecture to deal with 15 - * up to 16 Terrabyte physical memory. With current x86 CPUs 16 - * we now support up to 64 Gigabytes physical RAM. 17 - * 18 - * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> 19 - * 20 - * Reworked for PowerPC by various contributors. Moved from 21 - * highmem.h by Benjamin Herrenschmidt (c) 2009 IBM Corp. 22 - */ 23 - 24 - #include <linux/export.h> 25 - #include <linux/highmem.h> 26 - 27 - /* 28 - * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap 29 - * gives a more generic (and caching) interface. But kmap_atomic can 30 - * be used in IRQ contexts, so in some (very limited) cases we need 31 - * it. 32 - */ 33 - #include <asm/tlbflush.h> 34 - 35 - void *kmap_atomic_high_prot(struct page *page, pgprot_t prot) 36 - { 37 - 38 - unsigned long vaddr; 39 - int idx, type; 40 - 41 - type = kmap_atomic_idx_push(); 42 - idx = type + KM_TYPE_NR*smp_processor_id(); 43 - vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 44 - #ifdef CONFIG_DEBUG_HIGHMEM 45 - BUG_ON(!pte_none(*(kmap_pte-idx))); 46 - #endif 47 - set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot)); 48 - local_flush_tlb_page(NULL, vaddr); 49 - 50 - return (void *) vaddr; 51 - } 52 - EXPORT_SYMBOL(kmap_atomic_high_prot); 53 - 54 - void kunmap_atomic_high(void *kvaddr) 55 - { 56 - unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 57 - int type; 58 - unsigned int idx; 59 - 60 - if (vaddr < __fix_to_virt(FIX_KMAP_END)) 61 - return; 62 - 63 - type = kmap_atomic_idx(); 64 - 65 - idx = type + KM_TYPE_NR * smp_processor_id(); 66 - #ifdef CONFIG_DEBUG_HIGHMEM 67 - BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); 68 - #endif 69 - /* 70 - * force other mappings to Oops if they'll try to access 71 - * this pte without first remap it 72 - */ 73 - pte_clear(&init_mm, vaddr, kmap_pte-idx); 74 - local_flush_tlb_page(NULL, vaddr); 75 - 76 - kmap_atomic_idx_pop(); 77 - } 78 - EXPORT_SYMBOL(kunmap_atomic_high);
-6
arch/microblaze/mm/init.c
··· 49 49 EXPORT_SYMBOL(min_low_pfn); 50 50 EXPORT_SYMBOL(max_low_pfn); 51 51 52 - #ifdef CONFIG_HIGHMEM 53 - pte_t *kmap_pte; 54 - EXPORT_SYMBOL(kmap_pte); 55 - 56 52 static void __init highmem_init(void) 57 53 { 58 54 pr_debug("%x\n", (u32)PKMAP_BASE); 59 55 map_page(PKMAP_BASE, 0, 0); /* XXX gross */ 60 56 pkmap_page_table = virt_to_kpte(PKMAP_BASE); 61 - 62 - kmap_pte = virt_to_kpte(__fix_to_virt(FIX_KMAP_BEGIN)); 63 57 } 64 58 65 59 static void highmem_setup(void)