Linux 4.1.18
[linux/fpc-iii.git] / arch / microblaze / mm / highmem.c
blob5a92576fad927127eb05fbe24833b57e18ba7155
1 /*
2 * highmem.c: virtual kernel memory mappings for high memory
4 * PowerPC version, stolen from the i386 version.
6 * Used in CONFIG_HIGHMEM systems for memory pages which
7 * are not addressable by direct kernel virtual addresses.
9 * Copyright (C) 1999 Gerhard Wichert, Siemens AG
10 * Gerhard.Wichert@pdb.siemens.de
13 * Redesigned the x86 32-bit VM architecture to deal with
14 * up to 16 Terrabyte physical memory. With current x86 CPUs
15 * we now support up to 64 Gigabytes physical RAM.
17 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
19 * Reworked for PowerPC by various contributors. Moved from
20 * highmem.h by Benjamin Herrenschmidt (c) 2009 IBM Corp.
23 #include <linux/export.h>
24 #include <linux/highmem.h>
27 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
28 * gives a more generic (and caching) interface. But kmap_atomic can
29 * be used in IRQ contexts, so in some (very limited) cases we need
30 * it.
32 #include <asm/tlbflush.h>
34 void *kmap_atomic_prot(struct page *page, pgprot_t prot)
37 unsigned long vaddr;
38 int idx, type;
40 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
41 pagefault_disable();
42 if (!PageHighMem(page))
43 return page_address(page);
46 type = kmap_atomic_idx_push();
47 idx = type + KM_TYPE_NR*smp_processor_id();
48 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
49 #ifdef CONFIG_DEBUG_HIGHMEM
50 BUG_ON(!pte_none(*(kmap_pte-idx)));
51 #endif
52 set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot));
53 local_flush_tlb_page(NULL, vaddr);
55 return (void *) vaddr;
57 EXPORT_SYMBOL(kmap_atomic_prot);
59 void __kunmap_atomic(void *kvaddr)
61 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
62 int type;
64 if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
65 pagefault_enable();
66 return;
69 type = kmap_atomic_idx();
70 #ifdef CONFIG_DEBUG_HIGHMEM
72 unsigned int idx;
74 idx = type + KM_TYPE_NR * smp_processor_id();
75 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
78 * force other mappings to Oops if they'll try to access
79 * this pte without first remap it
81 pte_clear(&init_mm, vaddr, kmap_pte-idx);
82 local_flush_tlb_page(NULL, vaddr);
84 #endif
85 kmap_atomic_idx_pop();
86 pagefault_enable();
88 EXPORT_SYMBOL(__kunmap_atomic);