aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/hash_utils_64.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/mm/hash_utils_64.c')
-rw-r--r--arch/powerpc/mm/hash_utils_64.c121
1 files changed, 83 insertions, 38 deletions
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index a47151e806ca..611ad084b7e7 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -49,7 +49,6 @@
49#include <asm/tlb.h> 49#include <asm/tlb.h>
50#include <asm/cacheflush.h> 50#include <asm/cacheflush.h>
51#include <asm/cputable.h> 51#include <asm/cputable.h>
52#include <asm/abs_addr.h>
53#include <asm/sections.h> 52#include <asm/sections.h>
54#include <asm/spu.h> 53#include <asm/spu.h>
55 54
@@ -94,6 +93,8 @@ int mmu_linear_psize = MMU_PAGE_4K;
94int mmu_virtual_psize = MMU_PAGE_4K; 93int mmu_virtual_psize = MMU_PAGE_4K;
95int mmu_vmalloc_psize = MMU_PAGE_4K; 94int mmu_vmalloc_psize = MMU_PAGE_4K;
96int mmu_io_psize = MMU_PAGE_4K; 95int mmu_io_psize = MMU_PAGE_4K;
96int mmu_kernel_ssize = MMU_SEGSIZE_256M;
97int mmu_highuser_ssize = MMU_SEGSIZE_256M;
97#ifdef CONFIG_HUGETLB_PAGE 98#ifdef CONFIG_HUGETLB_PAGE
98int mmu_huge_psize = MMU_PAGE_16M; 99int mmu_huge_psize = MMU_PAGE_16M;
99unsigned int HPAGE_SHIFT; 100unsigned int HPAGE_SHIFT;
@@ -146,7 +147,8 @@ struct mmu_psize_def mmu_psize_defaults_gp[] = {
146 147
147 148
148int htab_bolt_mapping(unsigned long vstart, unsigned long vend, 149int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
149 unsigned long pstart, unsigned long mode, int psize) 150 unsigned long pstart, unsigned long mode,
151 int psize, int ssize)
150{ 152{
151 unsigned long vaddr, paddr; 153 unsigned long vaddr, paddr;
152 unsigned int step, shift; 154 unsigned int step, shift;
@@ -159,8 +161,8 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
159 for (vaddr = vstart, paddr = pstart; vaddr < vend; 161 for (vaddr = vstart, paddr = pstart; vaddr < vend;
160 vaddr += step, paddr += step) { 162 vaddr += step, paddr += step) {
161 unsigned long hash, hpteg; 163 unsigned long hash, hpteg;
162 unsigned long vsid = get_kernel_vsid(vaddr); 164 unsigned long vsid = get_kernel_vsid(vaddr, ssize);
163 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff); 165 unsigned long va = hpt_va(vaddr, vsid, ssize);
164 166
165 tmp_mode = mode; 167 tmp_mode = mode;
166 168
@@ -168,14 +170,14 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
168 if (!in_kernel_text(vaddr)) 170 if (!in_kernel_text(vaddr))
169 tmp_mode = mode | HPTE_R_N; 171 tmp_mode = mode | HPTE_R_N;
170 172
171 hash = hpt_hash(va, shift); 173 hash = hpt_hash(va, shift, ssize);
172 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); 174 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP);
173 175
174 DBG("htab_bolt_mapping: calling %p\n", ppc_md.hpte_insert); 176 DBG("htab_bolt_mapping: calling %p\n", ppc_md.hpte_insert);
175 177
176 BUG_ON(!ppc_md.hpte_insert); 178 BUG_ON(!ppc_md.hpte_insert);
177 ret = ppc_md.hpte_insert(hpteg, va, paddr, 179 ret = ppc_md.hpte_insert(hpteg, va, paddr,
178 tmp_mode, HPTE_V_BOLTED, psize); 180 tmp_mode, HPTE_V_BOLTED, psize, ssize);
179 181
180 if (ret < 0) 182 if (ret < 0)
181 break; 183 break;
@@ -187,6 +189,37 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
187 return ret < 0 ? ret : 0; 189 return ret < 0 ? ret : 0;
188} 190}
189 191
192static int __init htab_dt_scan_seg_sizes(unsigned long node,
193 const char *uname, int depth,
194 void *data)
195{
196 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
197 u32 *prop;
198 unsigned long size = 0;
199
200 /* We are scanning "cpu" nodes only */
201 if (type == NULL || strcmp(type, "cpu") != 0)
202 return 0;
203
204 prop = (u32 *)of_get_flat_dt_prop(node, "ibm,processor-segment-sizes",
205 &size);
206 if (prop == NULL)
207 return 0;
208 for (; size >= 4; size -= 4, ++prop) {
209 if (prop[0] == 40) {
210 DBG("1T segment support detected\n");
211 cur_cpu_spec->cpu_features |= CPU_FTR_1T_SEGMENT;
212 }
213 return 1;
214 }
215 return 0;
216}
217
218static void __init htab_init_seg_sizes(void)
219{
220 of_scan_flat_dt(htab_dt_scan_seg_sizes, NULL);
221}
222
190static int __init htab_dt_scan_page_sizes(unsigned long node, 223static int __init htab_dt_scan_page_sizes(unsigned long node,
191 const char *uname, int depth, 224 const char *uname, int depth,
192 void *data) 225 void *data)
@@ -266,7 +299,6 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
266 return 0; 299 return 0;
267} 300}
268 301
269
270static void __init htab_init_page_sizes(void) 302static void __init htab_init_page_sizes(void)
271{ 303{
272 int rc; 304 int rc;
@@ -399,7 +431,7 @@ void create_section_mapping(unsigned long start, unsigned long end)
399{ 431{
400 BUG_ON(htab_bolt_mapping(start, end, __pa(start), 432 BUG_ON(htab_bolt_mapping(start, end, __pa(start),
401 _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX, 433 _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX,
402 mmu_linear_psize)); 434 mmu_linear_psize, mmu_kernel_ssize));
403} 435}
404#endif /* CONFIG_MEMORY_HOTPLUG */ 436#endif /* CONFIG_MEMORY_HOTPLUG */
405 437
@@ -450,9 +482,18 @@ void __init htab_initialize(void)
450 482
451 DBG(" -> htab_initialize()\n"); 483 DBG(" -> htab_initialize()\n");
452 484
485 /* Initialize segment sizes */
486 htab_init_seg_sizes();
487
453 /* Initialize page sizes */ 488 /* Initialize page sizes */
454 htab_init_page_sizes(); 489 htab_init_page_sizes();
455 490
491 if (cpu_has_feature(CPU_FTR_1T_SEGMENT)) {
492 mmu_kernel_ssize = MMU_SEGSIZE_1T;
493 mmu_highuser_ssize = MMU_SEGSIZE_1T;
494 printk(KERN_INFO "Using 1TB segments\n");
495 }
496
456 /* 497 /*
457 * Calculate the required size of the htab. We want the number of 498 * Calculate the required size of the htab. We want the number of
458 * PTEGs to equal one half the number of real pages. 499 * PTEGs to equal one half the number of real pages.
@@ -524,18 +565,20 @@ void __init htab_initialize(void)
524 if (base != dart_tablebase) 565 if (base != dart_tablebase)
525 BUG_ON(htab_bolt_mapping(base, dart_tablebase, 566 BUG_ON(htab_bolt_mapping(base, dart_tablebase,
526 __pa(base), mode_rw, 567 __pa(base), mode_rw,
527 mmu_linear_psize)); 568 mmu_linear_psize,
569 mmu_kernel_ssize));
528 if ((base + size) > dart_table_end) 570 if ((base + size) > dart_table_end)
529 BUG_ON(htab_bolt_mapping(dart_tablebase+16*MB, 571 BUG_ON(htab_bolt_mapping(dart_tablebase+16*MB,
530 base + size, 572 base + size,
531 __pa(dart_table_end), 573 __pa(dart_table_end),
532 mode_rw, 574 mode_rw,
533 mmu_linear_psize)); 575 mmu_linear_psize,
576 mmu_kernel_ssize));
534 continue; 577 continue;
535 } 578 }
536#endif /* CONFIG_U3_DART */ 579#endif /* CONFIG_U3_DART */
537 BUG_ON(htab_bolt_mapping(base, base + size, __pa(base), 580 BUG_ON(htab_bolt_mapping(base, base + size, __pa(base),
538 mode_rw, mmu_linear_psize)); 581 mode_rw, mmu_linear_psize, mmu_kernel_ssize));
539 } 582 }
540 583
541 /* 584 /*
@@ -554,7 +597,7 @@ void __init htab_initialize(void)
554 597
555 BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end, 598 BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end,
556 __pa(tce_alloc_start), mode_rw, 599 __pa(tce_alloc_start), mode_rw,
557 mmu_linear_psize)); 600 mmu_linear_psize, mmu_kernel_ssize));
558 } 601 }
559 602
560 htab_finish_init(); 603 htab_finish_init();
@@ -602,13 +645,7 @@ static void demote_segment_4k(struct mm_struct *mm, unsigned long addr)
602{ 645{
603 if (mm->context.user_psize == MMU_PAGE_4K) 646 if (mm->context.user_psize == MMU_PAGE_4K)
604 return; 647 return;
605#ifdef CONFIG_PPC_MM_SLICES
606 slice_set_user_psize(mm, MMU_PAGE_4K); 648 slice_set_user_psize(mm, MMU_PAGE_4K);
607#else /* CONFIG_PPC_MM_SLICES */
608 mm->context.user_psize = MMU_PAGE_4K;
609 mm->context.sllp = SLB_VSID_USER | mmu_psize_defs[MMU_PAGE_4K].sllp;
610#endif /* CONFIG_PPC_MM_SLICES */
611
612#ifdef CONFIG_SPU_BASE 649#ifdef CONFIG_SPU_BASE
613 spu_flush_all_slbs(mm); 650 spu_flush_all_slbs(mm);
614#endif 651#endif
@@ -628,7 +665,7 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
628 pte_t *ptep; 665 pte_t *ptep;
629 cpumask_t tmp; 666 cpumask_t tmp;
630 int rc, user_region = 0, local = 0; 667 int rc, user_region = 0, local = 0;
631 int psize; 668 int psize, ssize;
632 669
633 DBG_LOW("hash_page(ea=%016lx, access=%lx, trap=%lx\n", 670 DBG_LOW("hash_page(ea=%016lx, access=%lx, trap=%lx\n",
634 ea, access, trap); 671 ea, access, trap);
@@ -647,20 +684,22 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
647 DBG_LOW(" user region with no mm !\n"); 684 DBG_LOW(" user region with no mm !\n");
648 return 1; 685 return 1;
649 } 686 }
650 vsid = get_vsid(mm->context.id, ea);
651#ifdef CONFIG_PPC_MM_SLICES 687#ifdef CONFIG_PPC_MM_SLICES
652 psize = get_slice_psize(mm, ea); 688 psize = get_slice_psize(mm, ea);
653#else 689#else
654 psize = mm->context.user_psize; 690 psize = mm->context.user_psize;
655#endif 691#endif
692 ssize = user_segment_size(ea);
693 vsid = get_vsid(mm->context.id, ea, ssize);
656 break; 694 break;
657 case VMALLOC_REGION_ID: 695 case VMALLOC_REGION_ID:
658 mm = &init_mm; 696 mm = &init_mm;
659 vsid = get_kernel_vsid(ea); 697 vsid = get_kernel_vsid(ea, mmu_kernel_ssize);
660 if (ea < VMALLOC_END) 698 if (ea < VMALLOC_END)
661 psize = mmu_vmalloc_psize; 699 psize = mmu_vmalloc_psize;
662 else 700 else
663 psize = mmu_io_psize; 701 psize = mmu_io_psize;
702 ssize = mmu_kernel_ssize;
664 break; 703 break;
665 default: 704 default:
666 /* Not a valid range 705 /* Not a valid range
@@ -765,10 +804,10 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
765 804
766#ifdef CONFIG_PPC_HAS_HASH_64K 805#ifdef CONFIG_PPC_HAS_HASH_64K
767 if (psize == MMU_PAGE_64K) 806 if (psize == MMU_PAGE_64K)
768 rc = __hash_page_64K(ea, access, vsid, ptep, trap, local); 807 rc = __hash_page_64K(ea, access, vsid, ptep, trap, local, ssize);
769 else 808 else
770#endif /* CONFIG_PPC_HAS_HASH_64K */ 809#endif /* CONFIG_PPC_HAS_HASH_64K */
771 rc = __hash_page_4K(ea, access, vsid, ptep, trap, local); 810 rc = __hash_page_4K(ea, access, vsid, ptep, trap, local, ssize);
772 811
773#ifndef CONFIG_PPC_64K_PAGES 812#ifndef CONFIG_PPC_64K_PAGES
774 DBG_LOW(" o-pte: %016lx\n", pte_val(*ptep)); 813 DBG_LOW(" o-pte: %016lx\n", pte_val(*ptep));
@@ -790,6 +829,7 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
790 cpumask_t mask; 829 cpumask_t mask;
791 unsigned long flags; 830 unsigned long flags;
792 int local = 0; 831 int local = 0;
832 int ssize;
793 833
794 BUG_ON(REGION_ID(ea) != USER_REGION_ID); 834 BUG_ON(REGION_ID(ea) != USER_REGION_ID);
795 835
@@ -822,7 +862,8 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
822#endif /* CONFIG_PPC_64K_PAGES */ 862#endif /* CONFIG_PPC_64K_PAGES */
823 863
824 /* Get VSID */ 864 /* Get VSID */
825 vsid = get_vsid(mm->context.id, ea); 865 ssize = user_segment_size(ea);
866 vsid = get_vsid(mm->context.id, ea, ssize);
826 867
827 /* Hash doesn't like irqs */ 868 /* Hash doesn't like irqs */
828 local_irq_save(flags); 869 local_irq_save(flags);
@@ -835,28 +876,29 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
835 /* Hash it in */ 876 /* Hash it in */
836#ifdef CONFIG_PPC_HAS_HASH_64K 877#ifdef CONFIG_PPC_HAS_HASH_64K
837 if (mm->context.user_psize == MMU_PAGE_64K) 878 if (mm->context.user_psize == MMU_PAGE_64K)
838 __hash_page_64K(ea, access, vsid, ptep, trap, local); 879 __hash_page_64K(ea, access, vsid, ptep, trap, local, ssize);
839 else 880 else
840#endif /* CONFIG_PPC_HAS_HASH_64K */ 881#endif /* CONFIG_PPC_HAS_HASH_64K */
841 __hash_page_4K(ea, access, vsid, ptep, trap, local); 882 __hash_page_4K(ea, access, vsid, ptep, trap, local, ssize);
842 883
843 local_irq_restore(flags); 884 local_irq_restore(flags);
844} 885}
845 886
846void flush_hash_page(unsigned long va, real_pte_t pte, int psize, int local) 887void flush_hash_page(unsigned long va, real_pte_t pte, int psize, int ssize,
888 int local)
847{ 889{
848 unsigned long hash, index, shift, hidx, slot; 890 unsigned long hash, index, shift, hidx, slot;
849 891
850 DBG_LOW("flush_hash_page(va=%016x)\n", va); 892 DBG_LOW("flush_hash_page(va=%016x)\n", va);
851 pte_iterate_hashed_subpages(pte, psize, va, index, shift) { 893 pte_iterate_hashed_subpages(pte, psize, va, index, shift) {
852 hash = hpt_hash(va, shift); 894 hash = hpt_hash(va, shift, ssize);
853 hidx = __rpte_to_hidx(pte, index); 895 hidx = __rpte_to_hidx(pte, index);
854 if (hidx & _PTEIDX_SECONDARY) 896 if (hidx & _PTEIDX_SECONDARY)
855 hash = ~hash; 897 hash = ~hash;
856 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 898 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
857 slot += hidx & _PTEIDX_GROUP_IX; 899 slot += hidx & _PTEIDX_GROUP_IX;
858 DBG_LOW(" sub %d: hash=%x, hidx=%x\n", index, slot, hidx); 900 DBG_LOW(" sub %d: hash=%x, hidx=%x\n", index, slot, hidx);
859 ppc_md.hpte_invalidate(slot, va, psize, local); 901 ppc_md.hpte_invalidate(slot, va, psize, ssize, local);
860 } pte_iterate_hashed_end(); 902 } pte_iterate_hashed_end();
861} 903}
862 904
@@ -871,7 +913,7 @@ void flush_hash_range(unsigned long number, int local)
871 913
872 for (i = 0; i < number; i++) 914 for (i = 0; i < number; i++)
873 flush_hash_page(batch->vaddr[i], batch->pte[i], 915 flush_hash_page(batch->vaddr[i], batch->pte[i],
874 batch->psize, local); 916 batch->psize, batch->ssize, local);
875 } 917 }
876} 918}
877 919
@@ -897,17 +939,19 @@ void low_hash_fault(struct pt_regs *regs, unsigned long address)
897#ifdef CONFIG_DEBUG_PAGEALLOC 939#ifdef CONFIG_DEBUG_PAGEALLOC
898static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) 940static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
899{ 941{
900 unsigned long hash, hpteg, vsid = get_kernel_vsid(vaddr); 942 unsigned long hash, hpteg;
901 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff); 943 unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize);
944 unsigned long va = hpt_va(vaddr, vsid, mmu_kernel_ssize);
902 unsigned long mode = _PAGE_ACCESSED | _PAGE_DIRTY | 945 unsigned long mode = _PAGE_ACCESSED | _PAGE_DIRTY |
903 _PAGE_COHERENT | PP_RWXX | HPTE_R_N; 946 _PAGE_COHERENT | PP_RWXX | HPTE_R_N;
904 int ret; 947 int ret;
905 948
906 hash = hpt_hash(va, PAGE_SHIFT); 949 hash = hpt_hash(va, PAGE_SHIFT, mmu_kernel_ssize);
907 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); 950 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP);
908 951
909 ret = ppc_md.hpte_insert(hpteg, va, __pa(vaddr), 952 ret = ppc_md.hpte_insert(hpteg, va, __pa(vaddr),
910 mode, HPTE_V_BOLTED, mmu_linear_psize); 953 mode, HPTE_V_BOLTED,
954 mmu_linear_psize, mmu_kernel_ssize);
911 BUG_ON (ret < 0); 955 BUG_ON (ret < 0);
912 spin_lock(&linear_map_hash_lock); 956 spin_lock(&linear_map_hash_lock);
913 BUG_ON(linear_map_hash_slots[lmi] & 0x80); 957 BUG_ON(linear_map_hash_slots[lmi] & 0x80);
@@ -917,10 +961,11 @@ static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
917 961
918static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi) 962static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
919{ 963{
920 unsigned long hash, hidx, slot, vsid = get_kernel_vsid(vaddr); 964 unsigned long hash, hidx, slot;
921 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff); 965 unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize);
966 unsigned long va = hpt_va(vaddr, vsid, mmu_kernel_ssize);
922 967
923 hash = hpt_hash(va, PAGE_SHIFT); 968 hash = hpt_hash(va, PAGE_SHIFT, mmu_kernel_ssize);
924 spin_lock(&linear_map_hash_lock); 969 spin_lock(&linear_map_hash_lock);
925 BUG_ON(!(linear_map_hash_slots[lmi] & 0x80)); 970 BUG_ON(!(linear_map_hash_slots[lmi] & 0x80));
926 hidx = linear_map_hash_slots[lmi] & 0x7f; 971 hidx = linear_map_hash_slots[lmi] & 0x7f;
@@ -930,7 +975,7 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
930 hash = ~hash; 975 hash = ~hash;
931 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 976 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
932 slot += hidx & _PTEIDX_GROUP_IX; 977 slot += hidx & _PTEIDX_GROUP_IX;
933 ppc_md.hpte_invalidate(slot, va, mmu_linear_psize, 0); 978 ppc_md.hpte_invalidate(slot, va, mmu_linear_psize, mmu_kernel_ssize, 0);
934} 979}
935 980
936void kernel_map_pages(struct page *page, int numpages, int enable) 981void kernel_map_pages(struct page *page, int numpages, int enable)