diff options
author | Paul Mackerras <paulus@samba.org> | 2005-10-10 07:58:35 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-10 07:58:35 -0400 |
commit | ab1f9dac6eea25ee59e4c8e1cf0b7476afbbfe07 (patch) | |
tree | 03577652197b5e58c348ede3c474bc8dd47e046c /arch | |
parent | 70d64ceaa1a84d2502405422a4dfd3f87786a347 (diff) |
powerpc: Merge arch/ppc64/mm to arch/powerpc/mm
This moves the remaining files in arch/ppc64/mm to arch/powerpc/mm,
and arranges that we use them when compiling with ARCH=ppc64.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/mm/Makefile | 8 | ||||
-rw-r--r-- | arch/powerpc/mm/hash_low_64.S (renamed from arch/ppc64/mm/hash_low.S) | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/hash_native_64.c (renamed from arch/ppc64/mm/hash_native.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/hash_utils_64.c (renamed from arch/ppc64/mm/hash_utils.c) | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/hugetlbpage.c (renamed from arch/ppc64/mm/hugetlbpage.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/imalloc.c (renamed from arch/ppc64/mm/imalloc.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/init_64.c | 36 | ||||
-rw-r--r-- | arch/powerpc/mm/mem.c | 11 | ||||
-rw-r--r-- | arch/powerpc/mm/mmap.c (renamed from arch/ppc64/mm/mmap.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/mmu_decl.h | 18 | ||||
-rw-r--r-- | arch/powerpc/mm/numa.c (renamed from arch/ppc64/mm/numa.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/pgtable_64.c | 34 | ||||
-rw-r--r-- | arch/powerpc/mm/slb.c (renamed from arch/ppc64/mm/slb.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/slb_low.S (renamed from arch/ppc64/mm/slb_low.S) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/stab.c (renamed from arch/ppc64/mm/stab.c) | 0 | ||||
-rw-r--r-- | arch/powerpc/mm/tlb_64.c (renamed from arch/ppc64/mm/tlb.c) | 0 | ||||
-rw-r--r-- | arch/ppc64/Makefile | 2 | ||||
-rw-r--r-- | arch/ppc64/mm/Makefile | 11 | ||||
-rw-r--r-- | arch/ppc64/mm/fault.c | 333 | ||||
-rw-r--r-- | arch/ppc64/mm/init.c | 870 |
20 files changed, 39 insertions, 1288 deletions
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index 35497deeb4b2..612bc4ec72b1 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile | |||
@@ -5,8 +5,14 @@ | |||
5 | obj-y := fault.o mem.o lmb.o | 5 | obj-y := fault.o mem.o lmb.o |
6 | obj-$(CONFIG_PPC32) += init_32.o pgtable_32.o mmu_context_32.o \ | 6 | obj-$(CONFIG_PPC32) += init_32.o pgtable_32.o mmu_context_32.o \ |
7 | tlb_32.o | 7 | tlb_32.o |
8 | obj-$(CONFIG_PPC64) += init_64.o pgtable_64.o mmu_context_64.o | 8 | hash-$(CONFIG_PPC_MULTIPLATFORM) := hash_native_64.o |
9 | obj-$(CONFIG_PPC64) += init_64.o pgtable_64.o mmu_context_64.o \ | ||
10 | hash_utils_64.o hash_low_64.o tlb_64.o \ | ||
11 | slb_low.o slb.o stab.o mmap.o imalloc.o \ | ||
12 | $(hash-y) | ||
9 | obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o | 13 | obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o |
10 | obj-$(CONFIG_40x) += 4xx_mmu.o | 14 | obj-$(CONFIG_40x) += 4xx_mmu.o |
11 | obj-$(CONFIG_44x) += 44x_mmu.o | 15 | obj-$(CONFIG_44x) += 44x_mmu.o |
12 | obj-$(CONFIG_FSL_BOOKE) += fsl_booke_mmu.o | 16 | obj-$(CONFIG_FSL_BOOKE) += fsl_booke_mmu.o |
17 | obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o | ||
18 | obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o | ||
diff --git a/arch/ppc64/mm/hash_low.S b/arch/powerpc/mm/hash_low_64.S index ee5a5d36bfa8..d6ed9102eeea 100644 --- a/arch/ppc64/mm/hash_low.S +++ b/arch/powerpc/mm/hash_low_64.S | |||
@@ -10,7 +10,7 @@ | |||
10 | * described in the kernel's COPYING file. | 10 | * described in the kernel's COPYING file. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <asm/processor.h> | 13 | #include <asm/reg.h> |
14 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
15 | #include <asm/mmu.h> | 15 | #include <asm/mmu.h> |
16 | #include <asm/page.h> | 16 | #include <asm/page.h> |
diff --git a/arch/ppc64/mm/hash_native.c b/arch/powerpc/mm/hash_native_64.c index 174d14576c28..174d14576c28 100644 --- a/arch/ppc64/mm/hash_native.c +++ b/arch/powerpc/mm/hash_native_64.c | |||
diff --git a/arch/ppc64/mm/hash_utils.c b/arch/powerpc/mm/hash_utils_64.c index 83507438d6a0..35dd93eeaf4b 100644 --- a/arch/ppc64/mm/hash_utils.c +++ b/arch/powerpc/mm/hash_utils_64.c | |||
@@ -78,7 +78,7 @@ extern unsigned long dart_tablebase; | |||
78 | hpte_t *htab_address; | 78 | hpte_t *htab_address; |
79 | unsigned long htab_hash_mask; | 79 | unsigned long htab_hash_mask; |
80 | 80 | ||
81 | extern unsigned long _SDR1; | 81 | unsigned long _SDR1; |
82 | 82 | ||
83 | #define KB (1024) | 83 | #define KB (1024) |
84 | #define MB (1024*KB) | 84 | #define MB (1024*KB) |
diff --git a/arch/ppc64/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 0ea0994ed974..0ea0994ed974 100644 --- a/arch/ppc64/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c | |||
diff --git a/arch/ppc64/mm/imalloc.c b/arch/powerpc/mm/imalloc.c index c65b87b92756..c65b87b92756 100644 --- a/arch/ppc64/mm/imalloc.c +++ b/arch/powerpc/mm/imalloc.c | |||
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c index c0ce6a7af3c7..b0fc822ec29f 100644 --- a/arch/powerpc/mm/init_64.c +++ b/arch/powerpc/mm/init_64.c | |||
@@ -73,18 +73,8 @@ | |||
73 | #warning TASK_SIZE is smaller than it needs to be. | 73 | #warning TASK_SIZE is smaller than it needs to be. |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | int mem_init_done; | ||
77 | unsigned long ioremap_bot = IMALLOC_BASE; | ||
78 | static unsigned long phbs_io_bot = PHBS_IO_BASE; | ||
79 | |||
80 | extern pgd_t swapper_pg_dir[]; | ||
81 | extern struct task_struct *current_set[NR_CPUS]; | ||
82 | |||
83 | unsigned long klimit = (unsigned long)_end; | 76 | unsigned long klimit = (unsigned long)_end; |
84 | 77 | ||
85 | unsigned long _SDR1=0; | ||
86 | unsigned long _ASR=0; | ||
87 | |||
88 | /* max amount of RAM to use */ | 78 | /* max amount of RAM to use */ |
89 | unsigned long __max_memory; | 79 | unsigned long __max_memory; |
90 | 80 | ||
@@ -193,19 +183,6 @@ static int __init setup_kcore(void) | |||
193 | } | 183 | } |
194 | module_init(setup_kcore); | 184 | module_init(setup_kcore); |
195 | 185 | ||
196 | void __iomem * reserve_phb_iospace(unsigned long size) | ||
197 | { | ||
198 | void __iomem *virt_addr; | ||
199 | |||
200 | if (phbs_io_bot >= IMALLOC_BASE) | ||
201 | panic("reserve_phb_iospace(): phb io space overflow\n"); | ||
202 | |||
203 | virt_addr = (void __iomem *) phbs_io_bot; | ||
204 | phbs_io_bot += size; | ||
205 | |||
206 | return virt_addr; | ||
207 | } | ||
208 | |||
209 | static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) | 186 | static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) |
210 | { | 187 | { |
211 | memset(addr, 0, kmem_cache_size(cache)); | 188 | memset(addr, 0, kmem_cache_size(cache)); |
@@ -244,16 +221,3 @@ void pgtable_cache_init(void) | |||
244 | name); | 221 | name); |
245 | } | 222 | } |
246 | } | 223 | } |
247 | |||
248 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long addr, | ||
249 | unsigned long size, pgprot_t vma_prot) | ||
250 | { | ||
251 | if (ppc_md.phys_mem_access_prot) | ||
252 | return ppc_md.phys_mem_access_prot(file, addr, size, vma_prot); | ||
253 | |||
254 | if (!page_is_ram(addr >> PAGE_SHIFT)) | ||
255 | vma_prot = __pgprot(pgprot_val(vma_prot) | ||
256 | | _PAGE_GUARDED | _PAGE_NO_CACHE); | ||
257 | return vma_prot; | ||
258 | } | ||
259 | EXPORT_SYMBOL(phys_mem_access_prot); | ||
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 0650de74d0b3..55b5860ed3c9 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -47,6 +47,9 @@ | |||
47 | #include <asm/prom.h> | 47 | #include <asm/prom.h> |
48 | #include <asm/lmb.h> | 48 | #include <asm/lmb.h> |
49 | #include <asm/sections.h> | 49 | #include <asm/sections.h> |
50 | #ifdef CONFIG_PPC64 | ||
51 | #include <asm/vdso.h> | ||
52 | #endif | ||
50 | 53 | ||
51 | #include "mmu_decl.h" | 54 | #include "mmu_decl.h" |
52 | 55 | ||
@@ -334,7 +337,7 @@ void flush_dcache_icache_page(struct page *page) | |||
334 | void *start = kmap_atomic(page, KM_PPC_SYNC_ICACHE); | 337 | void *start = kmap_atomic(page, KM_PPC_SYNC_ICACHE); |
335 | __flush_dcache_icache(start); | 338 | __flush_dcache_icache(start); |
336 | kunmap_atomic(start, KM_PPC_SYNC_ICACHE); | 339 | kunmap_atomic(start, KM_PPC_SYNC_ICACHE); |
337 | #elif defined(CONFIG_8xx) | 340 | #elif defined(CONFIG_8xx) || defined(CONFIG_PPC64) |
338 | /* On 8xx there is no need to kmap since highmem is not supported */ | 341 | /* On 8xx there is no need to kmap since highmem is not supported */ |
339 | __flush_dcache_icache(page_address(page)); | 342 | __flush_dcache_icache(page_address(page)); |
340 | #else | 343 | #else |
@@ -463,18 +466,18 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, | |||
463 | if (pgdir == NULL) | 466 | if (pgdir == NULL) |
464 | return; | 467 | return; |
465 | 468 | ||
466 | ptep = find_linux_pte(pgdir, ea); | 469 | ptep = find_linux_pte(pgdir, address); |
467 | if (!ptep) | 470 | if (!ptep) |
468 | return; | 471 | return; |
469 | 472 | ||
470 | vsid = get_vsid(vma->vm_mm->context.id, ea); | 473 | vsid = get_vsid(vma->vm_mm->context.id, address); |
471 | 474 | ||
472 | local_irq_save(flags); | 475 | local_irq_save(flags); |
473 | tmp = cpumask_of_cpu(smp_processor_id()); | 476 | tmp = cpumask_of_cpu(smp_processor_id()); |
474 | if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp)) | 477 | if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp)) |
475 | local = 1; | 478 | local = 1; |
476 | 479 | ||
477 | __hash_page(ea, pte_val(pte) & (_PAGE_USER|_PAGE_RW), vsid, ptep, | 480 | __hash_page(address, pte_val(pte) & (_PAGE_USER|_PAGE_RW), vsid, ptep, |
478 | 0x300, local); | 481 | 0x300, local); |
479 | local_irq_restore(flags); | 482 | local_irq_restore(flags); |
480 | #endif | 483 | #endif |
diff --git a/arch/ppc64/mm/mmap.c b/arch/powerpc/mm/mmap.c index fe65f522aff3..fe65f522aff3 100644 --- a/arch/ppc64/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c | |||
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index 06fe8af3af55..a4d7a327c0e5 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h | |||
@@ -22,11 +22,11 @@ | |||
22 | #include <asm/tlbflush.h> | 22 | #include <asm/tlbflush.h> |
23 | #include <asm/mmu.h> | 23 | #include <asm/mmu.h> |
24 | 24 | ||
25 | #ifdef CONFIG_PPC32 | ||
25 | extern void mapin_ram(void); | 26 | extern void mapin_ram(void); |
26 | extern int map_page(unsigned long va, phys_addr_t pa, int flags); | 27 | extern int map_page(unsigned long va, phys_addr_t pa, int flags); |
27 | extern void setbat(int index, unsigned long virt, unsigned long phys, | 28 | extern void setbat(int index, unsigned long virt, unsigned long phys, |
28 | unsigned int size, int flags); | 29 | unsigned int size, int flags); |
29 | extern void reserve_phys_mem(unsigned long start, unsigned long size); | ||
30 | extern void settlbcam(int index, unsigned long virt, phys_addr_t phys, | 30 | extern void settlbcam(int index, unsigned long virt, phys_addr_t phys, |
31 | unsigned int size, int flags, unsigned int pid); | 31 | unsigned int size, int flags, unsigned int pid); |
32 | extern void invalidate_tlbcam_entry(int index); | 32 | extern void invalidate_tlbcam_entry(int index); |
@@ -36,16 +36,16 @@ extern unsigned long ioremap_base; | |||
36 | extern unsigned long ioremap_bot; | 36 | extern unsigned long ioremap_bot; |
37 | extern unsigned int rtas_data, rtas_size; | 37 | extern unsigned int rtas_data, rtas_size; |
38 | 38 | ||
39 | extern unsigned long __max_low_memory; | ||
40 | extern unsigned long __initial_memory_limit; | ||
41 | extern unsigned long total_memory; | ||
42 | extern unsigned long total_lowmem; | ||
43 | extern int mem_init_done; | ||
44 | |||
45 | extern PTE *Hash, *Hash_end; | 39 | extern PTE *Hash, *Hash_end; |
46 | extern unsigned long Hash_size, Hash_mask; | 40 | extern unsigned long Hash_size, Hash_mask; |
47 | 41 | ||
48 | extern unsigned int num_tlbcam_entries; | 42 | extern unsigned int num_tlbcam_entries; |
43 | #endif | ||
44 | |||
45 | extern unsigned long __max_low_memory; | ||
46 | extern unsigned long __initial_memory_limit; | ||
47 | extern unsigned long total_memory; | ||
48 | extern unsigned long total_lowmem; | ||
49 | 49 | ||
50 | /* ...and now those things that may be slightly different between processor | 50 | /* ...and now those things that may be slightly different between processor |
51 | * architectures. -- Dan | 51 | * architectures. -- Dan |
@@ -66,8 +66,8 @@ extern void MMU_init_hw(void); | |||
66 | extern unsigned long mmu_mapin_ram(void); | 66 | extern unsigned long mmu_mapin_ram(void); |
67 | extern void adjust_total_lowmem(void); | 67 | extern void adjust_total_lowmem(void); |
68 | 68 | ||
69 | #else | 69 | #elif defined(CONFIG_PPC32) |
70 | /* anything except 4xx or 8xx */ | 70 | /* anything 32-bit except 4xx or 8xx */ |
71 | extern void MMU_init_hw(void); | 71 | extern void MMU_init_hw(void); |
72 | extern unsigned long mmu_mapin_ram(void); | 72 | extern unsigned long mmu_mapin_ram(void); |
73 | 73 | ||
diff --git a/arch/ppc64/mm/numa.c b/arch/powerpc/mm/numa.c index cb864b8f2750..cb864b8f2750 100644 --- a/arch/ppc64/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index 724f97e5dee5..484d24f9208b 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c | |||
@@ -67,30 +67,9 @@ | |||
67 | #include <asm/vdso.h> | 67 | #include <asm/vdso.h> |
68 | #include <asm/imalloc.h> | 68 | #include <asm/imalloc.h> |
69 | 69 | ||
70 | #if PGTABLE_RANGE > USER_VSID_RANGE | ||
71 | #warning Limited user VSID range means pagetable space is wasted | ||
72 | #endif | ||
73 | |||
74 | #if (TASK_SIZE_USER64 < PGTABLE_RANGE) && (TASK_SIZE_USER64 < USER_VSID_RANGE) | ||
75 | #warning TASK_SIZE is smaller than it needs to be. | ||
76 | #endif | ||
77 | |||
78 | int mem_init_done; | ||
79 | unsigned long ioremap_bot = IMALLOC_BASE; | 70 | unsigned long ioremap_bot = IMALLOC_BASE; |
80 | static unsigned long phbs_io_bot = PHBS_IO_BASE; | 71 | static unsigned long phbs_io_bot = PHBS_IO_BASE; |
81 | 72 | ||
82 | extern pgd_t swapper_pg_dir[]; | ||
83 | extern struct task_struct *current_set[NR_CPUS]; | ||
84 | |||
85 | unsigned long klimit = (unsigned long)_end; | ||
86 | |||
87 | /* max amount of RAM to use */ | ||
88 | unsigned long __max_memory; | ||
89 | |||
90 | /* info on what we think the IO hole is */ | ||
91 | unsigned long io_hole_start; | ||
92 | unsigned long io_hole_size; | ||
93 | |||
94 | #ifdef CONFIG_PPC_ISERIES | 73 | #ifdef CONFIG_PPC_ISERIES |
95 | 74 | ||
96 | void __iomem *ioremap(unsigned long addr, unsigned long size) | 75 | void __iomem *ioremap(unsigned long addr, unsigned long size) |
@@ -355,3 +334,16 @@ int iounmap_explicit(volatile void __iomem *start, unsigned long size) | |||
355 | EXPORT_SYMBOL(ioremap); | 334 | EXPORT_SYMBOL(ioremap); |
356 | EXPORT_SYMBOL(__ioremap); | 335 | EXPORT_SYMBOL(__ioremap); |
357 | EXPORT_SYMBOL(iounmap); | 336 | EXPORT_SYMBOL(iounmap); |
337 | |||
338 | void __iomem * reserve_phb_iospace(unsigned long size) | ||
339 | { | ||
340 | void __iomem *virt_addr; | ||
341 | |||
342 | if (phbs_io_bot >= IMALLOC_BASE) | ||
343 | panic("reserve_phb_iospace(): phb io space overflow\n"); | ||
344 | |||
345 | virt_addr = (void __iomem *) phbs_io_bot; | ||
346 | phbs_io_bot += size; | ||
347 | |||
348 | return virt_addr; | ||
349 | } | ||
diff --git a/arch/ppc64/mm/slb.c b/arch/powerpc/mm/slb.c index 0473953f6a37..0473953f6a37 100644 --- a/arch/ppc64/mm/slb.c +++ b/arch/powerpc/mm/slb.c | |||
diff --git a/arch/ppc64/mm/slb_low.S b/arch/powerpc/mm/slb_low.S index a3a03da503bc..a3a03da503bc 100644 --- a/arch/ppc64/mm/slb_low.S +++ b/arch/powerpc/mm/slb_low.S | |||
diff --git a/arch/ppc64/mm/stab.c b/arch/powerpc/mm/stab.c index 1b83f002bf27..1b83f002bf27 100644 --- a/arch/ppc64/mm/stab.c +++ b/arch/powerpc/mm/stab.c | |||
diff --git a/arch/ppc64/mm/tlb.c b/arch/powerpc/mm/tlb_64.c index 09ab81a10f4f..09ab81a10f4f 100644 --- a/arch/ppc64/mm/tlb.c +++ b/arch/powerpc/mm/tlb_64.c | |||
diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile index fa889204d6ae..4a9928ef3032 100644 --- a/arch/ppc64/Makefile +++ b/arch/ppc64/Makefile | |||
@@ -83,7 +83,7 @@ head-y := arch/ppc64/kernel/head.o | |||
83 | 83 | ||
84 | libs-y += arch/ppc64/lib/ | 84 | libs-y += arch/ppc64/lib/ |
85 | core-y += arch/ppc64/kernel/ arch/powerpc/kernel/ | 85 | core-y += arch/ppc64/kernel/ arch/powerpc/kernel/ |
86 | core-y += arch/ppc64/mm/ | 86 | core-y += arch/powerpc/mm/ |
87 | core-y += arch/powerpc/platforms/ | 87 | core-y += arch/powerpc/platforms/ |
88 | core-$(CONFIG_XMON) += arch/ppc64/xmon/ | 88 | core-$(CONFIG_XMON) += arch/ppc64/xmon/ |
89 | drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/ | 89 | drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/ |
diff --git a/arch/ppc64/mm/Makefile b/arch/ppc64/mm/Makefile deleted file mode 100644 index 3695d00d347f..000000000000 --- a/arch/ppc64/mm/Makefile +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for the linux ppc-specific parts of the memory manager. | ||
3 | # | ||
4 | |||
5 | EXTRA_CFLAGS += -mno-minimal-toc | ||
6 | |||
7 | obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o \ | ||
8 | slb_low.o slb.o stab.o mmap.o | ||
9 | obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o | ||
10 | obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o | ||
11 | obj-$(CONFIG_PPC_MULTIPLATFORM) += hash_native.o | ||
diff --git a/arch/ppc64/mm/fault.c b/arch/ppc64/mm/fault.c deleted file mode 100644 index be3f25cf3e9f..000000000000 --- a/arch/ppc64/mm/fault.c +++ /dev/null | |||
@@ -1,333 +0,0 @@ | |||
1 | /* | ||
2 | * arch/ppc/mm/fault.c | ||
3 | * | ||
4 | * PowerPC version | ||
5 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) | ||
6 | * | ||
7 | * Derived from "arch/i386/mm/fault.c" | ||
8 | * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds | ||
9 | * | ||
10 | * Modified by Cort Dougan and Paul Mackerras. | ||
11 | * | ||
12 | * Modified for PPC64 by Dave Engebretsen (engebret@ibm.com) | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version | ||
17 | * 2 of the License, or (at your option) any later version. | ||
18 | */ | ||
19 | |||
20 | #include <linux/config.h> | ||
21 | #include <linux/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/errno.h> | ||
25 | #include <linux/string.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/mman.h> | ||
28 | #include <linux/mm.h> | ||
29 | #include <linux/interrupt.h> | ||
30 | #include <linux/smp_lock.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/kprobes.h> | ||
33 | |||
34 | #include <asm/page.h> | ||
35 | #include <asm/pgtable.h> | ||
36 | #include <asm/mmu.h> | ||
37 | #include <asm/mmu_context.h> | ||
38 | #include <asm/system.h> | ||
39 | #include <asm/uaccess.h> | ||
40 | #include <asm/kdebug.h> | ||
41 | #include <asm/siginfo.h> | ||
42 | |||
43 | /* | ||
44 | * Check whether the instruction at regs->nip is a store using | ||
45 | * an update addressing form which will update r1. | ||
46 | */ | ||
47 | static int store_updates_sp(struct pt_regs *regs) | ||
48 | { | ||
49 | unsigned int inst; | ||
50 | |||
51 | if (get_user(inst, (unsigned int __user *)regs->nip)) | ||
52 | return 0; | ||
53 | /* check for 1 in the rA field */ | ||
54 | if (((inst >> 16) & 0x1f) != 1) | ||
55 | return 0; | ||
56 | /* check major opcode */ | ||
57 | switch (inst >> 26) { | ||
58 | case 37: /* stwu */ | ||
59 | case 39: /* stbu */ | ||
60 | case 45: /* sthu */ | ||
61 | case 53: /* stfsu */ | ||
62 | case 55: /* stfdu */ | ||
63 | return 1; | ||
64 | case 62: /* std or stdu */ | ||
65 | return (inst & 3) == 1; | ||
66 | case 31: | ||
67 | /* check minor opcode */ | ||
68 | switch ((inst >> 1) & 0x3ff) { | ||
69 | case 181: /* stdux */ | ||
70 | case 183: /* stwux */ | ||
71 | case 247: /* stbux */ | ||
72 | case 439: /* sthux */ | ||
73 | case 695: /* stfsux */ | ||
74 | case 759: /* stfdux */ | ||
75 | return 1; | ||
76 | } | ||
77 | } | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static void do_dabr(struct pt_regs *regs, unsigned long error_code) | ||
82 | { | ||
83 | siginfo_t info; | ||
84 | |||
85 | if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, | ||
86 | 11, SIGSEGV) == NOTIFY_STOP) | ||
87 | return; | ||
88 | |||
89 | if (debugger_dabr_match(regs)) | ||
90 | return; | ||
91 | |||
92 | /* Clear the DABR */ | ||
93 | set_dabr(0); | ||
94 | |||
95 | /* Deliver the signal to userspace */ | ||
96 | info.si_signo = SIGTRAP; | ||
97 | info.si_errno = 0; | ||
98 | info.si_code = TRAP_HWBKPT; | ||
99 | info.si_addr = (void __user *)regs->nip; | ||
100 | force_sig_info(SIGTRAP, &info, current); | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * The error_code parameter is | ||
105 | * - DSISR for a non-SLB data access fault, | ||
106 | * - SRR1 & 0x08000000 for a non-SLB instruction access fault | ||
107 | * - 0 any SLB fault. | ||
108 | * The return value is 0 if the fault was handled, or the signal | ||
109 | * number if this is a kernel fault that can't be handled here. | ||
110 | */ | ||
111 | int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address, | ||
112 | unsigned long error_code) | ||
113 | { | ||
114 | struct vm_area_struct * vma; | ||
115 | struct mm_struct *mm = current->mm; | ||
116 | siginfo_t info; | ||
117 | unsigned long code = SEGV_MAPERR; | ||
118 | unsigned long is_write = error_code & DSISR_ISSTORE; | ||
119 | unsigned long trap = TRAP(regs); | ||
120 | unsigned long is_exec = trap == 0x400; | ||
121 | |||
122 | BUG_ON((trap == 0x380) || (trap == 0x480)); | ||
123 | |||
124 | if (notify_die(DIE_PAGE_FAULT, "page_fault", regs, error_code, | ||
125 | 11, SIGSEGV) == NOTIFY_STOP) | ||
126 | return 0; | ||
127 | |||
128 | if (trap == 0x300) { | ||
129 | if (debugger_fault_handler(regs)) | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | /* On a kernel SLB miss we can only check for a valid exception entry */ | ||
134 | if (!user_mode(regs) && (address >= TASK_SIZE)) | ||
135 | return SIGSEGV; | ||
136 | |||
137 | if (error_code & DSISR_DABRMATCH) { | ||
138 | do_dabr(regs, error_code); | ||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | if (in_atomic() || mm == NULL) { | ||
143 | if (!user_mode(regs)) | ||
144 | return SIGSEGV; | ||
145 | /* in_atomic() in user mode is really bad, | ||
146 | as is current->mm == NULL. */ | ||
147 | printk(KERN_EMERG "Page fault in user mode with" | ||
148 | "in_atomic() = %d mm = %p\n", in_atomic(), mm); | ||
149 | printk(KERN_EMERG "NIP = %lx MSR = %lx\n", | ||
150 | regs->nip, regs->msr); | ||
151 | die("Weird page fault", regs, SIGSEGV); | ||
152 | } | ||
153 | |||
154 | /* When running in the kernel we expect faults to occur only to | ||
155 | * addresses in user space. All other faults represent errors in the | ||
156 | * kernel and should generate an OOPS. Unfortunatly, in the case of an | ||
157 | * erroneous fault occuring in a code path which already holds mmap_sem | ||
158 | * we will deadlock attempting to validate the fault against the | ||
159 | * address space. Luckily the kernel only validly references user | ||
160 | * space from well defined areas of code, which are listed in the | ||
161 | * exceptions table. | ||
162 | * | ||
163 | * As the vast majority of faults will be valid we will only perform | ||
164 | * the source reference check when there is a possibilty of a deadlock. | ||
165 | * Attempt to lock the address space, if we cannot we then validate the | ||
166 | * source. If this is invalid we can skip the address space check, | ||
167 | * thus avoiding the deadlock. | ||
168 | */ | ||
169 | if (!down_read_trylock(&mm->mmap_sem)) { | ||
170 | if (!user_mode(regs) && !search_exception_tables(regs->nip)) | ||
171 | goto bad_area_nosemaphore; | ||
172 | |||
173 | down_read(&mm->mmap_sem); | ||
174 | } | ||
175 | |||
176 | vma = find_vma(mm, address); | ||
177 | if (!vma) | ||
178 | goto bad_area; | ||
179 | |||
180 | if (vma->vm_start <= address) { | ||
181 | goto good_area; | ||
182 | } | ||
183 | if (!(vma->vm_flags & VM_GROWSDOWN)) | ||
184 | goto bad_area; | ||
185 | |||
186 | /* | ||
187 | * N.B. The POWER/Open ABI allows programs to access up to | ||
188 | * 288 bytes below the stack pointer. | ||
189 | * The kernel signal delivery code writes up to about 1.5kB | ||
190 | * below the stack pointer (r1) before decrementing it. | ||
191 | * The exec code can write slightly over 640kB to the stack | ||
192 | * before setting the user r1. Thus we allow the stack to | ||
193 | * expand to 1MB without further checks. | ||
194 | */ | ||
195 | if (address + 0x100000 < vma->vm_end) { | ||
196 | /* get user regs even if this fault is in kernel mode */ | ||
197 | struct pt_regs *uregs = current->thread.regs; | ||
198 | if (uregs == NULL) | ||
199 | goto bad_area; | ||
200 | |||
201 | /* | ||
202 | * A user-mode access to an address a long way below | ||
203 | * the stack pointer is only valid if the instruction | ||
204 | * is one which would update the stack pointer to the | ||
205 | * address accessed if the instruction completed, | ||
206 | * i.e. either stwu rs,n(r1) or stwux rs,r1,rb | ||
207 | * (or the byte, halfword, float or double forms). | ||
208 | * | ||
209 | * If we don't check this then any write to the area | ||
210 | * between the last mapped region and the stack will | ||
211 | * expand the stack rather than segfaulting. | ||
212 | */ | ||
213 | if (address + 2048 < uregs->gpr[1] | ||
214 | && (!user_mode(regs) || !store_updates_sp(regs))) | ||
215 | goto bad_area; | ||
216 | } | ||
217 | |||
218 | if (expand_stack(vma, address)) | ||
219 | goto bad_area; | ||
220 | |||
221 | good_area: | ||
222 | code = SEGV_ACCERR; | ||
223 | |||
224 | if (is_exec) { | ||
225 | /* protection fault */ | ||
226 | if (error_code & DSISR_PROTFAULT) | ||
227 | goto bad_area; | ||
228 | if (!(vma->vm_flags & VM_EXEC)) | ||
229 | goto bad_area; | ||
230 | /* a write */ | ||
231 | } else if (is_write) { | ||
232 | if (!(vma->vm_flags & VM_WRITE)) | ||
233 | goto bad_area; | ||
234 | /* a read */ | ||
235 | } else { | ||
236 | if (!(vma->vm_flags & VM_READ)) | ||
237 | goto bad_area; | ||
238 | } | ||
239 | |||
240 | survive: | ||
241 | /* | ||
242 | * If for any reason at all we couldn't handle the fault, | ||
243 | * make sure we exit gracefully rather than endlessly redo | ||
244 | * the fault. | ||
245 | */ | ||
246 | switch (handle_mm_fault(mm, vma, address, is_write)) { | ||
247 | |||
248 | case VM_FAULT_MINOR: | ||
249 | current->min_flt++; | ||
250 | break; | ||
251 | case VM_FAULT_MAJOR: | ||
252 | current->maj_flt++; | ||
253 | break; | ||
254 | case VM_FAULT_SIGBUS: | ||
255 | goto do_sigbus; | ||
256 | case VM_FAULT_OOM: | ||
257 | goto out_of_memory; | ||
258 | default: | ||
259 | BUG(); | ||
260 | } | ||
261 | |||
262 | up_read(&mm->mmap_sem); | ||
263 | return 0; | ||
264 | |||
265 | bad_area: | ||
266 | up_read(&mm->mmap_sem); | ||
267 | |||
268 | bad_area_nosemaphore: | ||
269 | /* User mode accesses cause a SIGSEGV */ | ||
270 | if (user_mode(regs)) { | ||
271 | info.si_signo = SIGSEGV; | ||
272 | info.si_errno = 0; | ||
273 | info.si_code = code; | ||
274 | info.si_addr = (void __user *) address; | ||
275 | force_sig_info(SIGSEGV, &info, current); | ||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | if (trap == 0x400 && (error_code & DSISR_PROTFAULT) | ||
280 | && printk_ratelimit()) | ||
281 | printk(KERN_CRIT "kernel tried to execute NX-protected" | ||
282 | " page (%lx) - exploit attempt? (uid: %d)\n", | ||
283 | address, current->uid); | ||
284 | |||
285 | return SIGSEGV; | ||
286 | |||
287 | /* | ||
288 | * We ran out of memory, or some other thing happened to us that made | ||
289 | * us unable to handle the page fault gracefully. | ||
290 | */ | ||
291 | out_of_memory: | ||
292 | up_read(&mm->mmap_sem); | ||
293 | if (current->pid == 1) { | ||
294 | yield(); | ||
295 | down_read(&mm->mmap_sem); | ||
296 | goto survive; | ||
297 | } | ||
298 | printk("VM: killing process %s\n", current->comm); | ||
299 | if (user_mode(regs)) | ||
300 | do_exit(SIGKILL); | ||
301 | return SIGKILL; | ||
302 | |||
303 | do_sigbus: | ||
304 | up_read(&mm->mmap_sem); | ||
305 | if (user_mode(regs)) { | ||
306 | info.si_signo = SIGBUS; | ||
307 | info.si_errno = 0; | ||
308 | info.si_code = BUS_ADRERR; | ||
309 | info.si_addr = (void __user *)address; | ||
310 | force_sig_info(SIGBUS, &info, current); | ||
311 | return 0; | ||
312 | } | ||
313 | return SIGBUS; | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * bad_page_fault is called when we have a bad access from the kernel. | ||
318 | * It is called from do_page_fault above and from some of the procedures | ||
319 | * in traps.c. | ||
320 | */ | ||
321 | void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) | ||
322 | { | ||
323 | const struct exception_table_entry *entry; | ||
324 | |||
325 | /* Are we prepared to handle this fault? */ | ||
326 | if ((entry = search_exception_tables(regs->nip)) != NULL) { | ||
327 | regs->nip = entry->fixup; | ||
328 | return; | ||
329 | } | ||
330 | |||
331 | /* kernel has accessed a bad area */ | ||
332 | die("Kernel access of bad area", regs, sig); | ||
333 | } | ||
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c deleted file mode 100644 index c2157c9c3acb..000000000000 --- a/arch/ppc64/mm/init.c +++ /dev/null | |||
@@ -1,870 +0,0 @@ | |||
1 | /* | ||
2 | * PowerPC version | ||
3 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) | ||
4 | * | ||
5 | * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au) | ||
6 | * and Cort Dougan (PReP) (cort@cs.nmt.edu) | ||
7 | * Copyright (C) 1996 Paul Mackerras | ||
8 | * Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk). | ||
9 | * | ||
10 | * Derived from "arch/i386/mm/init.c" | ||
11 | * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds | ||
12 | * | ||
13 | * Dave Engebretsen <engebret@us.ibm.com> | ||
14 | * Rework for PPC64 port. | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License | ||
18 | * as published by the Free Software Foundation; either version | ||
19 | * 2 of the License, or (at your option) any later version. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | #include <linux/signal.h> | ||
25 | #include <linux/sched.h> | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/string.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/mman.h> | ||
31 | #include <linux/mm.h> | ||
32 | #include <linux/swap.h> | ||
33 | #include <linux/stddef.h> | ||
34 | #include <linux/vmalloc.h> | ||
35 | #include <linux/init.h> | ||
36 | #include <linux/delay.h> | ||
37 | #include <linux/bootmem.h> | ||
38 | #include <linux/highmem.h> | ||
39 | #include <linux/idr.h> | ||
40 | #include <linux/nodemask.h> | ||
41 | #include <linux/module.h> | ||
42 | |||
43 | #include <asm/pgalloc.h> | ||
44 | #include <asm/page.h> | ||
45 | #include <asm/prom.h> | ||
46 | #include <asm/lmb.h> | ||
47 | #include <asm/rtas.h> | ||
48 | #include <asm/io.h> | ||
49 | #include <asm/mmu_context.h> | ||
50 | #include <asm/pgtable.h> | ||
51 | #include <asm/mmu.h> | ||
52 | #include <asm/uaccess.h> | ||
53 | #include <asm/smp.h> | ||
54 | #include <asm/machdep.h> | ||
55 | #include <asm/tlb.h> | ||
56 | #include <asm/eeh.h> | ||
57 | #include <asm/processor.h> | ||
58 | #include <asm/mmzone.h> | ||
59 | #include <asm/cputable.h> | ||
60 | #include <asm/ppcdebug.h> | ||
61 | #include <asm/sections.h> | ||
62 | #include <asm/system.h> | ||
63 | #include <asm/iommu.h> | ||
64 | #include <asm/abs_addr.h> | ||
65 | #include <asm/vdso.h> | ||
66 | #include <asm/imalloc.h> | ||
67 | |||
68 | #if PGTABLE_RANGE > USER_VSID_RANGE | ||
69 | #warning Limited user VSID range means pagetable space is wasted | ||
70 | #endif | ||
71 | |||
72 | #if (TASK_SIZE_USER64 < PGTABLE_RANGE) && (TASK_SIZE_USER64 < USER_VSID_RANGE) | ||
73 | #warning TASK_SIZE is smaller than it needs to be. | ||
74 | #endif | ||
75 | |||
76 | int mem_init_done; | ||
77 | unsigned long ioremap_bot = IMALLOC_BASE; | ||
78 | static unsigned long phbs_io_bot = PHBS_IO_BASE; | ||
79 | |||
80 | extern pgd_t swapper_pg_dir[]; | ||
81 | extern struct task_struct *current_set[NR_CPUS]; | ||
82 | |||
83 | unsigned long klimit = (unsigned long)_end; | ||
84 | |||
85 | unsigned long _SDR1=0; | ||
86 | unsigned long _ASR=0; | ||
87 | |||
88 | /* max amount of RAM to use */ | ||
89 | unsigned long __max_memory; | ||
90 | |||
91 | /* info on what we think the IO hole is */ | ||
92 | unsigned long io_hole_start; | ||
93 | unsigned long io_hole_size; | ||
94 | |||
95 | void show_mem(void) | ||
96 | { | ||
97 | unsigned long total = 0, reserved = 0; | ||
98 | unsigned long shared = 0, cached = 0; | ||
99 | struct page *page; | ||
100 | pg_data_t *pgdat; | ||
101 | unsigned long i; | ||
102 | |||
103 | printk("Mem-info:\n"); | ||
104 | show_free_areas(); | ||
105 | printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); | ||
106 | for_each_pgdat(pgdat) { | ||
107 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | ||
108 | page = pgdat_page_nr(pgdat, i); | ||
109 | total++; | ||
110 | if (PageReserved(page)) | ||
111 | reserved++; | ||
112 | else if (PageSwapCache(page)) | ||
113 | cached++; | ||
114 | else if (page_count(page)) | ||
115 | shared += page_count(page) - 1; | ||
116 | } | ||
117 | } | ||
118 | printk("%ld pages of RAM\n", total); | ||
119 | printk("%ld reserved pages\n", reserved); | ||
120 | printk("%ld pages shared\n", shared); | ||
121 | printk("%ld pages swap cached\n", cached); | ||
122 | } | ||
123 | |||
124 | #ifdef CONFIG_PPC_ISERIES | ||
125 | |||
126 | void __iomem *ioremap(unsigned long addr, unsigned long size) | ||
127 | { | ||
128 | return (void __iomem *)addr; | ||
129 | } | ||
130 | |||
131 | extern void __iomem *__ioremap(unsigned long addr, unsigned long size, | ||
132 | unsigned long flags) | ||
133 | { | ||
134 | return (void __iomem *)addr; | ||
135 | } | ||
136 | |||
137 | void iounmap(volatile void __iomem *addr) | ||
138 | { | ||
139 | return; | ||
140 | } | ||
141 | |||
142 | #else | ||
143 | |||
144 | /* | ||
145 | * map_io_page currently only called by __ioremap | ||
146 | * map_io_page adds an entry to the ioremap page table | ||
147 | * and adds an entry to the HPT, possibly bolting it | ||
148 | */ | ||
149 | static int map_io_page(unsigned long ea, unsigned long pa, int flags) | ||
150 | { | ||
151 | pgd_t *pgdp; | ||
152 | pud_t *pudp; | ||
153 | pmd_t *pmdp; | ||
154 | pte_t *ptep; | ||
155 | unsigned long vsid; | ||
156 | |||
157 | if (mem_init_done) { | ||
158 | spin_lock(&init_mm.page_table_lock); | ||
159 | pgdp = pgd_offset_k(ea); | ||
160 | pudp = pud_alloc(&init_mm, pgdp, ea); | ||
161 | if (!pudp) | ||
162 | return -ENOMEM; | ||
163 | pmdp = pmd_alloc(&init_mm, pudp, ea); | ||
164 | if (!pmdp) | ||
165 | return -ENOMEM; | ||
166 | ptep = pte_alloc_kernel(&init_mm, pmdp, ea); | ||
167 | if (!ptep) | ||
168 | return -ENOMEM; | ||
169 | set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, | ||
170 | __pgprot(flags))); | ||
171 | spin_unlock(&init_mm.page_table_lock); | ||
172 | } else { | ||
173 | unsigned long va, vpn, hash, hpteg; | ||
174 | |||
175 | /* | ||
176 | * If the mm subsystem is not fully up, we cannot create a | ||
177 | * linux page table entry for this mapping. Simply bolt an | ||
178 | * entry in the hardware page table. | ||
179 | */ | ||
180 | vsid = get_kernel_vsid(ea); | ||
181 | va = (vsid << 28) | (ea & 0xFFFFFFF); | ||
182 | vpn = va >> PAGE_SHIFT; | ||
183 | |||
184 | hash = hpt_hash(vpn, 0); | ||
185 | |||
186 | hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); | ||
187 | |||
188 | /* Panic if a pte grpup is full */ | ||
189 | if (ppc_md.hpte_insert(hpteg, va, pa >> PAGE_SHIFT, | ||
190 | HPTE_V_BOLTED, | ||
191 | _PAGE_NO_CACHE|_PAGE_GUARDED|PP_RWXX) | ||
192 | == -1) { | ||
193 | panic("map_io_page: could not insert mapping"); | ||
194 | } | ||
195 | } | ||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | |||
200 | static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa, | ||
201 | unsigned long ea, unsigned long size, | ||
202 | unsigned long flags) | ||
203 | { | ||
204 | unsigned long i; | ||
205 | |||
206 | if ((flags & _PAGE_PRESENT) == 0) | ||
207 | flags |= pgprot_val(PAGE_KERNEL); | ||
208 | |||
209 | for (i = 0; i < size; i += PAGE_SIZE) | ||
210 | if (map_io_page(ea+i, pa+i, flags)) | ||
211 | return NULL; | ||
212 | |||
213 | return (void __iomem *) (ea + (addr & ~PAGE_MASK)); | ||
214 | } | ||
215 | |||
216 | |||
217 | void __iomem * | ||
218 | ioremap(unsigned long addr, unsigned long size) | ||
219 | { | ||
220 | return __ioremap(addr, size, _PAGE_NO_CACHE | _PAGE_GUARDED); | ||
221 | } | ||
222 | |||
223 | void __iomem * __ioremap(unsigned long addr, unsigned long size, | ||
224 | unsigned long flags) | ||
225 | { | ||
226 | unsigned long pa, ea; | ||
227 | void __iomem *ret; | ||
228 | |||
229 | /* | ||
230 | * Choose an address to map it to. | ||
231 | * Once the imalloc system is running, we use it. | ||
232 | * Before that, we map using addresses going | ||
233 | * up from ioremap_bot. imalloc will use | ||
234 | * the addresses from ioremap_bot through | ||
235 | * IMALLOC_END | ||
236 | * | ||
237 | */ | ||
238 | pa = addr & PAGE_MASK; | ||
239 | size = PAGE_ALIGN(addr + size) - pa; | ||
240 | |||
241 | if (size == 0) | ||
242 | return NULL; | ||
243 | |||
244 | if (mem_init_done) { | ||
245 | struct vm_struct *area; | ||
246 | area = im_get_free_area(size); | ||
247 | if (area == NULL) | ||
248 | return NULL; | ||
249 | ea = (unsigned long)(area->addr); | ||
250 | ret = __ioremap_com(addr, pa, ea, size, flags); | ||
251 | if (!ret) | ||
252 | im_free(area->addr); | ||
253 | } else { | ||
254 | ea = ioremap_bot; | ||
255 | ret = __ioremap_com(addr, pa, ea, size, flags); | ||
256 | if (ret) | ||
257 | ioremap_bot += size; | ||
258 | } | ||
259 | return ret; | ||
260 | } | ||
261 | |||
262 | #define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK)) | ||
263 | |||
264 | int __ioremap_explicit(unsigned long pa, unsigned long ea, | ||
265 | unsigned long size, unsigned long flags) | ||
266 | { | ||
267 | struct vm_struct *area; | ||
268 | void __iomem *ret; | ||
269 | |||
270 | /* For now, require page-aligned values for pa, ea, and size */ | ||
271 | if (!IS_PAGE_ALIGNED(pa) || !IS_PAGE_ALIGNED(ea) || | ||
272 | !IS_PAGE_ALIGNED(size)) { | ||
273 | printk(KERN_ERR "unaligned value in %s\n", __FUNCTION__); | ||
274 | return 1; | ||
275 | } | ||
276 | |||
277 | if (!mem_init_done) { | ||
278 | /* Two things to consider in this case: | ||
279 | * 1) No records will be kept (imalloc, etc) that the region | ||
280 | * has been remapped | ||
281 | * 2) It won't be easy to iounmap() the region later (because | ||
282 | * of 1) | ||
283 | */ | ||
284 | ; | ||
285 | } else { | ||
286 | area = im_get_area(ea, size, | ||
287 | IM_REGION_UNUSED|IM_REGION_SUBSET|IM_REGION_EXISTS); | ||
288 | if (area == NULL) { | ||
289 | /* Expected when PHB-dlpar is in play */ | ||
290 | return 1; | ||
291 | } | ||
292 | if (ea != (unsigned long) area->addr) { | ||
293 | printk(KERN_ERR "unexpected addr return from " | ||
294 | "im_get_area\n"); | ||
295 | return 1; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | ret = __ioremap_com(pa, pa, ea, size, flags); | ||
300 | if (ret == NULL) { | ||
301 | printk(KERN_ERR "ioremap_explicit() allocation failure !\n"); | ||
302 | return 1; | ||
303 | } | ||
304 | if (ret != (void *) ea) { | ||
305 | printk(KERN_ERR "__ioremap_com() returned unexpected addr\n"); | ||
306 | return 1; | ||
307 | } | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | /* | ||
313 | * Unmap an IO region and remove it from imalloc'd list. | ||
314 | * Access to IO memory should be serialized by driver. | ||
315 | * This code is modeled after vmalloc code - unmap_vm_area() | ||
316 | * | ||
317 | * XXX what about calls before mem_init_done (ie python_countermeasures()) | ||
318 | */ | ||
319 | void iounmap(volatile void __iomem *token) | ||
320 | { | ||
321 | void *addr; | ||
322 | |||
323 | if (!mem_init_done) | ||
324 | return; | ||
325 | |||
326 | addr = (void *) ((unsigned long __force) token & PAGE_MASK); | ||
327 | |||
328 | im_free(addr); | ||
329 | } | ||
330 | |||
331 | static int iounmap_subset_regions(unsigned long addr, unsigned long size) | ||
332 | { | ||
333 | struct vm_struct *area; | ||
334 | |||
335 | /* Check whether subsets of this region exist */ | ||
336 | area = im_get_area(addr, size, IM_REGION_SUPERSET); | ||
337 | if (area == NULL) | ||
338 | return 1; | ||
339 | |||
340 | while (area) { | ||
341 | iounmap((void __iomem *) area->addr); | ||
342 | area = im_get_area(addr, size, | ||
343 | IM_REGION_SUPERSET); | ||
344 | } | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | int iounmap_explicit(volatile void __iomem *start, unsigned long size) | ||
350 | { | ||
351 | struct vm_struct *area; | ||
352 | unsigned long addr; | ||
353 | int rc; | ||
354 | |||
355 | addr = (unsigned long __force) start & PAGE_MASK; | ||
356 | |||
357 | /* Verify that the region either exists or is a subset of an existing | ||
358 | * region. In the latter case, split the parent region to create | ||
359 | * the exact region | ||
360 | */ | ||
361 | area = im_get_area(addr, size, | ||
362 | IM_REGION_EXISTS | IM_REGION_SUBSET); | ||
363 | if (area == NULL) { | ||
364 | /* Determine whether subset regions exist. If so, unmap */ | ||
365 | rc = iounmap_subset_regions(addr, size); | ||
366 | if (rc) { | ||
367 | printk(KERN_ERR | ||
368 | "%s() cannot unmap nonexistent range 0x%lx\n", | ||
369 | __FUNCTION__, addr); | ||
370 | return 1; | ||
371 | } | ||
372 | } else { | ||
373 | iounmap((void __iomem *) area->addr); | ||
374 | } | ||
375 | /* | ||
376 | * FIXME! This can't be right: | ||
377 | iounmap(area->addr); | ||
378 | * Maybe it should be "iounmap(area);" | ||
379 | */ | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | #endif | ||
384 | |||
385 | EXPORT_SYMBOL(ioremap); | ||
386 | EXPORT_SYMBOL(__ioremap); | ||
387 | EXPORT_SYMBOL(iounmap); | ||
388 | |||
389 | void free_initmem(void) | ||
390 | { | ||
391 | unsigned long addr; | ||
392 | |||
393 | addr = (unsigned long)__init_begin; | ||
394 | for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) { | ||
395 | memset((void *)addr, 0xcc, PAGE_SIZE); | ||
396 | ClearPageReserved(virt_to_page(addr)); | ||
397 | set_page_count(virt_to_page(addr), 1); | ||
398 | free_page(addr); | ||
399 | totalram_pages++; | ||
400 | } | ||
401 | printk ("Freeing unused kernel memory: %luk freed\n", | ||
402 | ((unsigned long)__init_end - (unsigned long)__init_begin) >> 10); | ||
403 | } | ||
404 | |||
405 | #ifdef CONFIG_BLK_DEV_INITRD | ||
406 | void free_initrd_mem(unsigned long start, unsigned long end) | ||
407 | { | ||
408 | if (start < end) | ||
409 | printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); | ||
410 | for (; start < end; start += PAGE_SIZE) { | ||
411 | ClearPageReserved(virt_to_page(start)); | ||
412 | set_page_count(virt_to_page(start), 1); | ||
413 | free_page(start); | ||
414 | totalram_pages++; | ||
415 | } | ||
416 | } | ||
417 | #endif | ||
418 | |||
419 | static DEFINE_SPINLOCK(mmu_context_lock); | ||
420 | static DEFINE_IDR(mmu_context_idr); | ||
421 | |||
422 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm) | ||
423 | { | ||
424 | int index; | ||
425 | int err; | ||
426 | |||
427 | again: | ||
428 | if (!idr_pre_get(&mmu_context_idr, GFP_KERNEL)) | ||
429 | return -ENOMEM; | ||
430 | |||
431 | spin_lock(&mmu_context_lock); | ||
432 | err = idr_get_new_above(&mmu_context_idr, NULL, 1, &index); | ||
433 | spin_unlock(&mmu_context_lock); | ||
434 | |||
435 | if (err == -EAGAIN) | ||
436 | goto again; | ||
437 | else if (err) | ||
438 | return err; | ||
439 | |||
440 | if (index > MAX_CONTEXT) { | ||
441 | idr_remove(&mmu_context_idr, index); | ||
442 | return -ENOMEM; | ||
443 | } | ||
444 | |||
445 | mm->context.id = index; | ||
446 | |||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | void destroy_context(struct mm_struct *mm) | ||
451 | { | ||
452 | spin_lock(&mmu_context_lock); | ||
453 | idr_remove(&mmu_context_idr, mm->context.id); | ||
454 | spin_unlock(&mmu_context_lock); | ||
455 | |||
456 | mm->context.id = NO_CONTEXT; | ||
457 | } | ||
458 | |||
459 | /* | ||
460 | * Do very early mm setup. | ||
461 | */ | ||
462 | void __init mm_init_ppc64(void) | ||
463 | { | ||
464 | #ifndef CONFIG_PPC_ISERIES | ||
465 | unsigned long i; | ||
466 | #endif | ||
467 | |||
468 | ppc64_boot_msg(0x100, "MM Init"); | ||
469 | |||
470 | /* This is the story of the IO hole... please, keep seated, | ||
471 | * unfortunately, we are out of oxygen masks at the moment. | ||
472 | * So we need some rough way to tell where your big IO hole | ||
473 | * is. On pmac, it's between 2G and 4G, on POWER3, it's around | ||
474 | * that area as well, on POWER4 we don't have one, etc... | ||
475 | * We need that as a "hint" when sizing the TCE table on POWER3 | ||
476 | * So far, the simplest way that seem work well enough for us it | ||
477 | * to just assume that the first discontinuity in our physical | ||
478 | * RAM layout is the IO hole. That may not be correct in the future | ||
479 | * (and isn't on iSeries but then we don't care ;) | ||
480 | */ | ||
481 | |||
482 | #ifndef CONFIG_PPC_ISERIES | ||
483 | for (i = 1; i < lmb.memory.cnt; i++) { | ||
484 | unsigned long base, prevbase, prevsize; | ||
485 | |||
486 | prevbase = lmb.memory.region[i-1].base; | ||
487 | prevsize = lmb.memory.region[i-1].size; | ||
488 | base = lmb.memory.region[i].base; | ||
489 | if (base > (prevbase + prevsize)) { | ||
490 | io_hole_start = prevbase + prevsize; | ||
491 | io_hole_size = base - (prevbase + prevsize); | ||
492 | break; | ||
493 | } | ||
494 | } | ||
495 | #endif /* CONFIG_PPC_ISERIES */ | ||
496 | if (io_hole_start) | ||
497 | printk("IO Hole assumed to be %lx -> %lx\n", | ||
498 | io_hole_start, io_hole_start + io_hole_size - 1); | ||
499 | |||
500 | ppc64_boot_msg(0x100, "MM Init Done"); | ||
501 | } | ||
502 | |||
503 | /* | ||
504 | * This is called by /dev/mem to know if a given address has to | ||
505 | * be mapped non-cacheable or not | ||
506 | */ | ||
507 | int page_is_ram(unsigned long pfn) | ||
508 | { | ||
509 | int i; | ||
510 | unsigned long paddr = (pfn << PAGE_SHIFT); | ||
511 | |||
512 | for (i=0; i < lmb.memory.cnt; i++) { | ||
513 | unsigned long base; | ||
514 | |||
515 | base = lmb.memory.region[i].base; | ||
516 | |||
517 | if ((paddr >= base) && | ||
518 | (paddr < (base + lmb.memory.region[i].size))) { | ||
519 | return 1; | ||
520 | } | ||
521 | } | ||
522 | |||
523 | return 0; | ||
524 | } | ||
525 | EXPORT_SYMBOL(page_is_ram); | ||
526 | |||
527 | /* | ||
528 | * Initialize the bootmem system and give it all the memory we | ||
529 | * have available. | ||
530 | */ | ||
531 | #ifndef CONFIG_NEED_MULTIPLE_NODES | ||
532 | void __init do_init_bootmem(void) | ||
533 | { | ||
534 | unsigned long i; | ||
535 | unsigned long start, bootmap_pages; | ||
536 | unsigned long total_pages = lmb_end_of_DRAM() >> PAGE_SHIFT; | ||
537 | int boot_mapsize; | ||
538 | |||
539 | /* | ||
540 | * Find an area to use for the bootmem bitmap. Calculate the size of | ||
541 | * bitmap required as (Total Memory) / PAGE_SIZE / BITS_PER_BYTE. | ||
542 | * Add 1 additional page in case the address isn't page-aligned. | ||
543 | */ | ||
544 | bootmap_pages = bootmem_bootmap_pages(total_pages); | ||
545 | |||
546 | start = lmb_alloc(bootmap_pages<<PAGE_SHIFT, PAGE_SIZE); | ||
547 | BUG_ON(!start); | ||
548 | |||
549 | boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages); | ||
550 | |||
551 | max_pfn = max_low_pfn; | ||
552 | |||
553 | /* Add all physical memory to the bootmem map, mark each area | ||
554 | * present. | ||
555 | */ | ||
556 | for (i=0; i < lmb.memory.cnt; i++) | ||
557 | free_bootmem(lmb.memory.region[i].base, | ||
558 | lmb_size_bytes(&lmb.memory, i)); | ||
559 | |||
560 | /* reserve the sections we're already using */ | ||
561 | for (i=0; i < lmb.reserved.cnt; i++) | ||
562 | reserve_bootmem(lmb.reserved.region[i].base, | ||
563 | lmb_size_bytes(&lmb.reserved, i)); | ||
564 | |||
565 | for (i=0; i < lmb.memory.cnt; i++) | ||
566 | memory_present(0, lmb_start_pfn(&lmb.memory, i), | ||
567 | lmb_end_pfn(&lmb.memory, i)); | ||
568 | } | ||
569 | |||
570 | /* | ||
571 | * paging_init() sets up the page tables - in fact we've already done this. | ||
572 | */ | ||
573 | void __init paging_init(void) | ||
574 | { | ||
575 | unsigned long zones_size[MAX_NR_ZONES]; | ||
576 | unsigned long zholes_size[MAX_NR_ZONES]; | ||
577 | unsigned long total_ram = lmb_phys_mem_size(); | ||
578 | unsigned long top_of_ram = lmb_end_of_DRAM(); | ||
579 | |||
580 | printk(KERN_INFO "Top of RAM: 0x%lx, Total RAM: 0x%lx\n", | ||
581 | top_of_ram, total_ram); | ||
582 | printk(KERN_INFO "Memory hole size: %ldMB\n", | ||
583 | (top_of_ram - total_ram) >> 20); | ||
584 | /* | ||
585 | * All pages are DMA-able so we put them all in the DMA zone. | ||
586 | */ | ||
587 | memset(zones_size, 0, sizeof(zones_size)); | ||
588 | memset(zholes_size, 0, sizeof(zholes_size)); | ||
589 | |||
590 | zones_size[ZONE_DMA] = top_of_ram >> PAGE_SHIFT; | ||
591 | zholes_size[ZONE_DMA] = (top_of_ram - total_ram) >> PAGE_SHIFT; | ||
592 | |||
593 | free_area_init_node(0, NODE_DATA(0), zones_size, | ||
594 | __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size); | ||
595 | } | ||
596 | #endif /* ! CONFIG_NEED_MULTIPLE_NODES */ | ||
597 | |||
598 | static struct kcore_list kcore_vmem; | ||
599 | |||
600 | static int __init setup_kcore(void) | ||
601 | { | ||
602 | int i; | ||
603 | |||
604 | for (i=0; i < lmb.memory.cnt; i++) { | ||
605 | unsigned long base, size; | ||
606 | struct kcore_list *kcore_mem; | ||
607 | |||
608 | base = lmb.memory.region[i].base; | ||
609 | size = lmb.memory.region[i].size; | ||
610 | |||
611 | /* GFP_ATOMIC to avoid might_sleep warnings during boot */ | ||
612 | kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC); | ||
613 | if (!kcore_mem) | ||
614 | panic("mem_init: kmalloc failed\n"); | ||
615 | |||
616 | kclist_add(kcore_mem, __va(base), size); | ||
617 | } | ||
618 | |||
619 | kclist_add(&kcore_vmem, (void *)VMALLOC_START, VMALLOC_END-VMALLOC_START); | ||
620 | |||
621 | return 0; | ||
622 | } | ||
623 | module_init(setup_kcore); | ||
624 | |||
625 | void __init mem_init(void) | ||
626 | { | ||
627 | #ifdef CONFIG_NEED_MULTIPLE_NODES | ||
628 | int nid; | ||
629 | #endif | ||
630 | pg_data_t *pgdat; | ||
631 | unsigned long i; | ||
632 | struct page *page; | ||
633 | unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize; | ||
634 | |||
635 | num_physpages = max_low_pfn; /* RAM is assumed contiguous */ | ||
636 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); | ||
637 | |||
638 | #ifdef CONFIG_NEED_MULTIPLE_NODES | ||
639 | for_each_online_node(nid) { | ||
640 | if (NODE_DATA(nid)->node_spanned_pages != 0) { | ||
641 | printk("freeing bootmem node %x\n", nid); | ||
642 | totalram_pages += | ||
643 | free_all_bootmem_node(NODE_DATA(nid)); | ||
644 | } | ||
645 | } | ||
646 | #else | ||
647 | max_mapnr = num_physpages; | ||
648 | totalram_pages += free_all_bootmem(); | ||
649 | #endif | ||
650 | |||
651 | for_each_pgdat(pgdat) { | ||
652 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | ||
653 | page = pgdat_page_nr(pgdat, i); | ||
654 | if (PageReserved(page)) | ||
655 | reservedpages++; | ||
656 | } | ||
657 | } | ||
658 | |||
659 | codesize = (unsigned long)&_etext - (unsigned long)&_stext; | ||
660 | initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin; | ||
661 | datasize = (unsigned long)&_edata - (unsigned long)&__init_end; | ||
662 | bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start; | ||
663 | |||
664 | printk(KERN_INFO "Memory: %luk/%luk available (%luk kernel code, " | ||
665 | "%luk reserved, %luk data, %luk bss, %luk init)\n", | ||
666 | (unsigned long)nr_free_pages() << (PAGE_SHIFT-10), | ||
667 | num_physpages << (PAGE_SHIFT-10), | ||
668 | codesize >> 10, | ||
669 | reservedpages << (PAGE_SHIFT-10), | ||
670 | datasize >> 10, | ||
671 | bsssize >> 10, | ||
672 | initsize >> 10); | ||
673 | |||
674 | mem_init_done = 1; | ||
675 | |||
676 | /* Initialize the vDSO */ | ||
677 | vdso_init(); | ||
678 | } | ||
679 | |||
680 | /* | ||
681 | * This is called when a page has been modified by the kernel. | ||
682 | * It just marks the page as not i-cache clean. We do the i-cache | ||
683 | * flush later when the page is given to a user process, if necessary. | ||
684 | */ | ||
685 | void flush_dcache_page(struct page *page) | ||
686 | { | ||
687 | if (cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) | ||
688 | return; | ||
689 | /* avoid an atomic op if possible */ | ||
690 | if (test_bit(PG_arch_1, &page->flags)) | ||
691 | clear_bit(PG_arch_1, &page->flags); | ||
692 | } | ||
693 | EXPORT_SYMBOL(flush_dcache_page); | ||
694 | |||
695 | void clear_user_page(void *page, unsigned long vaddr, struct page *pg) | ||
696 | { | ||
697 | clear_page(page); | ||
698 | |||
699 | if (cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) | ||
700 | return; | ||
701 | /* | ||
702 | * We shouldnt have to do this, but some versions of glibc | ||
703 | * require it (ld.so assumes zero filled pages are icache clean) | ||
704 | * - Anton | ||
705 | */ | ||
706 | |||
707 | /* avoid an atomic op if possible */ | ||
708 | if (test_bit(PG_arch_1, &pg->flags)) | ||
709 | clear_bit(PG_arch_1, &pg->flags); | ||
710 | } | ||
711 | EXPORT_SYMBOL(clear_user_page); | ||
712 | |||
713 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, | ||
714 | struct page *pg) | ||
715 | { | ||
716 | copy_page(vto, vfrom); | ||
717 | |||
718 | /* | ||
719 | * We should be able to use the following optimisation, however | ||
720 | * there are two problems. | ||
721 | * Firstly a bug in some versions of binutils meant PLT sections | ||
722 | * were not marked executable. | ||
723 | * Secondly the first word in the GOT section is blrl, used | ||
724 | * to establish the GOT address. Until recently the GOT was | ||
725 | * not marked executable. | ||
726 | * - Anton | ||
727 | */ | ||
728 | #if 0 | ||
729 | if (!vma->vm_file && ((vma->vm_flags & VM_EXEC) == 0)) | ||
730 | return; | ||
731 | #endif | ||
732 | |||
733 | if (cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) | ||
734 | return; | ||
735 | |||
736 | /* avoid an atomic op if possible */ | ||
737 | if (test_bit(PG_arch_1, &pg->flags)) | ||
738 | clear_bit(PG_arch_1, &pg->flags); | ||
739 | } | ||
740 | |||
741 | void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, | ||
742 | unsigned long addr, int len) | ||
743 | { | ||
744 | unsigned long maddr; | ||
745 | |||
746 | maddr = (unsigned long)page_address(page) + (addr & ~PAGE_MASK); | ||
747 | flush_icache_range(maddr, maddr + len); | ||
748 | } | ||
749 | EXPORT_SYMBOL(flush_icache_user_range); | ||
750 | |||
751 | /* | ||
752 | * This is called at the end of handling a user page fault, when the | ||
753 | * fault has been handled by updating a PTE in the linux page tables. | ||
754 | * We use it to preload an HPTE into the hash table corresponding to | ||
755 | * the updated linux PTE. | ||
756 | * | ||
757 | * This must always be called with the mm->page_table_lock held | ||
758 | */ | ||
759 | void update_mmu_cache(struct vm_area_struct *vma, unsigned long ea, | ||
760 | pte_t pte) | ||
761 | { | ||
762 | unsigned long vsid; | ||
763 | void *pgdir; | ||
764 | pte_t *ptep; | ||
765 | int local = 0; | ||
766 | cpumask_t tmp; | ||
767 | unsigned long flags; | ||
768 | |||
769 | /* handle i-cache coherency */ | ||
770 | if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE) && | ||
771 | !cpu_has_feature(CPU_FTR_NOEXECUTE)) { | ||
772 | unsigned long pfn = pte_pfn(pte); | ||
773 | if (pfn_valid(pfn)) { | ||
774 | struct page *page = pfn_to_page(pfn); | ||
775 | if (!PageReserved(page) | ||
776 | && !test_bit(PG_arch_1, &page->flags)) { | ||
777 | __flush_dcache_icache(page_address(page)); | ||
778 | set_bit(PG_arch_1, &page->flags); | ||
779 | } | ||
780 | } | ||
781 | } | ||
782 | |||
783 | /* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */ | ||
784 | if (!pte_young(pte)) | ||
785 | return; | ||
786 | |||
787 | pgdir = vma->vm_mm->pgd; | ||
788 | if (pgdir == NULL) | ||
789 | return; | ||
790 | |||
791 | ptep = find_linux_pte(pgdir, ea); | ||
792 | if (!ptep) | ||
793 | return; | ||
794 | |||
795 | vsid = get_vsid(vma->vm_mm->context.id, ea); | ||
796 | |||
797 | local_irq_save(flags); | ||
798 | tmp = cpumask_of_cpu(smp_processor_id()); | ||
799 | if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp)) | ||
800 | local = 1; | ||
801 | |||
802 | __hash_page(ea, pte_val(pte) & (_PAGE_USER|_PAGE_RW), vsid, ptep, | ||
803 | 0x300, local); | ||
804 | local_irq_restore(flags); | ||
805 | } | ||
806 | |||
807 | void __iomem * reserve_phb_iospace(unsigned long size) | ||
808 | { | ||
809 | void __iomem *virt_addr; | ||
810 | |||
811 | if (phbs_io_bot >= IMALLOC_BASE) | ||
812 | panic("reserve_phb_iospace(): phb io space overflow\n"); | ||
813 | |||
814 | virt_addr = (void __iomem *) phbs_io_bot; | ||
815 | phbs_io_bot += size; | ||
816 | |||
817 | return virt_addr; | ||
818 | } | ||
819 | |||
820 | static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) | ||
821 | { | ||
822 | memset(addr, 0, kmem_cache_size(cache)); | ||
823 | } | ||
824 | |||
825 | static const int pgtable_cache_size[2] = { | ||
826 | PTE_TABLE_SIZE, PMD_TABLE_SIZE | ||
827 | }; | ||
828 | static const char *pgtable_cache_name[ARRAY_SIZE(pgtable_cache_size)] = { | ||
829 | "pgd_pte_cache", "pud_pmd_cache", | ||
830 | }; | ||
831 | |||
832 | kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)]; | ||
833 | |||
834 | void pgtable_cache_init(void) | ||
835 | { | ||
836 | int i; | ||
837 | |||
838 | BUILD_BUG_ON(PTE_TABLE_SIZE != pgtable_cache_size[PTE_CACHE_NUM]); | ||
839 | BUILD_BUG_ON(PMD_TABLE_SIZE != pgtable_cache_size[PMD_CACHE_NUM]); | ||
840 | BUILD_BUG_ON(PUD_TABLE_SIZE != pgtable_cache_size[PUD_CACHE_NUM]); | ||
841 | BUILD_BUG_ON(PGD_TABLE_SIZE != pgtable_cache_size[PGD_CACHE_NUM]); | ||
842 | |||
843 | for (i = 0; i < ARRAY_SIZE(pgtable_cache_size); i++) { | ||
844 | int size = pgtable_cache_size[i]; | ||
845 | const char *name = pgtable_cache_name[i]; | ||
846 | |||
847 | pgtable_cache[i] = kmem_cache_create(name, | ||
848 | size, size, | ||
849 | SLAB_HWCACHE_ALIGN | ||
850 | | SLAB_MUST_HWCACHE_ALIGN, | ||
851 | zero_ctor, | ||
852 | NULL); | ||
853 | if (! pgtable_cache[i]) | ||
854 | panic("pgtable_cache_init(): could not create %s!\n", | ||
855 | name); | ||
856 | } | ||
857 | } | ||
858 | |||
859 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long addr, | ||
860 | unsigned long size, pgprot_t vma_prot) | ||
861 | { | ||
862 | if (ppc_md.phys_mem_access_prot) | ||
863 | return ppc_md.phys_mem_access_prot(file, addr, size, vma_prot); | ||
864 | |||
865 | if (!page_is_ram(addr >> PAGE_SHIFT)) | ||
866 | vma_prot = __pgprot(pgprot_val(vma_prot) | ||
867 | | _PAGE_GUARDED | _PAGE_NO_CACHE); | ||
868 | return vma_prot; | ||
869 | } | ||
870 | EXPORT_SYMBOL(phys_mem_access_prot); | ||