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

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

Version: ~ [ linux-6.0 ] ~ [ linux-5.19.12 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.71 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.146 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.215 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.260 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.295 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.330 ] ~ [ 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  * 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/highmem.h>
 25 #include <linux/module.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 void *kmap_atomic_prot(struct page *page, pgprot_t prot)
 34 {
 35         unsigned long vaddr;
 36         int idx, type;
 37 
 38         preempt_disable();
 39         pagefault_disable();
 40         if (!PageHighMem(page))
 41                 return page_address(page);
 42 
 43         type = kmap_atomic_idx_push();
 44         idx = type + KM_TYPE_NR*smp_processor_id();
 45         vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
 46 #ifdef CONFIG_DEBUG_HIGHMEM
 47         BUG_ON(!pte_none(*(kmap_pte-idx)));
 48 #endif
 49         __set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot), 1);
 50         local_flush_tlb_page(NULL, vaddr);
 51 
 52         return (void*) vaddr;
 53 }
 54 EXPORT_SYMBOL(kmap_atomic_prot);
 55 
 56 void __kunmap_atomic(void *kvaddr)
 57 {
 58         unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
 59         int type;
 60 
 61         if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
 62                 pagefault_enable();
 63                 preempt_enable();
 64                 return;
 65         }
 66 
 67         type = kmap_atomic_idx();
 68 
 69 #ifdef CONFIG_DEBUG_HIGHMEM
 70         {
 71                 unsigned int idx;
 72 
 73                 idx = type + KM_TYPE_NR * smp_processor_id();
 74                 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
 75 
 76                 /*
 77                  * force other mappings to Oops if they'll try to access
 78                  * this pte without first remap it
 79                  */
 80                 pte_clear(&init_mm, vaddr, kmap_pte-idx);
 81                 local_flush_tlb_page(NULL, vaddr);
 82         }
 83 #endif
 84 
 85         kmap_atomic_idx_pop();
 86         pagefault_enable();
 87         preempt_enable();
 88 }
 89 EXPORT_SYMBOL(__kunmap_atomic);
 90 

~ [ 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