diff options
Diffstat (limited to 'arch/sparc64/mm/init.c')
-rw-r--r-- | arch/sparc64/mm/init.c | 1431 |
1 files changed, 789 insertions, 642 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index 1e44ee26cee8..c2b556106fc1 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/config.h> | 8 | #include <linux/config.h> |
9 | #include <linux/module.h> | ||
9 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
10 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
11 | #include <linux/string.h> | 12 | #include <linux/string.h> |
@@ -39,9 +40,27 @@ | |||
39 | #include <asm/tlb.h> | 40 | #include <asm/tlb.h> |
40 | #include <asm/spitfire.h> | 41 | #include <asm/spitfire.h> |
41 | #include <asm/sections.h> | 42 | #include <asm/sections.h> |
43 | #include <asm/tsb.h> | ||
44 | #include <asm/hypervisor.h> | ||
42 | 45 | ||
43 | extern void device_scan(void); | 46 | extern void device_scan(void); |
44 | 47 | ||
48 | #define MAX_PHYS_ADDRESS (1UL << 42UL) | ||
49 | #define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) | ||
50 | #define KPTE_BITMAP_BYTES \ | ||
51 | ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 8) | ||
52 | |||
53 | unsigned long kern_linear_pte_xor[2] __read_mostly; | ||
54 | |||
55 | /* A bitmap, one bit for every 256MB of physical memory. If the bit | ||
56 | * is clear, we should use a 4MB page (via kern_linear_pte_xor[0]) else | ||
57 | * if set we should use a 256MB page (via kern_linear_pte_xor[1]). | ||
58 | */ | ||
59 | unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)]; | ||
60 | |||
61 | /* A special kernel TSB for 4MB and 256MB linear mappings. */ | ||
62 | struct tsb swapper_4m_tsb[KERNEL_TSB4M_NENTRIES]; | ||
63 | |||
45 | #define MAX_BANKS 32 | 64 | #define MAX_BANKS 32 |
46 | 65 | ||
47 | static struct linux_prom64_registers pavail[MAX_BANKS] __initdata; | 66 | static struct linux_prom64_registers pavail[MAX_BANKS] __initdata; |
@@ -111,11 +130,9 @@ static void __init read_obp_memory(const char *property, | |||
111 | 130 | ||
112 | unsigned long *sparc64_valid_addr_bitmap __read_mostly; | 131 | unsigned long *sparc64_valid_addr_bitmap __read_mostly; |
113 | 132 | ||
114 | /* Ugly, but necessary... -DaveM */ | 133 | /* Kernel physical address base and size in bytes. */ |
115 | unsigned long phys_base __read_mostly; | ||
116 | unsigned long kern_base __read_mostly; | 134 | unsigned long kern_base __read_mostly; |
117 | unsigned long kern_size __read_mostly; | 135 | unsigned long kern_size __read_mostly; |
118 | unsigned long pfn_base __read_mostly; | ||
119 | 136 | ||
120 | /* get_new_mmu_context() uses "cache + 1". */ | 137 | /* get_new_mmu_context() uses "cache + 1". */ |
121 | DEFINE_SPINLOCK(ctx_alloc_lock); | 138 | DEFINE_SPINLOCK(ctx_alloc_lock); |
@@ -141,24 +158,28 @@ unsigned long sparc64_kern_sec_context __read_mostly; | |||
141 | 158 | ||
142 | int bigkernel = 0; | 159 | int bigkernel = 0; |
143 | 160 | ||
144 | /* XXX Tune this... */ | 161 | kmem_cache_t *pgtable_cache __read_mostly; |
145 | #define PGT_CACHE_LOW 25 | 162 | |
146 | #define PGT_CACHE_HIGH 50 | 163 | static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) |
164 | { | ||
165 | clear_page(addr); | ||
166 | } | ||
167 | |||
168 | extern void tsb_cache_init(void); | ||
147 | 169 | ||
148 | void check_pgt_cache(void) | 170 | void pgtable_cache_init(void) |
149 | { | 171 | { |
150 | preempt_disable(); | 172 | pgtable_cache = kmem_cache_create("pgtable_cache", |
151 | if (pgtable_cache_size > PGT_CACHE_HIGH) { | 173 | PAGE_SIZE, PAGE_SIZE, |
152 | do { | 174 | SLAB_HWCACHE_ALIGN | |
153 | if (pgd_quicklist) | 175 | SLAB_MUST_HWCACHE_ALIGN, |
154 | free_pgd_slow(get_pgd_fast()); | 176 | zero_ctor, |
155 | if (pte_quicklist[0]) | 177 | NULL); |
156 | free_pte_slow(pte_alloc_one_fast(NULL, 0)); | 178 | if (!pgtable_cache) { |
157 | if (pte_quicklist[1]) | 179 | prom_printf("Could not create pgtable_cache\n"); |
158 | free_pte_slow(pte_alloc_one_fast(NULL, 1 << (PAGE_SHIFT + 10))); | 180 | prom_halt(); |
159 | } while (pgtable_cache_size > PGT_CACHE_LOW); | ||
160 | } | 181 | } |
161 | preempt_enable(); | 182 | tsb_cache_init(); |
162 | } | 183 | } |
163 | 184 | ||
164 | #ifdef CONFIG_DEBUG_DCFLUSH | 185 | #ifdef CONFIG_DEBUG_DCFLUSH |
@@ -168,8 +189,9 @@ atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0); | |||
168 | #endif | 189 | #endif |
169 | #endif | 190 | #endif |
170 | 191 | ||
171 | __inline__ void flush_dcache_page_impl(struct page *page) | 192 | inline void flush_dcache_page_impl(struct page *page) |
172 | { | 193 | { |
194 | BUG_ON(tlb_type == hypervisor); | ||
173 | #ifdef CONFIG_DEBUG_DCFLUSH | 195 | #ifdef CONFIG_DEBUG_DCFLUSH |
174 | atomic_inc(&dcpage_flushes); | 196 | atomic_inc(&dcpage_flushes); |
175 | #endif | 197 | #endif |
@@ -186,8 +208,8 @@ __inline__ void flush_dcache_page_impl(struct page *page) | |||
186 | } | 208 | } |
187 | 209 | ||
188 | #define PG_dcache_dirty PG_arch_1 | 210 | #define PG_dcache_dirty PG_arch_1 |
189 | #define PG_dcache_cpu_shift 24 | 211 | #define PG_dcache_cpu_shift 24UL |
190 | #define PG_dcache_cpu_mask (256 - 1) | 212 | #define PG_dcache_cpu_mask (256UL - 1UL) |
191 | 213 | ||
192 | #if NR_CPUS > 256 | 214 | #if NR_CPUS > 256 |
193 | #error D-cache dirty tracking and thread_info->cpu need fixing for > 256 cpus | 215 | #error D-cache dirty tracking and thread_info->cpu need fixing for > 256 cpus |
@@ -243,32 +265,61 @@ static __inline__ void clear_dcache_dirty_cpu(struct page *page, unsigned long c | |||
243 | : "g1", "g7"); | 265 | : "g1", "g7"); |
244 | } | 266 | } |
245 | 267 | ||
268 | static inline void tsb_insert(struct tsb *ent, unsigned long tag, unsigned long pte) | ||
269 | { | ||
270 | unsigned long tsb_addr = (unsigned long) ent; | ||
271 | |||
272 | if (tlb_type == cheetah_plus || tlb_type == hypervisor) | ||
273 | tsb_addr = __pa(tsb_addr); | ||
274 | |||
275 | __tsb_insert(tsb_addr, tag, pte); | ||
276 | } | ||
277 | |||
278 | unsigned long _PAGE_ALL_SZ_BITS __read_mostly; | ||
279 | unsigned long _PAGE_SZBITS __read_mostly; | ||
280 | |||
246 | void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte) | 281 | void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte) |
247 | { | 282 | { |
248 | struct page *page; | 283 | struct mm_struct *mm; |
249 | unsigned long pfn; | 284 | struct tsb *tsb; |
250 | unsigned long pg_flags; | 285 | unsigned long tag, flags; |
251 | 286 | ||
252 | pfn = pte_pfn(pte); | 287 | if (tlb_type != hypervisor) { |
253 | if (pfn_valid(pfn) && | 288 | unsigned long pfn = pte_pfn(pte); |
254 | (page = pfn_to_page(pfn), page_mapping(page)) && | 289 | unsigned long pg_flags; |
255 | ((pg_flags = page->flags) & (1UL << PG_dcache_dirty))) { | 290 | struct page *page; |
256 | int cpu = ((pg_flags >> PG_dcache_cpu_shift) & | 291 | |
257 | PG_dcache_cpu_mask); | 292 | if (pfn_valid(pfn) && |
258 | int this_cpu = get_cpu(); | 293 | (page = pfn_to_page(pfn), page_mapping(page)) && |
259 | 294 | ((pg_flags = page->flags) & (1UL << PG_dcache_dirty))) { | |
260 | /* This is just to optimize away some function calls | 295 | int cpu = ((pg_flags >> PG_dcache_cpu_shift) & |
261 | * in the SMP case. | 296 | PG_dcache_cpu_mask); |
262 | */ | 297 | int this_cpu = get_cpu(); |
263 | if (cpu == this_cpu) | 298 | |
264 | flush_dcache_page_impl(page); | 299 | /* This is just to optimize away some function calls |
265 | else | 300 | * in the SMP case. |
266 | smp_flush_dcache_page_impl(page, cpu); | 301 | */ |
302 | if (cpu == this_cpu) | ||
303 | flush_dcache_page_impl(page); | ||
304 | else | ||
305 | smp_flush_dcache_page_impl(page, cpu); | ||
267 | 306 | ||
268 | clear_dcache_dirty_cpu(page, cpu); | 307 | clear_dcache_dirty_cpu(page, cpu); |
269 | 308 | ||
270 | put_cpu(); | 309 | put_cpu(); |
310 | } | ||
271 | } | 311 | } |
312 | |||
313 | mm = vma->vm_mm; | ||
314 | |||
315 | spin_lock_irqsave(&mm->context.lock, flags); | ||
316 | |||
317 | tsb = &mm->context.tsb[(address >> PAGE_SHIFT) & | ||
318 | (mm->context.tsb_nentries - 1UL)]; | ||
319 | tag = (address >> 22UL); | ||
320 | tsb_insert(tsb, tag, pte_val(pte)); | ||
321 | |||
322 | spin_unlock_irqrestore(&mm->context.lock, flags); | ||
272 | } | 323 | } |
273 | 324 | ||
274 | void flush_dcache_page(struct page *page) | 325 | void flush_dcache_page(struct page *page) |
@@ -276,6 +327,9 @@ void flush_dcache_page(struct page *page) | |||
276 | struct address_space *mapping; | 327 | struct address_space *mapping; |
277 | int this_cpu; | 328 | int this_cpu; |
278 | 329 | ||
330 | if (tlb_type == hypervisor) | ||
331 | return; | ||
332 | |||
279 | /* Do not bother with the expensive D-cache flush if it | 333 | /* Do not bother with the expensive D-cache flush if it |
280 | * is merely the zero page. The 'bigcore' testcase in GDB | 334 | * is merely the zero page. The 'bigcore' testcase in GDB |
281 | * causes this case to run millions of times. | 335 | * causes this case to run millions of times. |
@@ -311,7 +365,7 @@ out: | |||
311 | 365 | ||
312 | void __kprobes flush_icache_range(unsigned long start, unsigned long end) | 366 | void __kprobes flush_icache_range(unsigned long start, unsigned long end) |
313 | { | 367 | { |
314 | /* Cheetah has coherent I-cache. */ | 368 | /* Cheetah and Hypervisor platform cpus have coherent I-cache. */ |
315 | if (tlb_type == spitfire) { | 369 | if (tlb_type == spitfire) { |
316 | unsigned long kaddr; | 370 | unsigned long kaddr; |
317 | 371 | ||
@@ -320,16 +374,6 @@ void __kprobes flush_icache_range(unsigned long start, unsigned long end) | |||
320 | } | 374 | } |
321 | } | 375 | } |
322 | 376 | ||
323 | unsigned long page_to_pfn(struct page *page) | ||
324 | { | ||
325 | return (unsigned long) ((page - mem_map) + pfn_base); | ||
326 | } | ||
327 | |||
328 | struct page *pfn_to_page(unsigned long pfn) | ||
329 | { | ||
330 | return (mem_map + (pfn - pfn_base)); | ||
331 | } | ||
332 | |||
333 | void show_mem(void) | 377 | void show_mem(void) |
334 | { | 378 | { |
335 | printk("Mem-info:\n"); | 379 | printk("Mem-info:\n"); |
@@ -338,7 +382,6 @@ void show_mem(void) | |||
338 | nr_swap_pages << (PAGE_SHIFT-10)); | 382 | nr_swap_pages << (PAGE_SHIFT-10)); |
339 | printk("%ld pages of RAM\n", num_physpages); | 383 | printk("%ld pages of RAM\n", num_physpages); |
340 | printk("%d free pages\n", nr_free_pages()); | 384 | printk("%d free pages\n", nr_free_pages()); |
341 | printk("%d pages in page table cache\n",pgtable_cache_size); | ||
342 | } | 385 | } |
343 | 386 | ||
344 | void mmu_info(struct seq_file *m) | 387 | void mmu_info(struct seq_file *m) |
@@ -349,6 +392,8 @@ void mmu_info(struct seq_file *m) | |||
349 | seq_printf(m, "MMU Type\t: Cheetah+\n"); | 392 | seq_printf(m, "MMU Type\t: Cheetah+\n"); |
350 | else if (tlb_type == spitfire) | 393 | else if (tlb_type == spitfire) |
351 | seq_printf(m, "MMU Type\t: Spitfire\n"); | 394 | seq_printf(m, "MMU Type\t: Spitfire\n"); |
395 | else if (tlb_type == hypervisor) | ||
396 | seq_printf(m, "MMU Type\t: Hypervisor (sun4v)\n"); | ||
352 | else | 397 | else |
353 | seq_printf(m, "MMU Type\t: ???\n"); | 398 | seq_printf(m, "MMU Type\t: ???\n"); |
354 | 399 | ||
@@ -371,45 +416,13 @@ struct linux_prom_translation { | |||
371 | /* Exported for kernel TLB miss handling in ktlb.S */ | 416 | /* Exported for kernel TLB miss handling in ktlb.S */ |
372 | struct linux_prom_translation prom_trans[512] __read_mostly; | 417 | struct linux_prom_translation prom_trans[512] __read_mostly; |
373 | unsigned int prom_trans_ents __read_mostly; | 418 | unsigned int prom_trans_ents __read_mostly; |
374 | unsigned int swapper_pgd_zero __read_mostly; | ||
375 | |||
376 | extern unsigned long prom_boot_page; | ||
377 | extern void prom_remap(unsigned long physpage, unsigned long virtpage, int mmu_ihandle); | ||
378 | extern int prom_get_mmu_ihandle(void); | ||
379 | extern void register_prom_callbacks(void); | ||
380 | 419 | ||
381 | /* Exported for SMP bootup purposes. */ | 420 | /* Exported for SMP bootup purposes. */ |
382 | unsigned long kern_locked_tte_data; | 421 | unsigned long kern_locked_tte_data; |
383 | 422 | ||
384 | /* | ||
385 | * Translate PROM's mapping we capture at boot time into physical address. | ||
386 | * The second parameter is only set from prom_callback() invocations. | ||
387 | */ | ||
388 | unsigned long prom_virt_to_phys(unsigned long promva, int *error) | ||
389 | { | ||
390 | int i; | ||
391 | |||
392 | for (i = 0; i < prom_trans_ents; i++) { | ||
393 | struct linux_prom_translation *p = &prom_trans[i]; | ||
394 | |||
395 | if (promva >= p->virt && | ||
396 | promva < (p->virt + p->size)) { | ||
397 | unsigned long base = p->data & _PAGE_PADDR; | ||
398 | |||
399 | if (error) | ||
400 | *error = 0; | ||
401 | return base + (promva & (8192 - 1)); | ||
402 | } | ||
403 | } | ||
404 | if (error) | ||
405 | *error = 1; | ||
406 | return 0UL; | ||
407 | } | ||
408 | |||
409 | /* The obp translations are saved based on 8k pagesize, since obp can | 423 | /* The obp translations are saved based on 8k pagesize, since obp can |
410 | * use a mixture of pagesizes. Misses to the LOW_OBP_ADDRESS -> | 424 | * use a mixture of pagesizes. Misses to the LOW_OBP_ADDRESS -> |
411 | * HI_OBP_ADDRESS range are handled in ktlb.S and do not use the vpte | 425 | * HI_OBP_ADDRESS range are handled in ktlb.S. |
412 | * scheme (also, see rant in inherit_locked_prom_mappings()). | ||
413 | */ | 426 | */ |
414 | static inline int in_obp_range(unsigned long vaddr) | 427 | static inline int in_obp_range(unsigned long vaddr) |
415 | { | 428 | { |
@@ -490,6 +503,36 @@ static void __init read_obp_translations(void) | |||
490 | } | 503 | } |
491 | } | 504 | } |
492 | 505 | ||
506 | static void __init hypervisor_tlb_lock(unsigned long vaddr, | ||
507 | unsigned long pte, | ||
508 | unsigned long mmu) | ||
509 | { | ||
510 | register unsigned long func asm("%o5"); | ||
511 | register unsigned long arg0 asm("%o0"); | ||
512 | register unsigned long arg1 asm("%o1"); | ||
513 | register unsigned long arg2 asm("%o2"); | ||
514 | register unsigned long arg3 asm("%o3"); | ||
515 | |||
516 | func = HV_FAST_MMU_MAP_PERM_ADDR; | ||
517 | arg0 = vaddr; | ||
518 | arg1 = 0; | ||
519 | arg2 = pte; | ||
520 | arg3 = mmu; | ||
521 | __asm__ __volatile__("ta 0x80" | ||
522 | : "=&r" (func), "=&r" (arg0), | ||
523 | "=&r" (arg1), "=&r" (arg2), | ||
524 | "=&r" (arg3) | ||
525 | : "0" (func), "1" (arg0), "2" (arg1), | ||
526 | "3" (arg2), "4" (arg3)); | ||
527 | if (arg0 != 0) { | ||
528 | prom_printf("hypervisor_tlb_lock[%lx:%lx:%lx:%lx]: " | ||
529 | "errors with %lx\n", vaddr, 0, pte, mmu, arg0); | ||
530 | prom_halt(); | ||
531 | } | ||
532 | } | ||
533 | |||
534 | static unsigned long kern_large_tte(unsigned long paddr); | ||
535 | |||
493 | static void __init remap_kernel(void) | 536 | static void __init remap_kernel(void) |
494 | { | 537 | { |
495 | unsigned long phys_page, tte_vaddr, tte_data; | 538 | unsigned long phys_page, tte_vaddr, tte_data; |
@@ -497,25 +540,34 @@ static void __init remap_kernel(void) | |||
497 | 540 | ||
498 | tte_vaddr = (unsigned long) KERNBASE; | 541 | tte_vaddr = (unsigned long) KERNBASE; |
499 | phys_page = (prom_boot_mapping_phys_low >> 22UL) << 22UL; | 542 | phys_page = (prom_boot_mapping_phys_low >> 22UL) << 22UL; |
500 | tte_data = (phys_page | (_PAGE_VALID | _PAGE_SZ4MB | | 543 | tte_data = kern_large_tte(phys_page); |
501 | _PAGE_CP | _PAGE_CV | _PAGE_P | | ||
502 | _PAGE_L | _PAGE_W)); | ||
503 | 544 | ||
504 | kern_locked_tte_data = tte_data; | 545 | kern_locked_tte_data = tte_data; |
505 | 546 | ||
506 | /* Now lock us into the TLBs via OBP. */ | 547 | /* Now lock us into the TLBs via Hypervisor or OBP. */ |
507 | prom_dtlb_load(tlb_ent, tte_data, tte_vaddr); | 548 | if (tlb_type == hypervisor) { |
508 | prom_itlb_load(tlb_ent, tte_data, tte_vaddr); | 549 | hypervisor_tlb_lock(tte_vaddr, tte_data, HV_MMU_DMMU); |
509 | if (bigkernel) { | 550 | hypervisor_tlb_lock(tte_vaddr, tte_data, HV_MMU_IMMU); |
510 | tlb_ent -= 1; | 551 | if (bigkernel) { |
511 | prom_dtlb_load(tlb_ent, | 552 | tte_vaddr += 0x400000; |
512 | tte_data + 0x400000, | 553 | tte_data += 0x400000; |
513 | tte_vaddr + 0x400000); | 554 | hypervisor_tlb_lock(tte_vaddr, tte_data, HV_MMU_DMMU); |
514 | prom_itlb_load(tlb_ent, | 555 | hypervisor_tlb_lock(tte_vaddr, tte_data, HV_MMU_IMMU); |
515 | tte_data + 0x400000, | 556 | } |
516 | tte_vaddr + 0x400000); | 557 | } else { |
558 | prom_dtlb_load(tlb_ent, tte_data, tte_vaddr); | ||
559 | prom_itlb_load(tlb_ent, tte_data, tte_vaddr); | ||
560 | if (bigkernel) { | ||
561 | tlb_ent -= 1; | ||
562 | prom_dtlb_load(tlb_ent, | ||
563 | tte_data + 0x400000, | ||
564 | tte_vaddr + 0x400000); | ||
565 | prom_itlb_load(tlb_ent, | ||
566 | tte_data + 0x400000, | ||
567 | tte_vaddr + 0x400000); | ||
568 | } | ||
569 | sparc64_highest_unlocked_tlb_ent = tlb_ent - 1; | ||
517 | } | 570 | } |
518 | sparc64_highest_unlocked_tlb_ent = tlb_ent - 1; | ||
519 | if (tlb_type == cheetah_plus) { | 571 | if (tlb_type == cheetah_plus) { |
520 | sparc64_kern_pri_context = (CTX_CHEETAH_PLUS_CTX0 | | 572 | sparc64_kern_pri_context = (CTX_CHEETAH_PLUS_CTX0 | |
521 | CTX_CHEETAH_PLUS_NUC); | 573 | CTX_CHEETAH_PLUS_NUC); |
@@ -533,372 +585,14 @@ static void __init inherit_prom_mappings(void) | |||
533 | prom_printf("Remapping the kernel... "); | 585 | prom_printf("Remapping the kernel... "); |
534 | remap_kernel(); | 586 | remap_kernel(); |
535 | prom_printf("done.\n"); | 587 | prom_printf("done.\n"); |
536 | |||
537 | prom_printf("Registering callbacks... "); | ||
538 | register_prom_callbacks(); | ||
539 | prom_printf("done.\n"); | ||
540 | } | ||
541 | |||
542 | /* The OBP specifications for sun4u mark 0xfffffffc00000000 and | ||
543 | * upwards as reserved for use by the firmware (I wonder if this | ||
544 | * will be the same on Cheetah...). We use this virtual address | ||
545 | * range for the VPTE table mappings of the nucleus so we need | ||
546 | * to zap them when we enter the PROM. -DaveM | ||
547 | */ | ||
548 | static void __flush_nucleus_vptes(void) | ||
549 | { | ||
550 | unsigned long prom_reserved_base = 0xfffffffc00000000UL; | ||
551 | int i; | ||
552 | |||
553 | /* Only DTLB must be checked for VPTE entries. */ | ||
554 | if (tlb_type == spitfire) { | ||
555 | for (i = 0; i < 63; i++) { | ||
556 | unsigned long tag; | ||
557 | |||
558 | /* Spitfire Errata #32 workaround */ | ||
559 | /* NOTE: Always runs on spitfire, so no cheetah+ | ||
560 | * page size encodings. | ||
561 | */ | ||
562 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
563 | "flush %%g6" | ||
564 | : /* No outputs */ | ||
565 | : "r" (0), | ||
566 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
567 | |||
568 | tag = spitfire_get_dtlb_tag(i); | ||
569 | if (((tag & ~(PAGE_MASK)) == 0) && | ||
570 | ((tag & (PAGE_MASK)) >= prom_reserved_base)) { | ||
571 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
572 | "membar #Sync" | ||
573 | : /* no outputs */ | ||
574 | : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
575 | spitfire_put_dtlb_data(i, 0x0UL); | ||
576 | } | ||
577 | } | ||
578 | } else if (tlb_type == cheetah || tlb_type == cheetah_plus) { | ||
579 | for (i = 0; i < 512; i++) { | ||
580 | unsigned long tag = cheetah_get_dtlb_tag(i, 2); | ||
581 | |||
582 | if ((tag & ~PAGE_MASK) == 0 && | ||
583 | (tag & PAGE_MASK) >= prom_reserved_base) { | ||
584 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
585 | "membar #Sync" | ||
586 | : /* no outputs */ | ||
587 | : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
588 | cheetah_put_dtlb_data(i, 0x0UL, 2); | ||
589 | } | ||
590 | |||
591 | if (tlb_type != cheetah_plus) | ||
592 | continue; | ||
593 | |||
594 | tag = cheetah_get_dtlb_tag(i, 3); | ||
595 | |||
596 | if ((tag & ~PAGE_MASK) == 0 && | ||
597 | (tag & PAGE_MASK) >= prom_reserved_base) { | ||
598 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
599 | "membar #Sync" | ||
600 | : /* no outputs */ | ||
601 | : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
602 | cheetah_put_dtlb_data(i, 0x0UL, 3); | ||
603 | } | ||
604 | } | ||
605 | } else { | ||
606 | /* Implement me :-) */ | ||
607 | BUG(); | ||
608 | } | ||
609 | } | 588 | } |
610 | 589 | ||
611 | static int prom_ditlb_set; | ||
612 | struct prom_tlb_entry { | ||
613 | int tlb_ent; | ||
614 | unsigned long tlb_tag; | ||
615 | unsigned long tlb_data; | ||
616 | }; | ||
617 | struct prom_tlb_entry prom_itlb[16], prom_dtlb[16]; | ||
618 | |||
619 | void prom_world(int enter) | 590 | void prom_world(int enter) |
620 | { | 591 | { |
621 | unsigned long pstate; | ||
622 | int i; | ||
623 | |||
624 | if (!enter) | 592 | if (!enter) |
625 | set_fs((mm_segment_t) { get_thread_current_ds() }); | 593 | set_fs((mm_segment_t) { get_thread_current_ds() }); |
626 | 594 | ||
627 | if (!prom_ditlb_set) | 595 | __asm__ __volatile__("flushw"); |
628 | return; | ||
629 | |||
630 | /* Make sure the following runs atomically. */ | ||
631 | __asm__ __volatile__("flushw\n\t" | ||
632 | "rdpr %%pstate, %0\n\t" | ||
633 | "wrpr %0, %1, %%pstate" | ||
634 | : "=r" (pstate) | ||
635 | : "i" (PSTATE_IE)); | ||
636 | |||
637 | if (enter) { | ||
638 | /* Kick out nucleus VPTEs. */ | ||
639 | __flush_nucleus_vptes(); | ||
640 | |||
641 | /* Install PROM world. */ | ||
642 | for (i = 0; i < 16; i++) { | ||
643 | if (prom_dtlb[i].tlb_ent != -1) { | ||
644 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
645 | "membar #Sync" | ||
646 | : : "r" (prom_dtlb[i].tlb_tag), "r" (TLB_TAG_ACCESS), | ||
647 | "i" (ASI_DMMU)); | ||
648 | if (tlb_type == spitfire) | ||
649 | spitfire_put_dtlb_data(prom_dtlb[i].tlb_ent, | ||
650 | prom_dtlb[i].tlb_data); | ||
651 | else if (tlb_type == cheetah || tlb_type == cheetah_plus) | ||
652 | cheetah_put_ldtlb_data(prom_dtlb[i].tlb_ent, | ||
653 | prom_dtlb[i].tlb_data); | ||
654 | } | ||
655 | if (prom_itlb[i].tlb_ent != -1) { | ||
656 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
657 | "membar #Sync" | ||
658 | : : "r" (prom_itlb[i].tlb_tag), | ||
659 | "r" (TLB_TAG_ACCESS), | ||
660 | "i" (ASI_IMMU)); | ||
661 | if (tlb_type == spitfire) | ||
662 | spitfire_put_itlb_data(prom_itlb[i].tlb_ent, | ||
663 | prom_itlb[i].tlb_data); | ||
664 | else if (tlb_type == cheetah || tlb_type == cheetah_plus) | ||
665 | cheetah_put_litlb_data(prom_itlb[i].tlb_ent, | ||
666 | prom_itlb[i].tlb_data); | ||
667 | } | ||
668 | } | ||
669 | } else { | ||
670 | for (i = 0; i < 16; i++) { | ||
671 | if (prom_dtlb[i].tlb_ent != -1) { | ||
672 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
673 | "membar #Sync" | ||
674 | : : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
675 | if (tlb_type == spitfire) | ||
676 | spitfire_put_dtlb_data(prom_dtlb[i].tlb_ent, 0x0UL); | ||
677 | else | ||
678 | cheetah_put_ldtlb_data(prom_dtlb[i].tlb_ent, 0x0UL); | ||
679 | } | ||
680 | if (prom_itlb[i].tlb_ent != -1) { | ||
681 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
682 | "membar #Sync" | ||
683 | : : "r" (TLB_TAG_ACCESS), | ||
684 | "i" (ASI_IMMU)); | ||
685 | if (tlb_type == spitfire) | ||
686 | spitfire_put_itlb_data(prom_itlb[i].tlb_ent, 0x0UL); | ||
687 | else | ||
688 | cheetah_put_litlb_data(prom_itlb[i].tlb_ent, 0x0UL); | ||
689 | } | ||
690 | } | ||
691 | } | ||
692 | __asm__ __volatile__("wrpr %0, 0, %%pstate" | ||
693 | : : "r" (pstate)); | ||
694 | } | ||
695 | |||
696 | void inherit_locked_prom_mappings(int save_p) | ||
697 | { | ||
698 | int i; | ||
699 | int dtlb_seen = 0; | ||
700 | int itlb_seen = 0; | ||
701 | |||
702 | /* Fucking losing PROM has more mappings in the TLB, but | ||
703 | * it (conveniently) fails to mention any of these in the | ||
704 | * translations property. The only ones that matter are | ||
705 | * the locked PROM tlb entries, so we impose the following | ||
706 | * irrecovable rule on the PROM, it is allowed 8 locked | ||
707 | * entries in the ITLB and 8 in the DTLB. | ||
708 | * | ||
709 | * Supposedly the upper 16GB of the address space is | ||
710 | * reserved for OBP, BUT I WISH THIS WAS DOCUMENTED | ||
711 | * SOMEWHERE!!!!!!!!!!!!!!!!! Furthermore the entire interface | ||
712 | * used between the client program and the firmware on sun5 | ||
713 | * systems to coordinate mmu mappings is also COMPLETELY | ||
714 | * UNDOCUMENTED!!!!!! Thanks S(t)un! | ||
715 | */ | ||
716 | if (save_p) { | ||
717 | for (i = 0; i < 16; i++) { | ||
718 | prom_itlb[i].tlb_ent = -1; | ||
719 | prom_dtlb[i].tlb_ent = -1; | ||
720 | } | ||
721 | } | ||
722 | if (tlb_type == spitfire) { | ||
723 | int high = sparc64_highest_unlocked_tlb_ent; | ||
724 | for (i = 0; i <= high; i++) { | ||
725 | unsigned long data; | ||
726 | |||
727 | /* Spitfire Errata #32 workaround */ | ||
728 | /* NOTE: Always runs on spitfire, so no cheetah+ | ||
729 | * page size encodings. | ||
730 | */ | ||
731 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
732 | "flush %%g6" | ||
733 | : /* No outputs */ | ||
734 | : "r" (0), | ||
735 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
736 | |||
737 | data = spitfire_get_dtlb_data(i); | ||
738 | if ((data & (_PAGE_L|_PAGE_VALID)) == (_PAGE_L|_PAGE_VALID)) { | ||
739 | unsigned long tag; | ||
740 | |||
741 | /* Spitfire Errata #32 workaround */ | ||
742 | /* NOTE: Always runs on spitfire, so no | ||
743 | * cheetah+ page size encodings. | ||
744 | */ | ||
745 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
746 | "flush %%g6" | ||
747 | : /* No outputs */ | ||
748 | : "r" (0), | ||
749 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
750 | |||
751 | tag = spitfire_get_dtlb_tag(i); | ||
752 | if (save_p) { | ||
753 | prom_dtlb[dtlb_seen].tlb_ent = i; | ||
754 | prom_dtlb[dtlb_seen].tlb_tag = tag; | ||
755 | prom_dtlb[dtlb_seen].tlb_data = data; | ||
756 | } | ||
757 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
758 | "membar #Sync" | ||
759 | : : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
760 | spitfire_put_dtlb_data(i, 0x0UL); | ||
761 | |||
762 | dtlb_seen++; | ||
763 | if (dtlb_seen > 15) | ||
764 | break; | ||
765 | } | ||
766 | } | ||
767 | |||
768 | for (i = 0; i < high; i++) { | ||
769 | unsigned long data; | ||
770 | |||
771 | /* Spitfire Errata #32 workaround */ | ||
772 | /* NOTE: Always runs on spitfire, so no | ||
773 | * cheetah+ page size encodings. | ||
774 | */ | ||
775 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
776 | "flush %%g6" | ||
777 | : /* No outputs */ | ||
778 | : "r" (0), | ||
779 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
780 | |||
781 | data = spitfire_get_itlb_data(i); | ||
782 | if ((data & (_PAGE_L|_PAGE_VALID)) == (_PAGE_L|_PAGE_VALID)) { | ||
783 | unsigned long tag; | ||
784 | |||
785 | /* Spitfire Errata #32 workaround */ | ||
786 | /* NOTE: Always runs on spitfire, so no | ||
787 | * cheetah+ page size encodings. | ||
788 | */ | ||
789 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
790 | "flush %%g6" | ||
791 | : /* No outputs */ | ||
792 | : "r" (0), | ||
793 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
794 | |||
795 | tag = spitfire_get_itlb_tag(i); | ||
796 | if (save_p) { | ||
797 | prom_itlb[itlb_seen].tlb_ent = i; | ||
798 | prom_itlb[itlb_seen].tlb_tag = tag; | ||
799 | prom_itlb[itlb_seen].tlb_data = data; | ||
800 | } | ||
801 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
802 | "membar #Sync" | ||
803 | : : "r" (TLB_TAG_ACCESS), "i" (ASI_IMMU)); | ||
804 | spitfire_put_itlb_data(i, 0x0UL); | ||
805 | |||
806 | itlb_seen++; | ||
807 | if (itlb_seen > 15) | ||
808 | break; | ||
809 | } | ||
810 | } | ||
811 | } else if (tlb_type == cheetah || tlb_type == cheetah_plus) { | ||
812 | int high = sparc64_highest_unlocked_tlb_ent; | ||
813 | |||
814 | for (i = 0; i <= high; i++) { | ||
815 | unsigned long data; | ||
816 | |||
817 | data = cheetah_get_ldtlb_data(i); | ||
818 | if ((data & (_PAGE_L|_PAGE_VALID)) == (_PAGE_L|_PAGE_VALID)) { | ||
819 | unsigned long tag; | ||
820 | |||
821 | tag = cheetah_get_ldtlb_tag(i); | ||
822 | if (save_p) { | ||
823 | prom_dtlb[dtlb_seen].tlb_ent = i; | ||
824 | prom_dtlb[dtlb_seen].tlb_tag = tag; | ||
825 | prom_dtlb[dtlb_seen].tlb_data = data; | ||
826 | } | ||
827 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
828 | "membar #Sync" | ||
829 | : : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
830 | cheetah_put_ldtlb_data(i, 0x0UL); | ||
831 | |||
832 | dtlb_seen++; | ||
833 | if (dtlb_seen > 15) | ||
834 | break; | ||
835 | } | ||
836 | } | ||
837 | |||
838 | for (i = 0; i < high; i++) { | ||
839 | unsigned long data; | ||
840 | |||
841 | data = cheetah_get_litlb_data(i); | ||
842 | if ((data & (_PAGE_L|_PAGE_VALID)) == (_PAGE_L|_PAGE_VALID)) { | ||
843 | unsigned long tag; | ||
844 | |||
845 | tag = cheetah_get_litlb_tag(i); | ||
846 | if (save_p) { | ||
847 | prom_itlb[itlb_seen].tlb_ent = i; | ||
848 | prom_itlb[itlb_seen].tlb_tag = tag; | ||
849 | prom_itlb[itlb_seen].tlb_data = data; | ||
850 | } | ||
851 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
852 | "membar #Sync" | ||
853 | : : "r" (TLB_TAG_ACCESS), "i" (ASI_IMMU)); | ||
854 | cheetah_put_litlb_data(i, 0x0UL); | ||
855 | |||
856 | itlb_seen++; | ||
857 | if (itlb_seen > 15) | ||
858 | break; | ||
859 | } | ||
860 | } | ||
861 | } else { | ||
862 | /* Implement me :-) */ | ||
863 | BUG(); | ||
864 | } | ||
865 | if (save_p) | ||
866 | prom_ditlb_set = 1; | ||
867 | } | ||
868 | |||
869 | /* Give PROM back his world, done during reboots... */ | ||
870 | void prom_reload_locked(void) | ||
871 | { | ||
872 | int i; | ||
873 | |||
874 | for (i = 0; i < 16; i++) { | ||
875 | if (prom_dtlb[i].tlb_ent != -1) { | ||
876 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
877 | "membar #Sync" | ||
878 | : : "r" (prom_dtlb[i].tlb_tag), "r" (TLB_TAG_ACCESS), | ||
879 | "i" (ASI_DMMU)); | ||
880 | if (tlb_type == spitfire) | ||
881 | spitfire_put_dtlb_data(prom_dtlb[i].tlb_ent, | ||
882 | prom_dtlb[i].tlb_data); | ||
883 | else if (tlb_type == cheetah || tlb_type == cheetah_plus) | ||
884 | cheetah_put_ldtlb_data(prom_dtlb[i].tlb_ent, | ||
885 | prom_dtlb[i].tlb_data); | ||
886 | } | ||
887 | |||
888 | if (prom_itlb[i].tlb_ent != -1) { | ||
889 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
890 | "membar #Sync" | ||
891 | : : "r" (prom_itlb[i].tlb_tag), | ||
892 | "r" (TLB_TAG_ACCESS), | ||
893 | "i" (ASI_IMMU)); | ||
894 | if (tlb_type == spitfire) | ||
895 | spitfire_put_itlb_data(prom_itlb[i].tlb_ent, | ||
896 | prom_itlb[i].tlb_data); | ||
897 | else | ||
898 | cheetah_put_litlb_data(prom_itlb[i].tlb_ent, | ||
899 | prom_itlb[i].tlb_data); | ||
900 | } | ||
901 | } | ||
902 | } | 596 | } |
903 | 597 | ||
904 | #ifdef DCACHE_ALIASING_POSSIBLE | 598 | #ifdef DCACHE_ALIASING_POSSIBLE |
@@ -914,7 +608,7 @@ void __flush_dcache_range(unsigned long start, unsigned long end) | |||
914 | if (++n >= 512) | 608 | if (++n >= 512) |
915 | break; | 609 | break; |
916 | } | 610 | } |
917 | } else { | 611 | } else if (tlb_type == cheetah || tlb_type == cheetah_plus) { |
918 | start = __pa(start); | 612 | start = __pa(start); |
919 | end = __pa(end); | 613 | end = __pa(end); |
920 | for (va = start; va < end; va += 32) | 614 | for (va = start; va < end; va += 32) |
@@ -927,63 +621,6 @@ void __flush_dcache_range(unsigned long start, unsigned long end) | |||
927 | } | 621 | } |
928 | #endif /* DCACHE_ALIASING_POSSIBLE */ | 622 | #endif /* DCACHE_ALIASING_POSSIBLE */ |
929 | 623 | ||
930 | /* If not locked, zap it. */ | ||
931 | void __flush_tlb_all(void) | ||
932 | { | ||
933 | unsigned long pstate; | ||
934 | int i; | ||
935 | |||
936 | __asm__ __volatile__("flushw\n\t" | ||
937 | "rdpr %%pstate, %0\n\t" | ||
938 | "wrpr %0, %1, %%pstate" | ||
939 | : "=r" (pstate) | ||
940 | : "i" (PSTATE_IE)); | ||
941 | if (tlb_type == spitfire) { | ||
942 | for (i = 0; i < 64; i++) { | ||
943 | /* Spitfire Errata #32 workaround */ | ||
944 | /* NOTE: Always runs on spitfire, so no | ||
945 | * cheetah+ page size encodings. | ||
946 | */ | ||
947 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
948 | "flush %%g6" | ||
949 | : /* No outputs */ | ||
950 | : "r" (0), | ||
951 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
952 | |||
953 | if (!(spitfire_get_dtlb_data(i) & _PAGE_L)) { | ||
954 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
955 | "membar #Sync" | ||
956 | : /* no outputs */ | ||
957 | : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
958 | spitfire_put_dtlb_data(i, 0x0UL); | ||
959 | } | ||
960 | |||
961 | /* Spitfire Errata #32 workaround */ | ||
962 | /* NOTE: Always runs on spitfire, so no | ||
963 | * cheetah+ page size encodings. | ||
964 | */ | ||
965 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
966 | "flush %%g6" | ||
967 | : /* No outputs */ | ||
968 | : "r" (0), | ||
969 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
970 | |||
971 | if (!(spitfire_get_itlb_data(i) & _PAGE_L)) { | ||
972 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
973 | "membar #Sync" | ||
974 | : /* no outputs */ | ||
975 | : "r" (TLB_TAG_ACCESS), "i" (ASI_IMMU)); | ||
976 | spitfire_put_itlb_data(i, 0x0UL); | ||
977 | } | ||
978 | } | ||
979 | } else if (tlb_type == cheetah || tlb_type == cheetah_plus) { | ||
980 | cheetah_flush_dtlb_all(); | ||
981 | cheetah_flush_itlb_all(); | ||
982 | } | ||
983 | __asm__ __volatile__("wrpr %0, 0, %%pstate" | ||
984 | : : "r" (pstate)); | ||
985 | } | ||
986 | |||
987 | /* Caller does TLB context flushing on local CPU if necessary. | 624 | /* Caller does TLB context flushing on local CPU if necessary. |
988 | * The caller also ensures that CTX_VALID(mm->context) is false. | 625 | * The caller also ensures that CTX_VALID(mm->context) is false. |
989 | * | 626 | * |
@@ -991,17 +628,21 @@ void __flush_tlb_all(void) | |||
991 | * let the user have CTX 0 (nucleus) or we ever use a CTX | 628 | * let the user have CTX 0 (nucleus) or we ever use a CTX |
992 | * version of zero (and thus NO_CONTEXT would not be caught | 629 | * version of zero (and thus NO_CONTEXT would not be caught |
993 | * by version mis-match tests in mmu_context.h). | 630 | * by version mis-match tests in mmu_context.h). |
631 | * | ||
632 | * Always invoked with interrupts disabled. | ||
994 | */ | 633 | */ |
995 | void get_new_mmu_context(struct mm_struct *mm) | 634 | void get_new_mmu_context(struct mm_struct *mm) |
996 | { | 635 | { |
997 | unsigned long ctx, new_ctx; | 636 | unsigned long ctx, new_ctx; |
998 | unsigned long orig_pgsz_bits; | 637 | unsigned long orig_pgsz_bits; |
999 | 638 | unsigned long flags; | |
639 | int new_version; | ||
1000 | 640 | ||
1001 | spin_lock(&ctx_alloc_lock); | 641 | spin_lock_irqsave(&ctx_alloc_lock, flags); |
1002 | orig_pgsz_bits = (mm->context.sparc64_ctx_val & CTX_PGSZ_MASK); | 642 | orig_pgsz_bits = (mm->context.sparc64_ctx_val & CTX_PGSZ_MASK); |
1003 | ctx = (tlb_context_cache + 1) & CTX_NR_MASK; | 643 | ctx = (tlb_context_cache + 1) & CTX_NR_MASK; |
1004 | new_ctx = find_next_zero_bit(mmu_context_bmap, 1 << CTX_NR_BITS, ctx); | 644 | new_ctx = find_next_zero_bit(mmu_context_bmap, 1 << CTX_NR_BITS, ctx); |
645 | new_version = 0; | ||
1005 | if (new_ctx >= (1 << CTX_NR_BITS)) { | 646 | if (new_ctx >= (1 << CTX_NR_BITS)) { |
1006 | new_ctx = find_next_zero_bit(mmu_context_bmap, ctx, 1); | 647 | new_ctx = find_next_zero_bit(mmu_context_bmap, ctx, 1); |
1007 | if (new_ctx >= ctx) { | 648 | if (new_ctx >= ctx) { |
@@ -1024,6 +665,7 @@ void get_new_mmu_context(struct mm_struct *mm) | |||
1024 | mmu_context_bmap[i + 2] = 0; | 665 | mmu_context_bmap[i + 2] = 0; |
1025 | mmu_context_bmap[i + 3] = 0; | 666 | mmu_context_bmap[i + 3] = 0; |
1026 | } | 667 | } |
668 | new_version = 1; | ||
1027 | goto out; | 669 | goto out; |
1028 | } | 670 | } |
1029 | } | 671 | } |
@@ -1032,79 +674,10 @@ void get_new_mmu_context(struct mm_struct *mm) | |||
1032 | out: | 674 | out: |
1033 | tlb_context_cache = new_ctx; | 675 | tlb_context_cache = new_ctx; |
1034 | mm->context.sparc64_ctx_val = new_ctx | orig_pgsz_bits; | 676 | mm->context.sparc64_ctx_val = new_ctx | orig_pgsz_bits; |
1035 | spin_unlock(&ctx_alloc_lock); | 677 | spin_unlock_irqrestore(&ctx_alloc_lock, flags); |
1036 | } | ||
1037 | |||
1038 | #ifndef CONFIG_SMP | ||
1039 | struct pgtable_cache_struct pgt_quicklists; | ||
1040 | #endif | ||
1041 | |||
1042 | /* OK, we have to color these pages. The page tables are accessed | ||
1043 | * by non-Dcache enabled mapping in the VPTE area by the dtlb_backend.S | ||
1044 | * code, as well as by PAGE_OFFSET range direct-mapped addresses by | ||
1045 | * other parts of the kernel. By coloring, we make sure that the tlbmiss | ||
1046 | * fast handlers do not get data from old/garbage dcache lines that | ||
1047 | * correspond to an old/stale virtual address (user/kernel) that | ||
1048 | * previously mapped the pagetable page while accessing vpte range | ||
1049 | * addresses. The idea is that if the vpte color and PAGE_OFFSET range | ||
1050 | * color is the same, then when the kernel initializes the pagetable | ||
1051 | * using the later address range, accesses with the first address | ||
1052 | * range will see the newly initialized data rather than the garbage. | ||
1053 | */ | ||
1054 | #ifdef DCACHE_ALIASING_POSSIBLE | ||
1055 | #define DC_ALIAS_SHIFT 1 | ||
1056 | #else | ||
1057 | #define DC_ALIAS_SHIFT 0 | ||
1058 | #endif | ||
1059 | pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) | ||
1060 | { | ||
1061 | struct page *page; | ||
1062 | unsigned long color; | ||
1063 | |||
1064 | { | ||
1065 | pte_t *ptep = pte_alloc_one_fast(mm, address); | ||
1066 | |||
1067 | if (ptep) | ||
1068 | return ptep; | ||
1069 | } | ||
1070 | 678 | ||
1071 | color = VPTE_COLOR(address); | 679 | if (unlikely(new_version)) |
1072 | page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, DC_ALIAS_SHIFT); | 680 | smp_new_mmu_context_version(); |
1073 | if (page) { | ||
1074 | unsigned long *to_free; | ||
1075 | unsigned long paddr; | ||
1076 | pte_t *pte; | ||
1077 | |||
1078 | #ifdef DCACHE_ALIASING_POSSIBLE | ||
1079 | set_page_count(page, 1); | ||
1080 | ClearPageCompound(page); | ||
1081 | |||
1082 | set_page_count((page + 1), 1); | ||
1083 | ClearPageCompound(page + 1); | ||
1084 | #endif | ||
1085 | paddr = (unsigned long) page_address(page); | ||
1086 | memset((char *)paddr, 0, (PAGE_SIZE << DC_ALIAS_SHIFT)); | ||
1087 | |||
1088 | if (!color) { | ||
1089 | pte = (pte_t *) paddr; | ||
1090 | to_free = (unsigned long *) (paddr + PAGE_SIZE); | ||
1091 | } else { | ||
1092 | pte = (pte_t *) (paddr + PAGE_SIZE); | ||
1093 | to_free = (unsigned long *) paddr; | ||
1094 | } | ||
1095 | |||
1096 | #ifdef DCACHE_ALIASING_POSSIBLE | ||
1097 | /* Now free the other one up, adjust cache size. */ | ||
1098 | preempt_disable(); | ||
1099 | *to_free = (unsigned long) pte_quicklist[color ^ 0x1]; | ||
1100 | pte_quicklist[color ^ 0x1] = to_free; | ||
1101 | pgtable_cache_size++; | ||
1102 | preempt_enable(); | ||
1103 | #endif | ||
1104 | |||
1105 | return pte; | ||
1106 | } | ||
1107 | return NULL; | ||
1108 | } | 681 | } |
1109 | 682 | ||
1110 | void sparc_ultra_dump_itlb(void) | 683 | void sparc_ultra_dump_itlb(void) |
@@ -1196,9 +769,78 @@ void sparc_ultra_dump_dtlb(void) | |||
1196 | 769 | ||
1197 | extern unsigned long cmdline_memory_size; | 770 | extern unsigned long cmdline_memory_size; |
1198 | 771 | ||
1199 | unsigned long __init bootmem_init(unsigned long *pages_avail) | 772 | /* Find a free area for the bootmem map, avoiding the kernel image |
773 | * and the initial ramdisk. | ||
774 | */ | ||
775 | static unsigned long __init choose_bootmap_pfn(unsigned long start_pfn, | ||
776 | unsigned long end_pfn) | ||
777 | { | ||
778 | unsigned long avoid_start, avoid_end, bootmap_size; | ||
779 | int i; | ||
780 | |||
781 | bootmap_size = ((end_pfn - start_pfn) + 7) / 8; | ||
782 | bootmap_size = ALIGN(bootmap_size, sizeof(long)); | ||
783 | |||
784 | avoid_start = avoid_end = 0; | ||
785 | #ifdef CONFIG_BLK_DEV_INITRD | ||
786 | avoid_start = initrd_start; | ||
787 | avoid_end = PAGE_ALIGN(initrd_end); | ||
788 | #endif | ||
789 | |||
790 | #ifdef CONFIG_DEBUG_BOOTMEM | ||
791 | prom_printf("choose_bootmap_pfn: kern[%lx:%lx] avoid[%lx:%lx]\n", | ||
792 | kern_base, PAGE_ALIGN(kern_base + kern_size), | ||
793 | avoid_start, avoid_end); | ||
794 | #endif | ||
795 | for (i = 0; i < pavail_ents; i++) { | ||
796 | unsigned long start, end; | ||
797 | |||
798 | start = pavail[i].phys_addr; | ||
799 | end = start + pavail[i].reg_size; | ||
800 | |||
801 | while (start < end) { | ||
802 | if (start >= kern_base && | ||
803 | start < PAGE_ALIGN(kern_base + kern_size)) { | ||
804 | start = PAGE_ALIGN(kern_base + kern_size); | ||
805 | continue; | ||
806 | } | ||
807 | if (start >= avoid_start && start < avoid_end) { | ||
808 | start = avoid_end; | ||
809 | continue; | ||
810 | } | ||
811 | |||
812 | if ((end - start) < bootmap_size) | ||
813 | break; | ||
814 | |||
815 | if (start < kern_base && | ||
816 | (start + bootmap_size) > kern_base) { | ||
817 | start = PAGE_ALIGN(kern_base + kern_size); | ||
818 | continue; | ||
819 | } | ||
820 | |||
821 | if (start < avoid_start && | ||
822 | (start + bootmap_size) > avoid_start) { | ||
823 | start = avoid_end; | ||
824 | continue; | ||
825 | } | ||
826 | |||
827 | /* OK, it doesn't overlap anything, use it. */ | ||
828 | #ifdef CONFIG_DEBUG_BOOTMEM | ||
829 | prom_printf("choose_bootmap_pfn: Using %lx [%lx]\n", | ||
830 | start >> PAGE_SHIFT, start); | ||
831 | #endif | ||
832 | return start >> PAGE_SHIFT; | ||
833 | } | ||
834 | } | ||
835 | |||
836 | prom_printf("Cannot find free area for bootmap, aborting.\n"); | ||
837 | prom_halt(); | ||
838 | } | ||
839 | |||
840 | static unsigned long __init bootmem_init(unsigned long *pages_avail, | ||
841 | unsigned long phys_base) | ||
1200 | { | 842 | { |
1201 | unsigned long bootmap_size, start_pfn, end_pfn; | 843 | unsigned long bootmap_size, end_pfn; |
1202 | unsigned long end_of_phys_memory = 0UL; | 844 | unsigned long end_of_phys_memory = 0UL; |
1203 | unsigned long bootmap_pfn, bytes_avail, size; | 845 | unsigned long bootmap_pfn, bytes_avail, size; |
1204 | int i; | 846 | int i; |
@@ -1236,14 +878,6 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) | |||
1236 | 878 | ||
1237 | *pages_avail = bytes_avail >> PAGE_SHIFT; | 879 | *pages_avail = bytes_avail >> PAGE_SHIFT; |
1238 | 880 | ||
1239 | /* Start with page aligned address of last symbol in kernel | ||
1240 | * image. The kernel is hard mapped below PAGE_OFFSET in a | ||
1241 | * 4MB locked TLB translation. | ||
1242 | */ | ||
1243 | start_pfn = PAGE_ALIGN(kern_base + kern_size) >> PAGE_SHIFT; | ||
1244 | |||
1245 | bootmap_pfn = start_pfn; | ||
1246 | |||
1247 | end_pfn = end_of_phys_memory >> PAGE_SHIFT; | 881 | end_pfn = end_of_phys_memory >> PAGE_SHIFT; |
1248 | 882 | ||
1249 | #ifdef CONFIG_BLK_DEV_INITRD | 883 | #ifdef CONFIG_BLK_DEV_INITRD |
@@ -1260,23 +894,22 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) | |||
1260 | "(0x%016lx > 0x%016lx)\ndisabling initrd\n", | 894 | "(0x%016lx > 0x%016lx)\ndisabling initrd\n", |
1261 | initrd_end, end_of_phys_memory); | 895 | initrd_end, end_of_phys_memory); |
1262 | initrd_start = 0; | 896 | initrd_start = 0; |
1263 | } | 897 | initrd_end = 0; |
1264 | if (initrd_start) { | ||
1265 | if (initrd_start >= (start_pfn << PAGE_SHIFT) && | ||
1266 | initrd_start < (start_pfn << PAGE_SHIFT) + 2 * PAGE_SIZE) | ||
1267 | bootmap_pfn = PAGE_ALIGN (initrd_end) >> PAGE_SHIFT; | ||
1268 | } | 898 | } |
1269 | } | 899 | } |
1270 | #endif | 900 | #endif |
1271 | /* Initialize the boot-time allocator. */ | 901 | /* Initialize the boot-time allocator. */ |
1272 | max_pfn = max_low_pfn = end_pfn; | 902 | max_pfn = max_low_pfn = end_pfn; |
1273 | min_low_pfn = pfn_base; | 903 | min_low_pfn = (phys_base >> PAGE_SHIFT); |
904 | |||
905 | bootmap_pfn = choose_bootmap_pfn(min_low_pfn, end_pfn); | ||
1274 | 906 | ||
1275 | #ifdef CONFIG_DEBUG_BOOTMEM | 907 | #ifdef CONFIG_DEBUG_BOOTMEM |
1276 | prom_printf("init_bootmem(min[%lx], bootmap[%lx], max[%lx])\n", | 908 | prom_printf("init_bootmem(min[%lx], bootmap[%lx], max[%lx])\n", |
1277 | min_low_pfn, bootmap_pfn, max_low_pfn); | 909 | min_low_pfn, bootmap_pfn, max_low_pfn); |
1278 | #endif | 910 | #endif |
1279 | bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, pfn_base, end_pfn); | 911 | bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, |
912 | min_low_pfn, end_pfn); | ||
1280 | 913 | ||
1281 | /* Now register the available physical memory with the | 914 | /* Now register the available physical memory with the |
1282 | * allocator. | 915 | * allocator. |
@@ -1324,9 +957,26 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) | |||
1324 | reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size); | 957 | reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size); |
1325 | *pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT; | 958 | *pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT; |
1326 | 959 | ||
960 | for (i = 0; i < pavail_ents; i++) { | ||
961 | unsigned long start_pfn, end_pfn; | ||
962 | |||
963 | start_pfn = pavail[i].phys_addr >> PAGE_SHIFT; | ||
964 | end_pfn = (start_pfn + (pavail[i].reg_size >> PAGE_SHIFT)); | ||
965 | #ifdef CONFIG_DEBUG_BOOTMEM | ||
966 | prom_printf("memory_present(0, %lx, %lx)\n", | ||
967 | start_pfn, end_pfn); | ||
968 | #endif | ||
969 | memory_present(0, start_pfn, end_pfn); | ||
970 | } | ||
971 | |||
972 | sparse_init(); | ||
973 | |||
1327 | return end_pfn; | 974 | return end_pfn; |
1328 | } | 975 | } |
1329 | 976 | ||
977 | static struct linux_prom64_registers pall[MAX_BANKS] __initdata; | ||
978 | static int pall_ents __initdata; | ||
979 | |||
1330 | #ifdef CONFIG_DEBUG_PAGEALLOC | 980 | #ifdef CONFIG_DEBUG_PAGEALLOC |
1331 | static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend, pgprot_t prot) | 981 | static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend, pgprot_t prot) |
1332 | { | 982 | { |
@@ -1382,14 +1032,44 @@ static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend, | |||
1382 | return alloc_bytes; | 1032 | return alloc_bytes; |
1383 | } | 1033 | } |
1384 | 1034 | ||
1385 | static struct linux_prom64_registers pall[MAX_BANKS] __initdata; | ||
1386 | static int pall_ents __initdata; | ||
1387 | |||
1388 | extern unsigned int kvmap_linear_patch[1]; | 1035 | extern unsigned int kvmap_linear_patch[1]; |
1036 | #endif /* CONFIG_DEBUG_PAGEALLOC */ | ||
1037 | |||
1038 | static void __init mark_kpte_bitmap(unsigned long start, unsigned long end) | ||
1039 | { | ||
1040 | const unsigned long shift_256MB = 28; | ||
1041 | const unsigned long mask_256MB = ((1UL << shift_256MB) - 1UL); | ||
1042 | const unsigned long size_256MB = (1UL << shift_256MB); | ||
1043 | |||
1044 | while (start < end) { | ||
1045 | long remains; | ||
1046 | |||
1047 | remains = end - start; | ||
1048 | if (remains < size_256MB) | ||
1049 | break; | ||
1050 | |||
1051 | if (start & mask_256MB) { | ||
1052 | start = (start + size_256MB) & ~mask_256MB; | ||
1053 | continue; | ||
1054 | } | ||
1055 | |||
1056 | while (remains >= size_256MB) { | ||
1057 | unsigned long index = start >> shift_256MB; | ||
1058 | |||
1059 | __set_bit(index, kpte_linear_bitmap); | ||
1060 | |||
1061 | start += size_256MB; | ||
1062 | remains -= size_256MB; | ||
1063 | } | ||
1064 | } | ||
1065 | } | ||
1389 | 1066 | ||
1390 | static void __init kernel_physical_mapping_init(void) | 1067 | static void __init kernel_physical_mapping_init(void) |
1391 | { | 1068 | { |
1392 | unsigned long i, mem_alloced = 0UL; | 1069 | unsigned long i; |
1070 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
1071 | unsigned long mem_alloced = 0UL; | ||
1072 | #endif | ||
1393 | 1073 | ||
1394 | read_obp_memory("reg", &pall[0], &pall_ents); | 1074 | read_obp_memory("reg", &pall[0], &pall_ents); |
1395 | 1075 | ||
@@ -1398,10 +1078,16 @@ static void __init kernel_physical_mapping_init(void) | |||
1398 | 1078 | ||
1399 | phys_start = pall[i].phys_addr; | 1079 | phys_start = pall[i].phys_addr; |
1400 | phys_end = phys_start + pall[i].reg_size; | 1080 | phys_end = phys_start + pall[i].reg_size; |
1081 | |||
1082 | mark_kpte_bitmap(phys_start, phys_end); | ||
1083 | |||
1084 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
1401 | mem_alloced += kernel_map_range(phys_start, phys_end, | 1085 | mem_alloced += kernel_map_range(phys_start, phys_end, |
1402 | PAGE_KERNEL); | 1086 | PAGE_KERNEL); |
1087 | #endif | ||
1403 | } | 1088 | } |
1404 | 1089 | ||
1090 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
1405 | printk("Allocated %ld bytes for kernel page tables.\n", | 1091 | printk("Allocated %ld bytes for kernel page tables.\n", |
1406 | mem_alloced); | 1092 | mem_alloced); |
1407 | 1093 | ||
@@ -1409,8 +1095,10 @@ static void __init kernel_physical_mapping_init(void) | |||
1409 | flushi(&kvmap_linear_patch[0]); | 1095 | flushi(&kvmap_linear_patch[0]); |
1410 | 1096 | ||
1411 | __flush_tlb_all(); | 1097 | __flush_tlb_all(); |
1098 | #endif | ||
1412 | } | 1099 | } |
1413 | 1100 | ||
1101 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
1414 | void kernel_map_pages(struct page *page, int numpages, int enable) | 1102 | void kernel_map_pages(struct page *page, int numpages, int enable) |
1415 | { | 1103 | { |
1416 | unsigned long phys_start = page_to_pfn(page) << PAGE_SHIFT; | 1104 | unsigned long phys_start = page_to_pfn(page) << PAGE_SHIFT; |
@@ -1419,6 +1107,9 @@ void kernel_map_pages(struct page *page, int numpages, int enable) | |||
1419 | kernel_map_range(phys_start, phys_end, | 1107 | kernel_map_range(phys_start, phys_end, |
1420 | (enable ? PAGE_KERNEL : __pgprot(0))); | 1108 | (enable ? PAGE_KERNEL : __pgprot(0))); |
1421 | 1109 | ||
1110 | flush_tsb_kernel_range(PAGE_OFFSET + phys_start, | ||
1111 | PAGE_OFFSET + phys_end); | ||
1112 | |||
1422 | /* we should perform an IPI and flush all tlbs, | 1113 | /* we should perform an IPI and flush all tlbs, |
1423 | * but that can deadlock->flush only current cpu. | 1114 | * but that can deadlock->flush only current cpu. |
1424 | */ | 1115 | */ |
@@ -1439,18 +1130,150 @@ unsigned long __init find_ecache_flush_span(unsigned long size) | |||
1439 | return ~0UL; | 1130 | return ~0UL; |
1440 | } | 1131 | } |
1441 | 1132 | ||
1133 | static void __init tsb_phys_patch(void) | ||
1134 | { | ||
1135 | struct tsb_ldquad_phys_patch_entry *pquad; | ||
1136 | struct tsb_phys_patch_entry *p; | ||
1137 | |||
1138 | pquad = &__tsb_ldquad_phys_patch; | ||
1139 | while (pquad < &__tsb_ldquad_phys_patch_end) { | ||
1140 | unsigned long addr = pquad->addr; | ||
1141 | |||
1142 | if (tlb_type == hypervisor) | ||
1143 | *(unsigned int *) addr = pquad->sun4v_insn; | ||
1144 | else | ||
1145 | *(unsigned int *) addr = pquad->sun4u_insn; | ||
1146 | wmb(); | ||
1147 | __asm__ __volatile__("flush %0" | ||
1148 | : /* no outputs */ | ||
1149 | : "r" (addr)); | ||
1150 | |||
1151 | pquad++; | ||
1152 | } | ||
1153 | |||
1154 | p = &__tsb_phys_patch; | ||
1155 | while (p < &__tsb_phys_patch_end) { | ||
1156 | unsigned long addr = p->addr; | ||
1157 | |||
1158 | *(unsigned int *) addr = p->insn; | ||
1159 | wmb(); | ||
1160 | __asm__ __volatile__("flush %0" | ||
1161 | : /* no outputs */ | ||
1162 | : "r" (addr)); | ||
1163 | |||
1164 | p++; | ||
1165 | } | ||
1166 | } | ||
1167 | |||
1168 | /* Don't mark as init, we give this to the Hypervisor. */ | ||
1169 | static struct hv_tsb_descr ktsb_descr[2]; | ||
1170 | extern struct tsb swapper_tsb[KERNEL_TSB_NENTRIES]; | ||
1171 | |||
1172 | static void __init sun4v_ktsb_init(void) | ||
1173 | { | ||
1174 | unsigned long ktsb_pa; | ||
1175 | |||
1176 | /* First KTSB for PAGE_SIZE mappings. */ | ||
1177 | ktsb_pa = kern_base + ((unsigned long)&swapper_tsb[0] - KERNBASE); | ||
1178 | |||
1179 | switch (PAGE_SIZE) { | ||
1180 | case 8 * 1024: | ||
1181 | default: | ||
1182 | ktsb_descr[0].pgsz_idx = HV_PGSZ_IDX_8K; | ||
1183 | ktsb_descr[0].pgsz_mask = HV_PGSZ_MASK_8K; | ||
1184 | break; | ||
1185 | |||
1186 | case 64 * 1024: | ||
1187 | ktsb_descr[0].pgsz_idx = HV_PGSZ_IDX_64K; | ||
1188 | ktsb_descr[0].pgsz_mask = HV_PGSZ_MASK_64K; | ||
1189 | break; | ||
1190 | |||
1191 | case 512 * 1024: | ||
1192 | ktsb_descr[0].pgsz_idx = HV_PGSZ_IDX_512K; | ||
1193 | ktsb_descr[0].pgsz_mask = HV_PGSZ_MASK_512K; | ||
1194 | break; | ||
1195 | |||
1196 | case 4 * 1024 * 1024: | ||
1197 | ktsb_descr[0].pgsz_idx = HV_PGSZ_IDX_4MB; | ||
1198 | ktsb_descr[0].pgsz_mask = HV_PGSZ_MASK_4MB; | ||
1199 | break; | ||
1200 | }; | ||
1201 | |||
1202 | ktsb_descr[0].assoc = 1; | ||
1203 | ktsb_descr[0].num_ttes = KERNEL_TSB_NENTRIES; | ||
1204 | ktsb_descr[0].ctx_idx = 0; | ||
1205 | ktsb_descr[0].tsb_base = ktsb_pa; | ||
1206 | ktsb_descr[0].resv = 0; | ||
1207 | |||
1208 | /* Second KTSB for 4MB/256MB mappings. */ | ||
1209 | ktsb_pa = (kern_base + | ||
1210 | ((unsigned long)&swapper_4m_tsb[0] - KERNBASE)); | ||
1211 | |||
1212 | ktsb_descr[1].pgsz_idx = HV_PGSZ_IDX_4MB; | ||
1213 | ktsb_descr[1].pgsz_mask = (HV_PGSZ_MASK_4MB | | ||
1214 | HV_PGSZ_MASK_256MB); | ||
1215 | ktsb_descr[1].assoc = 1; | ||
1216 | ktsb_descr[1].num_ttes = KERNEL_TSB4M_NENTRIES; | ||
1217 | ktsb_descr[1].ctx_idx = 0; | ||
1218 | ktsb_descr[1].tsb_base = ktsb_pa; | ||
1219 | ktsb_descr[1].resv = 0; | ||
1220 | } | ||
1221 | |||
1222 | void __cpuinit sun4v_ktsb_register(void) | ||
1223 | { | ||
1224 | register unsigned long func asm("%o5"); | ||
1225 | register unsigned long arg0 asm("%o0"); | ||
1226 | register unsigned long arg1 asm("%o1"); | ||
1227 | unsigned long pa; | ||
1228 | |||
1229 | pa = kern_base + ((unsigned long)&ktsb_descr[0] - KERNBASE); | ||
1230 | |||
1231 | func = HV_FAST_MMU_TSB_CTX0; | ||
1232 | arg0 = 2; | ||
1233 | arg1 = pa; | ||
1234 | __asm__ __volatile__("ta %6" | ||
1235 | : "=&r" (func), "=&r" (arg0), "=&r" (arg1) | ||
1236 | : "0" (func), "1" (arg0), "2" (arg1), | ||
1237 | "i" (HV_FAST_TRAP)); | ||
1238 | } | ||
1239 | |||
1442 | /* paging_init() sets up the page tables */ | 1240 | /* paging_init() sets up the page tables */ |
1443 | 1241 | ||
1444 | extern void cheetah_ecache_flush_init(void); | 1242 | extern void cheetah_ecache_flush_init(void); |
1243 | extern void sun4v_patch_tlb_handlers(void); | ||
1445 | 1244 | ||
1446 | static unsigned long last_valid_pfn; | 1245 | static unsigned long last_valid_pfn; |
1447 | pgd_t swapper_pg_dir[2048]; | 1246 | pgd_t swapper_pg_dir[2048]; |
1448 | 1247 | ||
1248 | static void sun4u_pgprot_init(void); | ||
1249 | static void sun4v_pgprot_init(void); | ||
1250 | |||
1449 | void __init paging_init(void) | 1251 | void __init paging_init(void) |
1450 | { | 1252 | { |
1451 | unsigned long end_pfn, pages_avail, shift; | 1253 | unsigned long end_pfn, pages_avail, shift, phys_base; |
1452 | unsigned long real_end, i; | 1254 | unsigned long real_end, i; |
1453 | 1255 | ||
1256 | kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL; | ||
1257 | kern_size = (unsigned long)&_end - (unsigned long)KERNBASE; | ||
1258 | |||
1259 | /* Invalidate both kernel TSBs. */ | ||
1260 | memset(swapper_tsb, 0x40, sizeof(swapper_tsb)); | ||
1261 | memset(swapper_4m_tsb, 0x40, sizeof(swapper_4m_tsb)); | ||
1262 | |||
1263 | if (tlb_type == hypervisor) | ||
1264 | sun4v_pgprot_init(); | ||
1265 | else | ||
1266 | sun4u_pgprot_init(); | ||
1267 | |||
1268 | if (tlb_type == cheetah_plus || | ||
1269 | tlb_type == hypervisor) | ||
1270 | tsb_phys_patch(); | ||
1271 | |||
1272 | if (tlb_type == hypervisor) { | ||
1273 | sun4v_patch_tlb_handlers(); | ||
1274 | sun4v_ktsb_init(); | ||
1275 | } | ||
1276 | |||
1454 | /* Find available physical memory... */ | 1277 | /* Find available physical memory... */ |
1455 | read_obp_memory("available", &pavail[0], &pavail_ents); | 1278 | read_obp_memory("available", &pavail[0], &pavail_ents); |
1456 | 1279 | ||
@@ -1458,11 +1281,6 @@ void __init paging_init(void) | |||
1458 | for (i = 0; i < pavail_ents; i++) | 1281 | for (i = 0; i < pavail_ents; i++) |
1459 | phys_base = min(phys_base, pavail[i].phys_addr); | 1282 | phys_base = min(phys_base, pavail[i].phys_addr); |
1460 | 1283 | ||
1461 | pfn_base = phys_base >> PAGE_SHIFT; | ||
1462 | |||
1463 | kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL; | ||
1464 | kern_size = (unsigned long)&_end - (unsigned long)KERNBASE; | ||
1465 | |||
1466 | set_bit(0, mmu_context_bmap); | 1284 | set_bit(0, mmu_context_bmap); |
1467 | 1285 | ||
1468 | shift = kern_base + PAGE_OFFSET - ((unsigned long)KERNBASE); | 1286 | shift = kern_base + PAGE_OFFSET - ((unsigned long)KERNBASE); |
@@ -1486,47 +1304,38 @@ void __init paging_init(void) | |||
1486 | pud_set(pud_offset(&swapper_pg_dir[0], 0), | 1304 | pud_set(pud_offset(&swapper_pg_dir[0], 0), |
1487 | swapper_low_pmd_dir + (shift / sizeof(pgd_t))); | 1305 | swapper_low_pmd_dir + (shift / sizeof(pgd_t))); |
1488 | 1306 | ||
1489 | swapper_pgd_zero = pgd_val(swapper_pg_dir[0]); | ||
1490 | |||
1491 | inherit_prom_mappings(); | 1307 | inherit_prom_mappings(); |
1492 | 1308 | ||
1493 | /* Ok, we can use our TLB miss and window trap handlers safely. | 1309 | /* Ok, we can use our TLB miss and window trap handlers safely. */ |
1494 | * We need to do a quick peek here to see if we are on StarFire | 1310 | setup_tba(); |
1495 | * or not, so setup_tba can setup the IRQ globals correctly (it | ||
1496 | * needs to get the hard smp processor id correctly). | ||
1497 | */ | ||
1498 | { | ||
1499 | extern void setup_tba(int); | ||
1500 | setup_tba(this_is_starfire); | ||
1501 | } | ||
1502 | |||
1503 | inherit_locked_prom_mappings(1); | ||
1504 | 1311 | ||
1505 | __flush_tlb_all(); | 1312 | __flush_tlb_all(); |
1506 | 1313 | ||
1314 | if (tlb_type == hypervisor) | ||
1315 | sun4v_ktsb_register(); | ||
1316 | |||
1507 | /* Setup bootmem... */ | 1317 | /* Setup bootmem... */ |
1508 | pages_avail = 0; | 1318 | pages_avail = 0; |
1509 | last_valid_pfn = end_pfn = bootmem_init(&pages_avail); | 1319 | last_valid_pfn = end_pfn = bootmem_init(&pages_avail, phys_base); |
1320 | |||
1321 | max_mapnr = last_valid_pfn; | ||
1510 | 1322 | ||
1511 | #ifdef CONFIG_DEBUG_PAGEALLOC | ||
1512 | kernel_physical_mapping_init(); | 1323 | kernel_physical_mapping_init(); |
1513 | #endif | ||
1514 | 1324 | ||
1515 | { | 1325 | { |
1516 | unsigned long zones_size[MAX_NR_ZONES]; | 1326 | unsigned long zones_size[MAX_NR_ZONES]; |
1517 | unsigned long zholes_size[MAX_NR_ZONES]; | 1327 | unsigned long zholes_size[MAX_NR_ZONES]; |
1518 | unsigned long npages; | ||
1519 | int znum; | 1328 | int znum; |
1520 | 1329 | ||
1521 | for (znum = 0; znum < MAX_NR_ZONES; znum++) | 1330 | for (znum = 0; znum < MAX_NR_ZONES; znum++) |
1522 | zones_size[znum] = zholes_size[znum] = 0; | 1331 | zones_size[znum] = zholes_size[znum] = 0; |
1523 | 1332 | ||
1524 | npages = end_pfn - pfn_base; | 1333 | zones_size[ZONE_DMA] = end_pfn; |
1525 | zones_size[ZONE_DMA] = npages; | 1334 | zholes_size[ZONE_DMA] = end_pfn - pages_avail; |
1526 | zholes_size[ZONE_DMA] = npages - pages_avail; | ||
1527 | 1335 | ||
1528 | free_area_init_node(0, &contig_page_data, zones_size, | 1336 | free_area_init_node(0, &contig_page_data, zones_size, |
1529 | phys_base >> PAGE_SHIFT, zholes_size); | 1337 | __pa(PAGE_OFFSET) >> PAGE_SHIFT, |
1338 | zholes_size); | ||
1530 | } | 1339 | } |
1531 | 1340 | ||
1532 | device_scan(); | 1341 | device_scan(); |
@@ -1596,7 +1405,6 @@ void __init mem_init(void) | |||
1596 | 1405 | ||
1597 | taint_real_pages(); | 1406 | taint_real_pages(); |
1598 | 1407 | ||
1599 | max_mapnr = last_valid_pfn - pfn_base; | ||
1600 | high_memory = __va(last_valid_pfn << PAGE_SHIFT); | 1408 | high_memory = __va(last_valid_pfn << PAGE_SHIFT); |
1601 | 1409 | ||
1602 | #ifdef CONFIG_DEBUG_BOOTMEM | 1410 | #ifdef CONFIG_DEBUG_BOOTMEM |
@@ -1676,3 +1484,342 @@ void free_initrd_mem(unsigned long start, unsigned long end) | |||
1676 | } | 1484 | } |
1677 | } | 1485 | } |
1678 | #endif | 1486 | #endif |
1487 | |||
1488 | #define _PAGE_CACHE_4U (_PAGE_CP_4U | _PAGE_CV_4U) | ||
1489 | #define _PAGE_CACHE_4V (_PAGE_CP_4V | _PAGE_CV_4V) | ||
1490 | #define __DIRTY_BITS_4U (_PAGE_MODIFIED_4U | _PAGE_WRITE_4U | _PAGE_W_4U) | ||
1491 | #define __DIRTY_BITS_4V (_PAGE_MODIFIED_4V | _PAGE_WRITE_4V | _PAGE_W_4V) | ||
1492 | #define __ACCESS_BITS_4U (_PAGE_ACCESSED_4U | _PAGE_READ_4U | _PAGE_R) | ||
1493 | #define __ACCESS_BITS_4V (_PAGE_ACCESSED_4V | _PAGE_READ_4V | _PAGE_R) | ||
1494 | |||
1495 | pgprot_t PAGE_KERNEL __read_mostly; | ||
1496 | EXPORT_SYMBOL(PAGE_KERNEL); | ||
1497 | |||
1498 | pgprot_t PAGE_KERNEL_LOCKED __read_mostly; | ||
1499 | pgprot_t PAGE_COPY __read_mostly; | ||
1500 | |||
1501 | pgprot_t PAGE_SHARED __read_mostly; | ||
1502 | EXPORT_SYMBOL(PAGE_SHARED); | ||
1503 | |||
1504 | pgprot_t PAGE_EXEC __read_mostly; | ||
1505 | unsigned long pg_iobits __read_mostly; | ||
1506 | |||
1507 | unsigned long _PAGE_IE __read_mostly; | ||
1508 | |||
1509 | unsigned long _PAGE_E __read_mostly; | ||
1510 | EXPORT_SYMBOL(_PAGE_E); | ||
1511 | |||
1512 | unsigned long _PAGE_CACHE __read_mostly; | ||
1513 | EXPORT_SYMBOL(_PAGE_CACHE); | ||
1514 | |||
1515 | static void prot_init_common(unsigned long page_none, | ||
1516 | unsigned long page_shared, | ||
1517 | unsigned long page_copy, | ||
1518 | unsigned long page_readonly, | ||
1519 | unsigned long page_exec_bit) | ||
1520 | { | ||
1521 | PAGE_COPY = __pgprot(page_copy); | ||
1522 | PAGE_SHARED = __pgprot(page_shared); | ||
1523 | |||
1524 | protection_map[0x0] = __pgprot(page_none); | ||
1525 | protection_map[0x1] = __pgprot(page_readonly & ~page_exec_bit); | ||
1526 | protection_map[0x2] = __pgprot(page_copy & ~page_exec_bit); | ||
1527 | protection_map[0x3] = __pgprot(page_copy & ~page_exec_bit); | ||
1528 | protection_map[0x4] = __pgprot(page_readonly); | ||
1529 | protection_map[0x5] = __pgprot(page_readonly); | ||
1530 | protection_map[0x6] = __pgprot(page_copy); | ||
1531 | protection_map[0x7] = __pgprot(page_copy); | ||
1532 | protection_map[0x8] = __pgprot(page_none); | ||
1533 | protection_map[0x9] = __pgprot(page_readonly & ~page_exec_bit); | ||
1534 | protection_map[0xa] = __pgprot(page_shared & ~page_exec_bit); | ||
1535 | protection_map[0xb] = __pgprot(page_shared & ~page_exec_bit); | ||
1536 | protection_map[0xc] = __pgprot(page_readonly); | ||
1537 | protection_map[0xd] = __pgprot(page_readonly); | ||
1538 | protection_map[0xe] = __pgprot(page_shared); | ||
1539 | protection_map[0xf] = __pgprot(page_shared); | ||
1540 | } | ||
1541 | |||
1542 | static void __init sun4u_pgprot_init(void) | ||
1543 | { | ||
1544 | unsigned long page_none, page_shared, page_copy, page_readonly; | ||
1545 | unsigned long page_exec_bit; | ||
1546 | |||
1547 | PAGE_KERNEL = __pgprot (_PAGE_PRESENT_4U | _PAGE_VALID | | ||
1548 | _PAGE_CACHE_4U | _PAGE_P_4U | | ||
1549 | __ACCESS_BITS_4U | __DIRTY_BITS_4U | | ||
1550 | _PAGE_EXEC_4U); | ||
1551 | PAGE_KERNEL_LOCKED = __pgprot (_PAGE_PRESENT_4U | _PAGE_VALID | | ||
1552 | _PAGE_CACHE_4U | _PAGE_P_4U | | ||
1553 | __ACCESS_BITS_4U | __DIRTY_BITS_4U | | ||
1554 | _PAGE_EXEC_4U | _PAGE_L_4U); | ||
1555 | PAGE_EXEC = __pgprot(_PAGE_EXEC_4U); | ||
1556 | |||
1557 | _PAGE_IE = _PAGE_IE_4U; | ||
1558 | _PAGE_E = _PAGE_E_4U; | ||
1559 | _PAGE_CACHE = _PAGE_CACHE_4U; | ||
1560 | |||
1561 | pg_iobits = (_PAGE_VALID | _PAGE_PRESENT_4U | __DIRTY_BITS_4U | | ||
1562 | __ACCESS_BITS_4U | _PAGE_E_4U); | ||
1563 | |||
1564 | kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4U) ^ | ||
1565 | 0xfffff80000000000; | ||
1566 | kern_linear_pte_xor[0] |= (_PAGE_CP_4U | _PAGE_CV_4U | | ||
1567 | _PAGE_P_4U | _PAGE_W_4U); | ||
1568 | |||
1569 | /* XXX Should use 256MB on Panther. XXX */ | ||
1570 | kern_linear_pte_xor[1] = kern_linear_pte_xor[0]; | ||
1571 | |||
1572 | _PAGE_SZBITS = _PAGE_SZBITS_4U; | ||
1573 | _PAGE_ALL_SZ_BITS = (_PAGE_SZ4MB_4U | _PAGE_SZ512K_4U | | ||
1574 | _PAGE_SZ64K_4U | _PAGE_SZ8K_4U | | ||
1575 | _PAGE_SZ32MB_4U | _PAGE_SZ256MB_4U); | ||
1576 | |||
1577 | |||
1578 | page_none = _PAGE_PRESENT_4U | _PAGE_ACCESSED_4U | _PAGE_CACHE_4U; | ||
1579 | page_shared = (_PAGE_VALID | _PAGE_PRESENT_4U | _PAGE_CACHE_4U | | ||
1580 | __ACCESS_BITS_4U | _PAGE_WRITE_4U | _PAGE_EXEC_4U); | ||
1581 | page_copy = (_PAGE_VALID | _PAGE_PRESENT_4U | _PAGE_CACHE_4U | | ||
1582 | __ACCESS_BITS_4U | _PAGE_EXEC_4U); | ||
1583 | page_readonly = (_PAGE_VALID | _PAGE_PRESENT_4U | _PAGE_CACHE_4U | | ||
1584 | __ACCESS_BITS_4U | _PAGE_EXEC_4U); | ||
1585 | |||
1586 | page_exec_bit = _PAGE_EXEC_4U; | ||
1587 | |||
1588 | prot_init_common(page_none, page_shared, page_copy, page_readonly, | ||
1589 | page_exec_bit); | ||
1590 | } | ||
1591 | |||
1592 | static void __init sun4v_pgprot_init(void) | ||
1593 | { | ||
1594 | unsigned long page_none, page_shared, page_copy, page_readonly; | ||
1595 | unsigned long page_exec_bit; | ||
1596 | |||
1597 | PAGE_KERNEL = __pgprot (_PAGE_PRESENT_4V | _PAGE_VALID | | ||
1598 | _PAGE_CACHE_4V | _PAGE_P_4V | | ||
1599 | __ACCESS_BITS_4V | __DIRTY_BITS_4V | | ||
1600 | _PAGE_EXEC_4V); | ||
1601 | PAGE_KERNEL_LOCKED = PAGE_KERNEL; | ||
1602 | PAGE_EXEC = __pgprot(_PAGE_EXEC_4V); | ||
1603 | |||
1604 | _PAGE_IE = _PAGE_IE_4V; | ||
1605 | _PAGE_E = _PAGE_E_4V; | ||
1606 | _PAGE_CACHE = _PAGE_CACHE_4V; | ||
1607 | |||
1608 | kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4V) ^ | ||
1609 | 0xfffff80000000000; | ||
1610 | kern_linear_pte_xor[0] |= (_PAGE_CP_4V | _PAGE_CV_4V | | ||
1611 | _PAGE_P_4V | _PAGE_W_4V); | ||
1612 | |||
1613 | kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZ256MB_4V) ^ | ||
1614 | 0xfffff80000000000; | ||
1615 | kern_linear_pte_xor[1] |= (_PAGE_CP_4V | _PAGE_CV_4V | | ||
1616 | _PAGE_P_4V | _PAGE_W_4V); | ||
1617 | |||
1618 | pg_iobits = (_PAGE_VALID | _PAGE_PRESENT_4V | __DIRTY_BITS_4V | | ||
1619 | __ACCESS_BITS_4V | _PAGE_E_4V); | ||
1620 | |||
1621 | _PAGE_SZBITS = _PAGE_SZBITS_4V; | ||
1622 | _PAGE_ALL_SZ_BITS = (_PAGE_SZ16GB_4V | _PAGE_SZ2GB_4V | | ||
1623 | _PAGE_SZ256MB_4V | _PAGE_SZ32MB_4V | | ||
1624 | _PAGE_SZ4MB_4V | _PAGE_SZ512K_4V | | ||
1625 | _PAGE_SZ64K_4V | _PAGE_SZ8K_4V); | ||
1626 | |||
1627 | page_none = _PAGE_PRESENT_4V | _PAGE_ACCESSED_4V | _PAGE_CACHE_4V; | ||
1628 | page_shared = (_PAGE_VALID | _PAGE_PRESENT_4V | _PAGE_CACHE_4V | | ||
1629 | __ACCESS_BITS_4V | _PAGE_WRITE_4V | _PAGE_EXEC_4V); | ||
1630 | page_copy = (_PAGE_VALID | _PAGE_PRESENT_4V | _PAGE_CACHE_4V | | ||
1631 | __ACCESS_BITS_4V | _PAGE_EXEC_4V); | ||
1632 | page_readonly = (_PAGE_VALID | _PAGE_PRESENT_4V | _PAGE_CACHE_4V | | ||
1633 | __ACCESS_BITS_4V | _PAGE_EXEC_4V); | ||
1634 | |||
1635 | page_exec_bit = _PAGE_EXEC_4V; | ||
1636 | |||
1637 | prot_init_common(page_none, page_shared, page_copy, page_readonly, | ||
1638 | page_exec_bit); | ||
1639 | } | ||
1640 | |||
1641 | unsigned long pte_sz_bits(unsigned long sz) | ||
1642 | { | ||
1643 | if (tlb_type == hypervisor) { | ||
1644 | switch (sz) { | ||
1645 | case 8 * 1024: | ||
1646 | default: | ||
1647 | return _PAGE_SZ8K_4V; | ||
1648 | case 64 * 1024: | ||
1649 | return _PAGE_SZ64K_4V; | ||
1650 | case 512 * 1024: | ||
1651 | return _PAGE_SZ512K_4V; | ||
1652 | case 4 * 1024 * 1024: | ||
1653 | return _PAGE_SZ4MB_4V; | ||
1654 | }; | ||
1655 | } else { | ||
1656 | switch (sz) { | ||
1657 | case 8 * 1024: | ||
1658 | default: | ||
1659 | return _PAGE_SZ8K_4U; | ||
1660 | case 64 * 1024: | ||
1661 | return _PAGE_SZ64K_4U; | ||
1662 | case 512 * 1024: | ||
1663 | return _PAGE_SZ512K_4U; | ||
1664 | case 4 * 1024 * 1024: | ||
1665 | return _PAGE_SZ4MB_4U; | ||
1666 | }; | ||
1667 | } | ||
1668 | } | ||
1669 | |||
1670 | pte_t mk_pte_io(unsigned long page, pgprot_t prot, int space, unsigned long page_size) | ||
1671 | { | ||
1672 | pte_t pte; | ||
1673 | |||
1674 | pte_val(pte) = page | pgprot_val(pgprot_noncached(prot)); | ||
1675 | pte_val(pte) |= (((unsigned long)space) << 32); | ||
1676 | pte_val(pte) |= pte_sz_bits(page_size); | ||
1677 | |||
1678 | return pte; | ||
1679 | } | ||
1680 | |||
1681 | static unsigned long kern_large_tte(unsigned long paddr) | ||
1682 | { | ||
1683 | unsigned long val; | ||
1684 | |||
1685 | val = (_PAGE_VALID | _PAGE_SZ4MB_4U | | ||
1686 | _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_P_4U | | ||
1687 | _PAGE_EXEC_4U | _PAGE_L_4U | _PAGE_W_4U); | ||
1688 | if (tlb_type == hypervisor) | ||
1689 | val = (_PAGE_VALID | _PAGE_SZ4MB_4V | | ||
1690 | _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_P_4V | | ||
1691 | _PAGE_EXEC_4V | _PAGE_W_4V); | ||
1692 | |||
1693 | return val | paddr; | ||
1694 | } | ||
1695 | |||
1696 | /* | ||
1697 | * Translate PROM's mapping we capture at boot time into physical address. | ||
1698 | * The second parameter is only set from prom_callback() invocations. | ||
1699 | */ | ||
1700 | unsigned long prom_virt_to_phys(unsigned long promva, int *error) | ||
1701 | { | ||
1702 | unsigned long mask; | ||
1703 | int i; | ||
1704 | |||
1705 | mask = _PAGE_PADDR_4U; | ||
1706 | if (tlb_type == hypervisor) | ||
1707 | mask = _PAGE_PADDR_4V; | ||
1708 | |||
1709 | for (i = 0; i < prom_trans_ents; i++) { | ||
1710 | struct linux_prom_translation *p = &prom_trans[i]; | ||
1711 | |||
1712 | if (promva >= p->virt && | ||
1713 | promva < (p->virt + p->size)) { | ||
1714 | unsigned long base = p->data & mask; | ||
1715 | |||
1716 | if (error) | ||
1717 | *error = 0; | ||
1718 | return base + (promva & (8192 - 1)); | ||
1719 | } | ||
1720 | } | ||
1721 | if (error) | ||
1722 | *error = 1; | ||
1723 | return 0UL; | ||
1724 | } | ||
1725 | |||
1726 | /* XXX We should kill off this ugly thing at so me point. XXX */ | ||
1727 | unsigned long sun4u_get_pte(unsigned long addr) | ||
1728 | { | ||
1729 | pgd_t *pgdp; | ||
1730 | pud_t *pudp; | ||
1731 | pmd_t *pmdp; | ||
1732 | pte_t *ptep; | ||
1733 | unsigned long mask = _PAGE_PADDR_4U; | ||
1734 | |||
1735 | if (tlb_type == hypervisor) | ||
1736 | mask = _PAGE_PADDR_4V; | ||
1737 | |||
1738 | if (addr >= PAGE_OFFSET) | ||
1739 | return addr & mask; | ||
1740 | |||
1741 | if ((addr >= LOW_OBP_ADDRESS) && (addr < HI_OBP_ADDRESS)) | ||
1742 | return prom_virt_to_phys(addr, NULL); | ||
1743 | |||
1744 | pgdp = pgd_offset_k(addr); | ||
1745 | pudp = pud_offset(pgdp, addr); | ||
1746 | pmdp = pmd_offset(pudp, addr); | ||
1747 | ptep = pte_offset_kernel(pmdp, addr); | ||
1748 | |||
1749 | return pte_val(*ptep) & mask; | ||
1750 | } | ||
1751 | |||
1752 | /* If not locked, zap it. */ | ||
1753 | void __flush_tlb_all(void) | ||
1754 | { | ||
1755 | unsigned long pstate; | ||
1756 | int i; | ||
1757 | |||
1758 | __asm__ __volatile__("flushw\n\t" | ||
1759 | "rdpr %%pstate, %0\n\t" | ||
1760 | "wrpr %0, %1, %%pstate" | ||
1761 | : "=r" (pstate) | ||
1762 | : "i" (PSTATE_IE)); | ||
1763 | if (tlb_type == spitfire) { | ||
1764 | for (i = 0; i < 64; i++) { | ||
1765 | /* Spitfire Errata #32 workaround */ | ||
1766 | /* NOTE: Always runs on spitfire, so no | ||
1767 | * cheetah+ page size encodings. | ||
1768 | */ | ||
1769 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
1770 | "flush %%g6" | ||
1771 | : /* No outputs */ | ||
1772 | : "r" (0), | ||
1773 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
1774 | |||
1775 | if (!(spitfire_get_dtlb_data(i) & _PAGE_L_4U)) { | ||
1776 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
1777 | "membar #Sync" | ||
1778 | : /* no outputs */ | ||
1779 | : "r" (TLB_TAG_ACCESS), "i" (ASI_DMMU)); | ||
1780 | spitfire_put_dtlb_data(i, 0x0UL); | ||
1781 | } | ||
1782 | |||
1783 | /* Spitfire Errata #32 workaround */ | ||
1784 | /* NOTE: Always runs on spitfire, so no | ||
1785 | * cheetah+ page size encodings. | ||
1786 | */ | ||
1787 | __asm__ __volatile__("stxa %0, [%1] %2\n\t" | ||
1788 | "flush %%g6" | ||
1789 | : /* No outputs */ | ||
1790 | : "r" (0), | ||
1791 | "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU)); | ||
1792 | |||
1793 | if (!(spitfire_get_itlb_data(i) & _PAGE_L_4U)) { | ||
1794 | __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" | ||
1795 | "membar #Sync" | ||
1796 | : /* no outputs */ | ||
1797 | : "r" (TLB_TAG_ACCESS), "i" (ASI_IMMU)); | ||
1798 | spitfire_put_itlb_data(i, 0x0UL); | ||
1799 | } | ||
1800 | } | ||
1801 | } else if (tlb_type == cheetah || tlb_type == cheetah_plus) { | ||
1802 | cheetah_flush_dtlb_all(); | ||
1803 | cheetah_flush_itlb_all(); | ||
1804 | } | ||
1805 | __asm__ __volatile__("wrpr %0, 0, %%pstate" | ||
1806 | : : "r" (pstate)); | ||
1807 | } | ||
1808 | |||
1809 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
1810 | |||
1811 | void online_page(struct page *page) | ||
1812 | { | ||
1813 | ClearPageReserved(page); | ||
1814 | set_page_count(page, 0); | ||
1815 | free_cold_page(page); | ||
1816 | totalram_pages++; | ||
1817 | num_physpages++; | ||
1818 | } | ||
1819 | |||
1820 | int remove_memory(u64 start, u64 size) | ||
1821 | { | ||
1822 | return -EINVAL; | ||
1823 | } | ||
1824 | |||
1825 | #endif /* CONFIG_MEMORY_HOTPLUG */ | ||