~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sparc/mm/highmem.c

Version: ~ [ linux-5.19-rc5 ] ~ [ linux-5.18.9 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.52 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.128 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.203 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.250 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.286 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.320 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  *  highmem.c: virtual kernel memory mappings for high memory
  4  *
  5  *  Provides kernel-static versions of atomic kmap functions originally
  6  *  found as inlines in include/asm-sparc/highmem.h.  These became
  7  *  needed as kmap_atomic() and kunmap_atomic() started getting
  8  *  called from within modules.
  9  *  -- Tomas Szepe <szepe@pinerecords.com>, September 2002
 10  *
 11  *  But kmap_atomic() and kunmap_atomic() cannot be inlined in
 12  *  modules because they are loaded with btfixup-ped functions.
 13  */
 14 
 15 /*
 16  * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
 17  * gives a more generic (and caching) interface. But kmap_atomic can
 18  * be used in IRQ contexts, so in some (very limited) cases we need it.
 19  *
 20  * XXX This is an old text. Actually, it's good to use atomic kmaps,
 21  * provided you remember that they are atomic and not try to sleep
 22  * with a kmap taken, much like a spinlock. Non-atomic kmaps are
 23  * shared by CPUs, and so precious, and establishing them requires IPI.
 24  * Atomic kmaps are lightweight and we may have NCPUS more of them.
 25  */
 26 #include <linux/highmem.h>
 27 #include <linux/export.h>
 28 #include <linux/mm.h>
 29 
 30 #include <asm/cacheflush.h>
 31 #include <asm/tlbflush.h>
 32 #include <asm/pgalloc.h>
 33 #include <asm/vaddrs.h>
 34 
 35 static pte_t *kmap_pte;
 36 
 37 void __init kmap_init(void)
 38 {
 39         unsigned long address = __fix_to_virt(FIX_KMAP_BEGIN);
 40 
 41         /* cache the first kmap pte */
 42         kmap_pte = virt_to_kpte(address);
 43 }
 44 
 45 void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
 46 {
 47         unsigned long vaddr;
 48         long idx, type;
 49 
 50         type = kmap_atomic_idx_push();
 51         idx = type + KM_TYPE_NR*smp_processor_id();
 52         vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
 53 
 54 /* XXX Fix - Anton */
 55 #if 0
 56         __flush_cache_one(vaddr);
 57 #else
 58         flush_cache_all();
 59 #endif
 60 
 61 #ifdef CONFIG_DEBUG_HIGHMEM
 62         BUG_ON(!pte_none(*(kmap_pte-idx)));
 63 #endif
 64         set_pte(kmap_pte-idx, mk_pte(page, prot));
 65 /* XXX Fix - Anton */
 66 #if 0
 67         __flush_tlb_one(vaddr);
 68 #else
 69         flush_tlb_all();
 70 #endif
 71 
 72         return (void*) vaddr;
 73 }
 74 EXPORT_SYMBOL(kmap_atomic_high_prot);
 75 
 76 void kunmap_atomic_high(void *kvaddr)
 77 {
 78         unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
 79         int type;
 80 
 81         if (vaddr < FIXADDR_START)
 82                 return;
 83 
 84         type = kmap_atomic_idx();
 85 
 86 #ifdef CONFIG_DEBUG_HIGHMEM
 87         {
 88                 unsigned long idx;
 89 
 90                 idx = type + KM_TYPE_NR * smp_processor_id();
 91                 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx));
 92 
 93                 /* XXX Fix - Anton */
 94 #if 0
 95                 __flush_cache_one(vaddr);
 96 #else
 97                 flush_cache_all();
 98 #endif
 99 
100                 /*
101                  * force other mappings to Oops if they'll try to access
102                  * this pte without first remap it
103                  */
104                 pte_clear(&init_mm, vaddr, kmap_pte-idx);
105                 /* XXX Fix - Anton */
106 #if 0
107                 __flush_tlb_one(vaddr);
108 #else
109                 flush_tlb_all();
110 #endif
111         }
112 #endif
113 
114         kmap_atomic_idx_pop();
115 }
116 EXPORT_SYMBOL(kunmap_atomic_high);
117 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp