arch/powerpc: Add 64TB support to ppc64
cover arch/powerpc: Add 64TB support to ppc64
Hi,
This patchset include patches for supporting 64TB with ppc64. I haven't booted this on hardware with 64TB memory yet. But they boot fine on real hardware with less memory. Changes extend VSID bits to 38 bits for a 256MB segment and 26 bits for 1TB segments.
Changes from V7:
* Address review feedback
Changes from V6:
* rebase to latest upstream (5b716ac728bcc01b1f2a7ed6e437196602237c27)
Changes from v5:
* Address review feedback
Changes from v4:
* Drop patch "arch/powerpc: properly offset the context bits for 1T segemnts" based on review feedback
* split CONTEXT_BITS related changes from patch 12
* Add a new doc update patch
Changes from v3:
* Address review comments.
* Added new patch to ensure proto-VSID isolation between kernel and user space
Changes from V2:
* Fix few FIXMEs in the patchset. I have added them as separate patch for easier review. That should help us to drop those changes if we don't agree.
Changes from V1:
* Drop the usage of structure (struct virt_addr) to carry virtual address. We now represent virtual address via vpn which is virtual address shifted right 12 bits.
Thanks,
-aneesh
PATCH 1/11 arch/powerpc: Replace open coded CONTEXT_BITS value
From: "Aneesh Kumar K.V" <[email protected]>
To clarify the meaning for future readers, replace the open coded 19 with CONTEXT_BITS
--- arch/powerpc/mm/mmu_context_hash64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/mmu_context_hash64.c +1 -1
@@ -34,7 +34,7 @@ static DEFINE_IDA(mmu_context_ida);* Each segment contains 2^28 bytes. Each context maps 2^44 bytes, * so we can support 2^19-1 contexts (19 == 35 + 28 - 44). */ -#define MAX_CONTEXT ((1UL << 19) - 1) +#define MAX_CONTEXT ((1UL << CONTEXT_BITS) - 1)int __init_new_context (void ) {
Signature · 1 line
1.7.10
PATCH 2/11 arch/powerpc: Use hpt_va to compute virtual address
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
Don't open code the same
--- arch/powerpc/platforms/cell/beat_htab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/cell/beat_htab.c +1 -1
@@ -259,7 +259,7 @@ static void beat_lpar_hpte_updateboltedpp(unsigned long newpp,u64 dummy0, dummy1; vsid =get_kernel_vsid (ea,MMU_SEGSIZE_256M ); - va = (vsid <<28 ) | (ea &0x0fffffff ); + va =hpt_va (ea, vsid,MMU_SEGSIZE_256M );raw_spin_lock (&beat_htab_lock); slot =beat_lpar_hpte_find (va, psize);
Signature · 1 line
1.7.10
PATCH 3/11 arch/powerpc: Simplify hpte_decode
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
This patch simplify hpte_decode for easy switching of virtual address to virtual page number in the later patch
--- arch/powerpc/mm/hash_native_64.c | 49 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-)
arch/powerpc/mm/hash_native_64.c +28 -21
@@ -351,9 +351,10 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long va,static void hpte_decode (struct hash_pte *hpte,unsigned long slot,int *psize,int *ssize,unsigned long *va) { +unsigned long avpn, pteg, vpi;unsigned long hpte_r = hpte->r;unsigned long hpte_v = hpte->v; -unsigned long avpn; +unsigned long vsid, seg_off;int i, size, shift, penc;if (!(hpte_v &HPTE_V_LARGE ))
@@ -380,32 +381,38 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot, }/* This works for all page sizes, and for 256M and 1T segments */ + *ssize = hpte_v >>HPTE_V_SSIZE_SHIFT ; shift = mmu_psize_defs[size].shift; - avpn = (HPTE_V_AVPN_VAL (hpte_v) & ~mmu_psize_defs[size].avpnm) <<23 ; - -if (shift <23 ) { -unsigned long vpi, vsid, pteg; - pteg = slot /HPTES_PER_GROUP ; -if (hpte_v &HPTE_V_SECONDARY ) - pteg = ~pteg; -switch (hpte_v >>HPTE_V_SSIZE_SHIFT ) { -case MMU_SEGSIZE_256M : - vpi = ((avpn >>28 ) ^ pteg) & htab_hash_mask; -break ; -case MMU_SEGSIZE_1T : - vsid = avpn >>40 ; + avpn = (HPTE_V_AVPN_VAL (hpte_v) & ~mmu_psize_defs[size].avpnm); + pteg = slot /HPTES_PER_GROUP ; +if (hpte_v &HPTE_V_SECONDARY ) + pteg = ~pteg; + +switch (*ssize) { +case MMU_SEGSIZE_256M : +/* We only have 28 - 23 bits of seg_off in avpn */ + seg_off = (avpn &0x1f ) <<23 ; + vsid = avpn >>5 ; +/* We can find more bits from the pteg value */ +if (shift <23 ) { + vpi = (vsid ^ pteg) & htab_hash_mask; + seg_off |= vpi << shift; + } + *va = vsid <<SID_SHIFT | seg_off; +case MMU_SEGSIZE_1T : +/* We only have 40 - 23 bits of seg_off in avpn */ + seg_off = (avpn &0x1ffff ) <<23 ; + vsid = avpn >>17 ; +if (shift <23 ) { vpi = (vsid ^ (vsid <<25 ) ^ pteg) & htab_hash_mask; -break ; -default : - avpn = vpi = size =0 ; + seg_off |= vpi << shift; } - avpn |= (vpi << mmu_psize_defs[size].shift); + *va = vsid <<SID_SHIFT_1T | seg_off; +default : + *va = size =0 ; } - - *va = avpn; *psize = size; - *ssize = hpte_v >>HPTE_V_SSIZE_SHIFT ; }/*
Signature · 1 line
1.7.10
PATCH 4/11 arch/powerpc: Convert virtual address to vpn
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
This patch convert different functions to take virtual page number instead of virtual address. Virtual page number is virtual address shifted right by VPN_SHIFT (12) bits. This enable us to have an address range of upto 76 bits.
--- arch/powerpc/include/asm/kvm_book3s.h | 2 +- arch/powerpc/include/asm/machdep.h | 6 +- arch/powerpc/include/asm/mmu-hash64.h | 78 +++++++++++++++---- arch/powerpc/include/asm/pte-hash64-64k.h | 18 +++-- arch/powerpc/include/asm/tlbflush.h | 4 +- arch/powerpc/kvm/book3s_32_mmu_host.c | 8 +- arch/powerpc/kvm/book3s_64_mmu_host.c | 17 ++-- arch/powerpc/kvm/trace.h | 14 ++-- arch/powerpc/mm/hash_low_64.S | 97 ++++++++++++++--------- arch/powerpc/mm/hash_native_64.c | 121 +++++++++++++++++------------ arch/powerpc/mm/hash_utils_64.c | 30 +++---- arch/powerpc/mm/hugetlbpage-hash64.c | 15 ++-- arch/powerpc/mm/tlb_hash64.c | 11 +-- arch/powerpc/platforms/cell/beat_htab.c | 45 +++++------ arch/powerpc/platforms/ps3/htab.c | 22 +++--- arch/powerpc/platforms/pseries/lpar.c | 76 ++++++++---------- 16 files changed, 324 insertions(+), 240 deletions(-)
arch/powerpc/include/asm/kvm_book3s.h +1 -1
@@ -59,7 +59,7 @@ struct hpte_cache {struct hlist_node list_vpte;struct hlist_node list_vpte_long;struct rcu_head rcu_head; -u64 host_va; +u64 host_vpn;u64 pfn;ulong slot;struct kvmppc_pte pte;
arch/powerpc/include/asm/machdep.h +3 -3
@@ -34,19 +34,19 @@ struct machdep_calls {char *name;#ifdef CONFIG_PPC64 void (*hpte_invalidate)(unsigned long slot, -unsigned long va, +unsigned long vpn,int psize,int ssize,int local);long (*hpte_updatepp)(unsigned long slot,unsigned long newpp, -unsigned long va, +unsigned long vpn,int psize,int ssize,int local);void (*hpte_updateboltedpp)(unsigned long newpp,unsigned long ea,int psize,int ssize); long (*hpte_insert)(unsigned long hpte_group, - unsigned long va, + unsigned long vpn, unsigned long prpn, unsigned long rflags, unsigned long vflags,
arch/powerpc/include/asm/mmu-hash64.h +61 -17
118 lines not on this page · raw message
arch/powerpc/include/asm/pte-hash64-64k.h +10 -8
@@ -58,14 +58,16 @@/* Trick: we set __end to va + 64k, which happens works for * a 16M page as well as we want only one iteration */ -#define pte_iterate_hashed_subpages (rpte, psize, va, index, shift) \ - do { \ - unsigned long __end = va + PAGE_SIZE; \ - unsigned __split = (psize == MMU_PAGE_4K || \ - psize == MMU_PAGE_64K_AP); \ - shift = mmu_psize_defs[psize].shift; \ - for (index = 0; va < __end; index++, va += (1L << shift)) { \ - if (!__split || __rpte_sub_valid(rpte, index)) do { \ +#define pte_iterate_hashed_subpages (rpte, psize, vpn, index, shift) \ + do { \ + unsigned long __end = vpn + (1UL << (PAGE_SHIFT - VPN_SHIFT)); \ + unsigned __split = (psize == MMU_PAGE_4K || \ + psize == MMU_PAGE_64K_AP); \ + shift = mmu_psize_defs[psize].shift; \ + for (index = 0; vpn < __end; index++, \ + vpn += (1L << (shift - VPN_SHIFT))) { \ + if (!__split || __rpte_sub_valid(rpte, index)) \ + do {#define pte_iterate_hashed_end () } while(0); } } while(0)
arch/powerpc/include/asm/tlbflush.h +2 -2
@@ -95,7 +95,7 @@ struct ppc64_tlb_batch {unsigned long index;struct mm_struct *mm;real_pte_t pte[PPC64_TLB_BATCH_NR ]; -unsigned long vaddr[PPC64_TLB_BATCH_NR ]; +unsigned long vpn[PPC64_TLB_BATCH_NR ];unsigned int psize;int ssize; };
@@ -127,7 +127,7 @@ static inline void arch_leave_lazy_mmu_mode(void)#define arch_flush_lazy_mmu_mode () do {} while (0) -extern void flush_hash_page (unsigned long va,real_pte_t pte,int psize, +extern void flush_hash_page (unsigned long vpn,real_pte_t pte,int psize,int ssize,int local);extern void flush_hash_range (unsigned long number,int local);
arch/powerpc/kvm/book3s_32_mmu_host.c +4 -4
@@ -141,7 +141,7 @@ extern char etext[];int kvmppc_mmu_map_page (struct kvm_vcpu *vcpu,struct kvmppc_pte *orig_pte) {pfn_t hpaddr; -u64 va; +u64 vpn;u64 vsid;struct kvmppc_sid_map *map;volatile u32 *pteg;
@@ -173,7 +173,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)BUG_ON (!map); vsid = map->host_vsid; - va = (vsid <<SID_SHIFT ) | (eaddr & ~ESID_MASK ); + vpn = (vsid << (SID_SHIFT - VPN_SHIFT)) | ((eaddr & ~ESID_MASK) >> VPN_SHIFT) next_pteg:if (rr ==16 ) {
@@ -244,11 +244,11 @@ next_pteg:dprintk_mmu ("KVM: %c%c Map 0x%llx: [%lx] 0x%llx (0x%llx) -> %lx\n" , orig_pte->may_write ?'w' :'-' , orig_pte->may_execute ?'x' :'-' , - orig_pte->eaddr, (ulong )pteg, va, + orig_pte->eaddr, (ulong )pteg, vpn, orig_pte->vpage, hpaddr); pte->slot = (ulong)&pteg[rr]; - pte->host_va = va; + pte->host_vpn = vpn; pte->pte = *orig_pte; pte->pfn = hpaddr >>PAGE_SHIFT ;
arch/powerpc/kvm/book3s_64_mmu_host.c +10 -7
@@ -33,7 +33,7 @@void kvmppc_mmu_invalidate_pte (struct kvm_vcpu *vcpu,struct hpte_cache *pte) { - ppc_md.hpte_invalidate (pte->slot, pte->host_va, + ppc_md.hpte_invalidate (pte->slot, pte->host_vpn,MMU_PAGE_4K ,MMU_SEGSIZE_256M , false); }
@@ -80,8 +80,9 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)int kvmppc_mmu_map_page (struct kvm_vcpu *vcpu,struct kvmppc_pte *orig_pte) { +unsigned long vpn;pfn_t hpaddr; -ulong hash, hpteg, va; +ulong hash, hpteg;u64 vsid;int ret;int rflags =0x192 ;
@@ -117,7 +118,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) } vsid = map->host_vsid; - va =hpt_va (orig_pte->eaddr, vsid,MMU_SEGSIZE_256M ); + vpn =hpt_vpn (orig_pte->eaddr, vsid,MMU_SEGSIZE_256M );if (!orig_pte->may_write) rflags |=HPTE_R_PP ;
@@ -129,7 +130,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)else kvmppc_mmu_flush_icache (hpaddr >>PAGE_SHIFT ); - hash =hpt_hash (va,PTE_SIZE ,MMU_SEGSIZE_256M ); + hash =hpt_hash (vpn,PTE_SIZE ,MMU_SEGSIZE_256M ); map_again: hpteg = ((hash & htab_hash_mask) *HPTES_PER_GROUP );
@@ -141,7 +142,8 @@ map_again: goto out; } - ret = ppc_md.hpte_insert (hpteg, va, hpaddr, rflags, vflags,MMU_PAGE_4K ,MMU_SEGSIZE_256M ); + ret = ppc_md.hpte_insert (hpteg, vpn, hpaddr, rflags, vflags, +MMU_PAGE_4K ,MMU_SEGSIZE_256M );if (ret <0 ) {/* If we couldn't map a primary PTE, try a secondary */
@@ -152,7 +154,8 @@ map_again: }else {struct hpte_cache *pte =kvmppc_mmu_hpte_cache_next (vcpu); -trace_kvm_book3s_64_mmu_map (rflags, hpteg, va, hpaddr, orig_pte); +trace_kvm_book3s_64_mmu_map (rflags, hpteg, + vpn, hpaddr, orig_pte);/* The ppc_md code may give us a secondary entry even though we asked for a primary. Fix up. */
@@ -162,7 +165,7 @@ map_again: } pte->slot = hpteg + (ret &7 ); - pte->host_va = va; + pte->host_vpn = vpn; pte->pte = *orig_pte; pte->pfn = hpaddr >>PAGE_SHIFT ;
arch/powerpc/kvm/trace.h +7 -7
@@ -189,7 +189,7 @@ TRACE_EVENT(kvm_book3s_mmu_map,TP_ARGS (pte),TP_STRUCT__entry ( - __field( u64, host_va ) + __field( u64, host_vpn ) __field( u64, pfn ) __field( ulong, eaddr ) __field( u64, vpage )
@@ -198,7 +198,7 @@ TRACE_EVENT(kvm_book3s_mmu_map, ), TP_fast_assign( - __entry->host_va = pte->host_va; + __entry->host_vpn = pte->host_vpn; __entry->pfn = pte->pfn; __entry->eaddr = pte->pte.eaddr; __entry->vpage = pte->pte.vpage;
@@ -208,8 +208,8 @@ TRACE_EVENT(kvm_book3s_mmu_map, (pte->pte.may_execute ?0x1 :0 ); ), -TP_printk ("Map: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]" , - __entry->host_va, __entry->pfn, __entry->eaddr, +TP_printk ("Map: hvpn=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]" , + __entry->host_vpn, __entry->pfn, __entry->eaddr, __entry->vpage, __entry->raddr, __entry->flags) );
@@ -218,7 +218,7 @@ TRACE_EVENT(kvm_book3s_mmu_invalidate,TP_ARGS (pte),TP_STRUCT__entry ( - __field( u64, host_va ) + __field( u64, host_vpn ) __field( u64, pfn ) __field( ulong, eaddr ) __field( u64, vpage )
@@ -227,7 +227,7 @@ TRACE_EVENT(kvm_book3s_mmu_invalidate, ), TP_fast_assign( - __entry->host_va = pte->host_va; + __entry->host_vpn = pte->host_vpn; __entry->pfn = pte->pfn; __entry->eaddr = pte->pte.eaddr; __entry->vpage = pte->pte.vpage;
@@ -238,7 +238,7 @@ TRACE_EVENT(kvm_book3s_mmu_invalidate, ),TP_printk ("Flush: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]" , - __entry->host_va, __entry->pfn, __entry->eaddr, + __entry->host_vpn, __entry->pfn, __entry->eaddr, __entry->vpage, __entry->raddr, __entry->flags) );
arch/powerpc/mm/hash_low_64.S +60 -37
223 lines not on this page · raw message
arch/powerpc/mm/hash_native_64.c +72 -49
322 lines not on this page · raw message
arch/powerpc/mm/hash_utils_64.c +15 -15
@@ -192,18 +192,18 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend, vaddr += step, paddr += step) {unsigned long hash, hpteg;unsigned long vsid =get_kernel_vsid (vaddr, ssize); -unsigned long va =hpt_va (vaddr, vsid, ssize); +unsigned long vpn =hpt_vpn (vaddr, vsid, ssize);unsigned long tprot = prot;/* Make kernel text executable */ if (overlaps_kernel_text (vaddr, vaddr + step)) tprot &= ~HPTE_R_N ; - hash =hpt_hash (va, shift, ssize); + hash =hpt_hash (vpn, shift, ssize); hpteg = ((hash & htab_hash_mask) *HPTES_PER_GROUP );BUG_ON (!ppc_md.hpte_insert); - ret = ppc_md.hpte_insert (hpteg, va, paddr, tprot, + ret = ppc_md.hpte_insert (hpteg, vpn, paddr, tprot,HPTE_V_BOLTED , psize, ssize);if (ret <0 )
@@ -1153,21 +1153,21 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,/* WARNING: This is called from hash_low_64.S, if you change this prototype, * do not forget to update the assembly call site ! */ -void flush_hash_page (unsigned long va,real_pte_t pte,int psize,int ssize, +void flush_hash_page (unsigned long vpn,real_pte_t pte,int psize,int ssize,int local) {unsigned long hash, index, shift, hidx, slot; -DBG_LOW ("flush_hash_page(va=%016lx)\n" , va); - pte_iterate_hashed_subpages(pte, psize, va, index, shift) { - hash =hpt_hash (va, shift, ssize); +DBG_LOW ("flush_hash_page(vpn=%016lx)\n" , vpn); + pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) { + hash =hpt_hash (vpn, shift, ssize); hidx =__rpte_to_hidx (pte, index);if (hidx & _PTEIDX_SECONDARY) hash = ~hash; slot = (hash & htab_hash_mask) *HPTES_PER_GROUP ; slot += hidx & _PTEIDX_GROUP_IX;DBG_LOW (" sub %ld: hash=%lx, hidx=%lx\n" , index, slot, hidx); - ppc_md.hpte_invalidate (slot, va, psize, ssize, local); + ppc_md.hpte_invalidate (slot, vpn, psize, ssize, local); }pte_iterate_hashed_end (); }
@@ -1181,7 +1181,7 @@ void flush_hash_range(unsigned long number, int local) &__get_cpu_var (ppc64_tlb_batch);for (i =0 ; i < number; i++) -flush_hash_page (batch->vaddr[i], batch->pte[i], +flush_hash_page (batch->vpn[i], batch->pte[i], batch->psize, batch->ssize, local); } }
@@ -1208,14 +1208,14 @@ static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) {unsigned long hash, hpteg;unsigned long vsid =get_kernel_vsid (vaddr, mmu_kernel_ssize); -unsigned long va =hpt_va (vaddr, vsid, mmu_kernel_ssize); +unsigned long vpn =hpt_vpn (vaddr, vsid, mmu_kernel_ssize);unsigned long mode =htab_convert_pte_flags (PAGE_KERNEL );int ret; - hash =hpt_hash (va,PAGE_SHIFT , mmu_kernel_ssize); + hash =hpt_hash (vpn,PAGE_SHIFT , mmu_kernel_ssize); hpteg = ((hash & htab_hash_mask) *HPTES_PER_GROUP ); - ret = ppc_md.hpte_insert (hpteg, va,__pa (vaddr), + ret = ppc_md.hpte_insert (hpteg, vpn,__pa (vaddr), mode,HPTE_V_BOLTED , mmu_linear_psize, mmu_kernel_ssize);BUG_ON (ret <0 );
@@ -1229,9 +1229,9 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi) {unsigned long hash, hidx, slot;unsigned long vsid =get_kernel_vsid (vaddr, mmu_kernel_ssize); -unsigned long va =hpt_va (vaddr, vsid, mmu_kernel_ssize); +unsigned long vpn =hpt_vpn (vaddr, vsid, mmu_kernel_ssize); - hash =hpt_hash (va,PAGE_SHIFT , mmu_kernel_ssize); + hash =hpt_hash (vpn,PAGE_SHIFT , mmu_kernel_ssize);spin_lock (&linear_map_hash_lock);BUG_ON (!(linear_map_hash_slots[lmi] &0x80 )); hidx = linear_map_hash_slots[lmi] &0x7f ;
@@ -1241,7 +1241,7 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi) hash = ~hash; slot = (hash & htab_hash_mask) *HPTES_PER_GROUP ; slot += hidx & _PTEIDX_GROUP_IX; - ppc_md.hpte_invalidate (slot, va, mmu_linear_psize, mmu_kernel_ssize,0 ); + ppc_md.hpte_invalidate (slot, vpn, mmu_linear_psize, mmu_kernel_ssize,0 ); }void kernel_map_pages (struct page *page,int numpages,int enable)
arch/powerpc/mm/hugetlbpage-hash64.c +8 -7
@@ -18,14 +18,15 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, pte_t *ptep, unsigned long trap, int local, int ssize, unsigned int shift, unsigned int mmu_psize) { + unsigned long vpn;unsigned long old_pte, new_pte; -unsigned long va, rflags, pa, sz; +unsigned long rflags, pa, sz;long slot;BUG_ON (shift != mmu_psize_defs[mmu_psize].shift);/* Search the Linux page table for a match with va */ - va =hpt_va (ea, vsid, ssize); + vpn =hpt_vpn (ea, vsid, ssize);/* At this point, we have a pte (old_pte) which can be used to build * or update an HPTE. There are 2 cases:
@@ -69,19 +70,19 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,/* There MIGHT be an HPTE for this pte */ unsigned long hash, slot; - hash =hpt_hash (va, shift, ssize); + hash =hpt_hash (vpn, shift, ssize);if (old_pte & _PAGE_F_SECOND) hash = ~hash; slot = (hash & htab_hash_mask) *HPTES_PER_GROUP ; slot += (old_pte & _PAGE_F_GIX) >>12 ; -if (ppc_md.hpte_updatepp (slot, rflags, va, mmu_psize, +if (ppc_md.hpte_updatepp (slot, rflags, vpn, mmu_psize, ssize, local) ==-1 ) old_pte &= ~_PAGE_HPTEFLAGS; }if (likely (!(old_pte & _PAGE_HASHPTE))) { -unsigned long hash =hpt_hash (va, shift, ssize); +unsigned long hash =hpt_hash (vpn, shift, ssize);unsigned long hpte_group; pa =pte_pfn (__pte (old_pte)) <<PAGE_SHIFT ;
@@ -101,14 +102,14 @@ repeat: _PAGE_COHERENT | _PAGE_GUARDED));/* Insert into the hash table, primary slot */ - slot = ppc_md.hpte_insert (hpte_group, va, pa, rflags,0 , + slot = ppc_md.hpte_insert (hpte_group, vpn, pa, rflags,0 , mmu_psize, ssize);/* Primary is full, try the secondary */ if (unlikely (slot ==-1 )) { hpte_group = ((~hash & htab_hash_mask) *HPTES_PER_GROUP ) & ~0x7UL ; - slot = ppc_md.hpte_insert (hpte_group, va, pa, rflags, + slot = ppc_md.hpte_insert (hpte_group, vpn, pa, rflags,HPTE_V_SECONDARY , mmu_psize, ssize);if (slot ==-1 ) {
arch/powerpc/mm/tlb_hash64.c +6 -5
@@ -42,8 +42,9 @@ DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);void hpte_need_flush (struct mm_struct *mm,unsigned long addr,pte_t *ptep,unsigned long pte,int huge) { +unsigned long vpn;struct ppc64_tlb_batch *batch = &get_cpu_var (ppc64_tlb_batch); -unsigned long vsid, vaddr; +unsigned long vsid;unsigned int psize;int ssize;real_pte_t rpte;
@@ -86,7 +87,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, vsid =get_kernel_vsid (addr, mmu_kernel_ssize); ssize = mmu_kernel_ssize; } - vaddr =hpt_va (addr, vsid, ssize); + vpn =hpt_vpn (addr, vsid, ssize); rpte =__real_pte (__pte (pte), ptep);/*
@@ -96,7 +97,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr,* and decide to use local invalidates instead... */ if (!batch->active) { -flush_hash_page (vaddr, rpte, psize, ssize,0 ); +flush_hash_page (vpn, rpte, psize, ssize,0 );put_cpu_var (ppc64_tlb_batch);return ; }
@@ -122,7 +123,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, batch->ssize = ssize; } batch->pte[i] = rpte; - batch->vaddr[i] = vaddr; + batch->vpn[i] = vpn; batch->index = ++i;if (i >=PPC64_TLB_BATCH_NR )__flush_tlb_pending (batch);
@@ -146,7 +147,7 @@ void __flush_tlb_pending(struct ppc64_tlb_batch *batch)if (cpumask_equal (mm_cpumask (batch->mm), tmp)) local =1 ;if (i ==1 ) -flush_hash_page (batch->vaddr[0 ], batch->pte[0 ], +flush_hash_page (batch->vpn[0 ], batch->pte[0 ], batch->psize, batch->ssize, local);else flush_hash_range (i, local);
arch/powerpc/platforms/cell/beat_htab.c +23 -22
142 lines not on this page · raw message
arch/powerpc/platforms/ps3/htab.c +11 -11
@@ -43,7 +43,7 @@ enum ps3_lpar_vas_id {static DEFINE_SPINLOCK (ps3_htab_lock); -static long ps3_hpte_insert (unsigned long hpte_group,unsigned long va, +static long ps3_hpte_insert (unsigned long hpte_group,unsigned long vpn,unsigned long pa,unsigned long rflags,unsigned long vflags,int psize,int ssize) {
@@ -61,7 +61,7 @@ static long ps3_hpte_insert(unsigned long hpte_group, unsigned long va,*/ vflags &= ~HPTE_V_SECONDARY ; - hpte_v =hpte_encode_v (va, psize, ssize) | vflags |HPTE_V_VALID ; + hpte_v =hpte_encode_v (vpn, psize, ssize) | vflags |HPTE_V_VALID ; hpte_r =hpte_encode_r (ps3_mm_phys_to_lpar (pa), psize) | rflags;spin_lock_irqsave (&ps3_htab_lock, flags);
@@ -75,8 +75,8 @@ static long ps3_hpte_insert(unsigned long hpte_group, unsigned long va,if (result) {/* all entries bolted !*/ -pr_info ("%s:result=%d va=%lx pa=%lx ix=%lx v=%llx r=%llx\n" , - __func__, result, va, pa, hpte_group, hpte_v, hpte_r); +pr_info ("%s:result=%d vpn=%lx pa=%lx ix=%lx v=%llx r=%llx\n" , + __func__, result, vpn, pa, hpte_group, hpte_v, hpte_r);BUG (); }
@@ -107,7 +107,7 @@ static long ps3_hpte_remove(unsigned long hpte_group) }static long ps3_hpte_updatepp (unsigned long slot,unsigned long newpp, -unsigned long va,int psize,int ssize,int local) +unsigned long vpn,int psize,int ssize,int local) {int result;u64 hpte_v, want_v, hpte_rs;
@@ -115,7 +115,7 @@ static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp,unsigned long flags;long ret; - want_v =hpte_encode_v (va, psize, ssize); + want_v =hpte_encode_v (vpn, psize, ssize);spin_lock_irqsave (&ps3_htab_lock, flags);
@@ -125,8 +125,8 @@ static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp, &hpte_rs);if (result) { -pr_info ("%s: res=%d read va=%lx slot=%lx psize=%d\n" , - __func__, result, va, slot, psize); +pr_info ("%s: res=%d read vpn=%lx slot=%lx psize=%d\n" , + __func__, result, vpn, slot, psize);BUG (); }
@@ -159,7 +159,7 @@ static void ps3_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,panic ("ps3_hpte_updateboltedpp() not implemented" ); } -static void ps3_hpte_invalidate (unsigned long slot,unsigned long va, +static void ps3_hpte_invalidate (unsigned long slot,unsigned long vpn,int psize,int ssize,int local) {unsigned long flags;
@@ -170,8 +170,8 @@ static void ps3_hpte_invalidate(unsigned long slot, unsigned long va, result =lv1_write_htab_entry (PS3_LPAR_VAS_ID_CURRENT , slot,0 ,0 );if (result) { -pr_info ("%s: res=%d va=%lx slot=%lx psize=%d\n" , - __func__, result, va, slot, psize); +pr_info ("%s: res=%d vpn=%lx slot=%lx psize=%d\n" , + __func__, result, vpn, slot, psize);BUG (); }
arch/powerpc/platforms/pseries/lpar.c +31 -45
179 lines not on this page · raw message
Signature · 1 line
1.7.10
Re: [PATCH -V8 04/11] arch/powerpc: Convert virtual address to vpn
Quoted 8 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
This patch convert different functions to take virtual page number instead of virtual address. Virtual page number is virtual address shifted right by
VPN_SHIFT(12) bits. This enable us to have an address range of upto 76 bits.Signed-off-by Aneesh Kumar K.V <[email protected]>
PATCH 5/11 arch/powerpc: Make KERN_VIRT_SIZE not dependend on PGTABLE_RANGE
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
As we keep increasing PGTABLE_RANGE we need not increase the virual map area for kernel.
--- arch/powerpc/include/asm/pgtable-ppc64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/pgtable-ppc64.h +1 -1
@@ -41,7 +41,7 @@#else #define KERN_VIRT_START ASM_CONST(0xD000000000000000)#endif -#define KERN_VIRT_SIZE PGTABLE_RANGE +#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000)/* * The vmalloc space starts at the beginning of that region, and
Signature · 1 line
1.7.10
PATCH 6/11 arch/powerpc: Increase the slice range to 64TB
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
This patch makes the high psizes mask as an unsigned char array so that we can have more than 16TB. Currently we support upto 64TB
--- arch/powerpc/include/asm/mmu-hash64.h | 6 +- arch/powerpc/include/asm/page_64.h | 6 +- arch/powerpc/mm/hash_utils_64.c | 15 +++-- arch/powerpc/mm/slb_low.S | 30 ++++++--- arch/powerpc/mm/slice.c | 107 +++++++++++++++++++++------------ 5 files changed, 109 insertions(+), 55 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +5 -1
@@ -460,7 +460,11 @@ typedef struct {#ifdef CONFIG_PPC_MM_SLICES u64 low_slices_psize;/* SLB page size encodings */ -u64 high_slices_psize;/* 4 bits per slice for now */ +/* +* Right now we support 64TB and 4 bits for each +* 1TB slice we need 32 bytes for 64TB. +*/ +unsigned char high_slices_psize[32 ];/* 4 bits per slice for now */ #else u16 sllp;/* SLB page size encoding */ #endif
arch/powerpc/include/asm/page_64.h +5 -1
@@ -82,7 +82,11 @@ extern u64 ppc64_pft_size;struct slice_mask {u16 low_slices; -u16 high_slices; +/* +* This should be derived out of PGTABLE_RANGE. For the current +* max 64TB, u64 should be ok. +*/ +u64 high_slices; };struct mm_struct ;
arch/powerpc/mm/hash_utils_64.c +9 -6
@@ -804,16 +804,19 @@ unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap)#ifdef CONFIG_PPC_MM_SLICES unsigned int get_paca_psize (unsigned long addr) { -unsigned long index, slices; +u64 lpsizes; +unsigned char *hpsizes; +unsigned long index, mask_index;if (addr <SLICE_LOW_TOP ) { - slices =get_paca ()->context.low_slices_psize; + lpsizes =get_paca ()->context.low_slices_psize; index =GET_LOW_SLICE_INDEX (addr); - }else { - slices =get_paca ()->context.high_slices_psize; - index =GET_HIGH_SLICE_INDEX (addr); +return (lpsizes >> (index *4 )) &0xF ; } -return (slices >> (index *4 )) &0xF ; + hpsizes =get_paca ()->context.high_slices_psize; + index =GET_HIGH_SLICE_INDEX (addr); + mask_index = index &0x1 ; +return (hpsizes[index >>1 ] >> (mask_index *4 )) &0xF ; }#else
arch/powerpc/mm/slb_low.S +22 -8
@@ -108,17 +108,31 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) * between 4k and 64k standard page size */ #ifdef CONFIG_PPC_MM_SLICES + /* r10 have esid */ cmpldi r10,16 - - /* Get the slice index * 4 in r11 and matching slice size mask in r9 */ - ld r9,PACALOWSLICESPSIZE(r13) - sldi r11,r10,2 + /* below SLICE_LOW_TOP */ blt 5f - ld r9,PACAHIGHSLICEPSIZE(r13) - srdi r11,r10,(SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT - 2) - andi. r11,r11,0x3c + /* + * Handle hpsizes, + * r9 is get_paca()->context.high_slices_psize[index], r11 is mask_index + */ + srdi r11,r10,(SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT + 1) /* index */ + addi r9,r11,PACAHIGHSLICEPSIZE + lbzx r9,r13,r9 /* r9 is hpsizes[r11] */ + /* r11 = (r10 >> (SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT)) & 0x1 */ + rldicl r11,r10,(64 - (SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT)),63 + b 6f -5: /* Extract the psize and multiply to get an array offset */ +5: + /* + * Handle lpsizes + * r9 is get_paca()->context.low_slices_psize, r11 is index + */ + ld r9,PACALOWSLICESPSIZE(r13) + mr r11,r10 +6: + sldi r11,r11,2 /* index * 4 */ + /* Extract the psize and multiply to get an array offset */ srd r9,r9,r11 andi. r9,r9,0xf mulli r9,r9,MMUPSIZEDEFSIZE
arch/powerpc/mm/slice.c +68 -39
196 lines not on this page · raw message
Signature · 1 line
1.7.10
PATCH 7/11 arch/powerpc: Make some of the PGTABLE_RANGE dependency explicit
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
slice array size and slice mask size depend on PGTABLE_RANGE. We can't directly include pgtable.h in these header because there is a circular dependency. So add compile time check for these values.
--- arch/powerpc/include/asm/mmu-hash64.h | 13 ++++++++----- arch/powerpc/include/asm/page_64.h | 16 ++++++++++++---- arch/powerpc/include/asm/pgtable-ppc64.h | 8 ++++++++ 3 files changed, 28 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +8 -5
@@ -416,6 +416,13 @@ extern void slb_set_size(u16 size); srdi rx,rx,VSID_BITS_##size; /* extract 2^VSID_BITS bit */ \ add rt,rt,rx +/* 4 bits per slice and we have one slice per 1TB */ +#if 0 /* We can't directly include pgtable.h hence this hack */ +#define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) +#else +/* Right now we only support 64TB */ +#define SLICE_ARRAY_SIZE 32 +#endif #ifndef __ASSEMBLY__
@@ -460,11 +467,7 @@ typedef struct {#ifdef CONFIG_PPC_MM_SLICES u64 low_slices_psize;/* SLB page size encodings */ -/* -* Right now we support 64TB and 4 bits for each -* 1TB slice we need 32 bytes for 64TB. -*/ -unsigned char high_slices_psize[32 ];/* 4 bits per slice for now */ +unsigned char high_slices_psize[SLICE_ARRAY_SIZE ];#else u16 sllp;/* SLB page size encoding */ #endif
arch/powerpc/include/asm/page_64.h +12 -4
@@ -78,14 +78,22 @@ extern u64 ppc64_pft_size;#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT)#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) +/* 1 bit per slice and we have one slice per 1TB */ +#if 0 /* We can't directly include pgtable.h hence this hack */ +#define SLICE_MASK_SIZE (PGTABLE_RANGE >> 43) +#else +/* +* Right now we support only 64TB. +* IF we change this we will have to change the type +* of high_slices +*/ +#define SLICE_MASK_SIZE 8 +#endif +#ifndef __ASSEMBLY__struct slice_mask {u16 low_slices; -/* -* This should be derived out of PGTABLE_RANGE. For the current -* max 64TB, u64 should be ok. -*/ u64 high_slices; };
arch/powerpc/include/asm/pgtable-ppc64.h +8 -0
@@ -32,6 +32,14 @@#endif #endif +#if (PGTABLE_RANGE >>41 ) >SLICE_ARRAY_SIZE +#error PGTABLE_RANGE exceeds SLICE_ARRAY_SIZE +#endif + +#if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE +#error PGTABLE_RANGE exceeds slice_mask high_slices size +#endif +/* * Define the address range of the kernel non-linear virtual area */
Signature · 1 line
1.7.10
PATCH 8/11 arch/powerpc: Use the required number of VSID bits in slbmte
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
ASM_VSID_SCRAMBLE can leave non-zero bits in the high 28 bits of the result for 256MB segment (40 bits for 1T segment). Properly mask them before using the values in slbmte
--- arch/powerpc/mm/slb_low.S | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/powerpc/mm/slb_low.S +10 -2
@@ -223,7 +223,11 @@ _GLOBAL(slb_allocate_user) */ slb_finish_load: ASM_VSID_SCRAMBLE(r10,r9,256M) - rldimi r11,r10,SLB_VSID_SHIFT,16 /* combine VSID and flags */ + /* + * bits above VSID_BITS_256M need to be ignored from r10 + * also combine VSID and flags + */ + rldimi r11,r10,SLB_VSID_SHIFT,(64 - (SLB_VSID_SHIFT + VSID_BITS_256M)) /* r3 = EA, r11 = VSID data */ /*
@@ -287,7 +291,11 @@ _GLOBAL(slb_compare_rr_to_size) slb_finish_load_1T: srdi r10,r10,40-28 /* get 1T ESID */ ASM_VSID_SCRAMBLE(r10,r9,1T) - rldimi r11,r10,SLB_VSID_SHIFT_1T,16 /* combine VSID and flags */ + /* + * bits above VSID_BITS_1T need to be ignored from r10 + * also combine VSID and flags + */ + rldimi r11,r10,SLB_VSID_SHIFT_1T,(64 - (SLB_VSID_SHIFT_1T + VSID_BITS_1T)) li r10,MMU_SEGSIZE_1T rldimi r11,r10,SLB_VSID_SSIZE_SHIFT,0 /* insert segment size */
Signature · 1 line
1.7.10
PATCH 9/11 arch/powerpc: Use 32bit array for slb cache
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
With larger vsid we need to track more bits of ESID in slb cache for slb invalidate.
--- arch/powerpc/include/asm/paca.h | 2 +- arch/powerpc/mm/slb_low.S | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/paca.h +1 -1
@@ -100,7 +100,7 @@ struct paca_struct {/* SLB related definitions */ u16 vmalloc_sllp;u16 slb_cache_ptr; -u16 slb_cache[SLB_CACHE_ENTRIES ]; +u32 slb_cache[SLB_CACHE_ENTRIES ];#endif /* CONFIG_PPC_STD_MMU_64 */ #ifdef CONFIG_PPC_BOOK3E
arch/powerpc/mm/slb_low.S +4 -4
@@ -270,10 +270,10 @@ _GLOBAL(slb_compare_rr_to_size) bge 1f /* still room in the slb cache */ - sldi r11,r3,1 /* r11 = offset * sizeof(u16) */ - rldicl r10,r10,36,28 /* get low 16 bits of the ESID */ - add r11,r11,r13 /* r11 = (u16 *)paca + offset */ - sth r10,PACASLBCACHE(r11) /* paca->slb_cache[offset] = esid */ + sldi r11,r3,2 /* r11 = offset * sizeof(u32) */ + srdi r10,r10,28 /* get the 36 bits of the ESID */ + add r11,r11,r13 /* r11 = (u32 *)paca + offset */ + stw r10,PACASLBCACHE(r11) /* paca->slb_cache[offset] = esid */ addi r3,r3,1 /* offset++ */ b 2f 1: /* offset >= SLB_CACHE_ENTRIES */
Signature · 1 line
1.7.10
PATCH 10/11 arch/powerpc: Add 64TB support
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
Increase max addressable range to 64TB. This is not tested on real hardware yet.
--- arch/powerpc/include/asm/mmu-hash64.h | 42 ++++++++++++++++++++------ arch/powerpc/include/asm/pgtable-ppc64-4k.h | 2 +- arch/powerpc/include/asm/pgtable-ppc64-64k.h | 2 +- arch/powerpc/include/asm/processor.h | 4 +-- arch/powerpc/include/asm/sparsemem.h | 4 +-- arch/powerpc/kernel/exceptions-64s.S | 4 ++- arch/powerpc/mm/slb_low.S | 12 ++++++++ 7 files changed, 54 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +33 -9
@@ -370,17 +370,21 @@ extern void slb_set_size(u16 size);* (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly. */ -#define VSID_MULTIPLIER_256M ASM_CONST(200730139)/* 28-bit prime */ -#define VSID_BITS_256M 36 +/* +* This should be computed such that protovosid * vsid_mulitplier +* doesn't overflow 64 bits. It should also be co-prime to vsid_modulus +*/ +#define VSID_MULTIPLIER_256M ASM_CONST(12538073)/* 24-bit prime */ +#define VSID_BITS_256M 38#define VSID_MODULUS_256M ((1UL<<VSID_BITS_256M)-1)#define VSID_MULTIPLIER_1T ASM_CONST(12538073)/* 24-bit prime */ -#define VSID_BITS_1T 24 +#define VSID_BITS_1T 26#define VSID_MODULUS_1T ((1UL<<VSID_BITS_1T)-1)#define CONTEXT_BITS 19 -#define USER_ESID_BITS 16 -#define USER_ESID_BITS_1T 4 +#define USER_ESID_BITS 18 +#define USER_ESID_BITS_1T 6#define USER_VSID_RANGE (1UL << (USER_ESID_BITS + SID_SHIFT))
@@ -503,12 +507,32 @@ typedef struct { })#endif /* 1 */ -/* This is only valid for addresses >= PAGE_OFFSET */ +/* +* This is only valid for addresses >= PAGE_OFFSET +* The proto-VSID space is divided into two class +* User: 0 to 2^(CONTEXT_BITS + USER_ESID_BITS) -1 +* kernel: 2^(CONTEXT_BITS + USER_ESID_BITS) to 2^(VSID_BITS) - 1 +* +* With KERNEL_START at 0xc000000000000000, the proto vsid for +* the kernel ends up with 0xc00000000 (36 bits). With 64TB +* support we need to have kernel proto-VSID in the +* [2^37 to 2^38 - 1] range due to the increased USER_ESID_BITS. +*/ static inline unsigned long get_kernel_vsid (unsigned long ea,int ssize) { -if (ssize ==MMU_SEGSIZE_256M ) - return vsid_scramble(ea >> SID_SHIFT, 256M); - return vsid_scramble(ea >> SID_SHIFT_1T, 1T); +unsigned long proto_vsid; +/* +* We need to make sure proto_vsid for the kernel is +* >= 2^(CONTEXT_BITS + USER_ESID_BITS[_1T]) +*/ +if (ssize ==MMU_SEGSIZE_256M ) { + proto_vsid = ea >>SID_SHIFT ; + proto_vsid |= (1UL << (CONTEXT_BITS +USER_ESID_BITS )); + return vsid_scramble(proto_vsid, 256M); + } + proto_vsid = ea >>SID_SHIFT_1T ; + proto_vsid |= (1UL << (CONTEXT_BITS +USER_ESID_BITS_1T )); + return vsid_scramble(proto_vsid, 1T); }/* Returns the segment size indicator for a user address */
arch/powerpc/include/asm/pgtable-ppc64-4k.h +1 -1
@@ -7,7 +7,7 @@*/ #define PTE_INDEX_SIZE 9#define PMD_INDEX_SIZE 7 -#define PUD_INDEX_SIZE 7 +#define PUD_INDEX_SIZE 9#define PGD_INDEX_SIZE 9#ifndef __ASSEMBLY__
arch/powerpc/include/asm/pgtable-ppc64-64k.h +1 -1
@@ -7,7 +7,7 @@#define PTE_INDEX_SIZE 12#define PMD_INDEX_SIZE 12#define PUD_INDEX_SIZE 0 -#define PGD_INDEX_SIZE 4 +#define PGD_INDEX_SIZE 6#ifndef __ASSEMBLY__#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE)
arch/powerpc/include/asm/processor.h +2 -2
@@ -97,8 +97,8 @@ extern struct task_struct *last_task_used_spe;#endif #ifdef CONFIG_PPC64 -/* 64-bit user address space is 44-bits (16TB user VM) */ -#define TASK_SIZE_USER64 (0x0000100000000000UL) +/* 64-bit user address space is 46-bits (64TB user VM) */ +#define TASK_SIZE_USER64 (0x0000400000000000UL)/* * 32-bit user address space is 4GB - 1 page
arch/powerpc/include/asm/sparsemem.h +2 -2
@@ -10,8 +10,8 @@*/ #define SECTION_SIZE_BITS 24 -#define MAX_PHYSADDR_BITS 44 -#define MAX_PHYSMEM_BITS 44 +#define MAX_PHYSADDR_BITS 46 +#define MAX_PHYSMEM_BITS 46#endif /* CONFIG_SPARSEMEM */
arch/powerpc/kernel/exceptions-64s.S +3 -1
@@ -959,7 +959,9 @@ _GLOBAL(do_stab_bolted) rldimi r10,r11,7,52 /* r10 = first ste of the group */ /* Calculate VSID */ - /* This is a kernel address, so protovsid = ESID */ + /* This is a kernel address, so protovsid = ESID | 1 << 37 */ + li r9,0x1 + rldimi r11,r9,(CONTEXT_BITS + USER_ESID_BITS),0 ASM_VSID_SCRAMBLE(r11, r9, 256M) rldic r9,r11,12,16 /* r9 = vsid << 12 */
arch/powerpc/mm/slb_low.S +12 -0
@@ -56,6 +56,12 @@ _GLOBAL(slb_allocate_realmode) */ _GLOBAL(slb_miss_kernel_load_linear) li r11,0 + li r9,0x1 + /* + * for 1T we shift 12 bits more. slb_finish_load_1T will do + * the necessary adjustment + */ + rldimi r10,r9,(CONTEXT_BITS + USER_ESID_BITS),0 BEGIN_FTR_SECTION b slb_finish_load END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
@@ -85,6 +91,12 @@ _GLOBAL(slb_miss_kernel_load_vmemmap) _GLOBAL(slb_miss_kernel_load_io) li r11,0 6: + li r9,0x1 + /* + * for 1T we shift 12 bits more. slb_finish_load_1T will do + * the necessary adjustment + */ + rldimi r10,r9,(CONTEXT_BITS + USER_ESID_BITS),0 BEGIN_FTR_SECTION b slb_finish_load END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
Signature · 1 line
1.7.10
PATCH 11/11 arch/powerpc: Update VSID allocation documentation
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
This update the proto-VSID and VSID scramble related information to be more generic by using names instead of current values.
--- arch/powerpc/include/asm/mmu-hash64.h | 40 ++++++++++++++------------------- arch/powerpc/mm/mmu_context_hash64.c | 8 ++++--- 2 files changed, 22 insertions(+), 26 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +17 -23
@@ -324,51 +324,45 @@ extern void slb_set_size(u16 size);#endif /* __ASSEMBLY__ */ /* -* VSID allocation +* VSID allocation (256MB segment) * -* We first generate a 36-bit "proto-VSID". For kernel addresses this -* is equal to the ESID, for user addresses it is: -* (context << 15) | (esid & 0x7fff) +* We first generate a 38-bit "proto-VSID". For kernel addresses this +* is equal to the ESID | 1 << 37, for user addresses it is: +* (context << USER_ESID_BITS) | (esid & ((1U << USER_ESID_BITS) - 1) * -* The two forms are distinguishable because the top bit is 0 for user -* addresses, whereas the top two bits are 1 for kernel addresses. -* Proto-VSIDs with the top two bits equal to 0b10 are reserved for -* now. +* This splits the proto-VSID into the below range +* 0 - (2^(CONTEXT_BITS + USER_ESID_BITS) - 1) : User proto-VSID range +* 2^(CONTEXT_BITS + USER_ESID_BITS) - 2^(VSID_BITS) : Kernel proto-VSID range +* +* We also have CONTEXT_BITS + USER_ESID_BITS = VSID_BITS - 1 +* That is, we assign half of the space to user processes and half +* to the kernel. * * The proto-VSIDs are then scrambled into real VSIDs with the * multiplicative hash: * * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS -* where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7 -* VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF * -* This scramble is only well defined for proto-VSIDs below -* 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are -* reserved. VSID_MULTIPLIER is prime, so in particular it is +* VSID_MULTIPLIER is prime, so in particular it is * co-prime to VSID_MODULUS, making this a 1:1 scrambling function. * Because the modulus is 2^n-1 we can compute it efficiently without * a divide or extra multiply (see below). * * This scheme has several advantages over older methods: * -* - We have VSIDs allocated for every kernel address +* - We have VSIDs allocated for every kernel address * (i.e. everything above 0xC000000000000000), except the very top * segment, which simplifies several things. * -* - We allow for 16 significant bits of ESID and 19 bits of -* context for user addresses. i.e. 16T (44 bits) of address space for -* up to half a million contexts. +* - We allow for USER_ESID_BITS significant bits of ESID and +* CONTEXT_BITS bits of context for user addresses. +* i.e. 64T (46 bits) of address space for up to half a million contexts. * -* - The scramble function gives robust scattering in the hash +* - The scramble function gives robust scattering in the hash * table (at least based on some initial results). The previous * method was more susceptible to pathological cases giving excessive * hash collisions. */ -/* -* WARNING - If you change these you must make sure the asm -* implementations in slb_allocate (slb_low.S), do_stab_bolted -* (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly. -*/ /* * This should be computed such that protovosid * vsid_mulitplier
arch/powerpc/mm/mmu_context_hash64.c +5 -3
@@ -30,9 +30,11 @@ static DEFINE_SPINLOCK(mmu_context_lock);static DEFINE_IDA (mmu_context_ida);/* -* The proto-VSID space has 2^35 - 1 segments available for user mappings. -* Each segment contains 2^28 bytes. Each context maps 2^44 bytes, -* so we can support 2^19-1 contexts (19 == 35 + 28 - 44). +* 256MB segment +* The proto-VSID space has 2^(CONTEX_BITS + USER_ESID_BITS) - 1 segments +* available for user mappings. Each segment contains 2^28 bytes. Each +* context maps 2^46 bytes (64TB) so we can support 2^19-1 contexts +* (19 == 37 + 28 - 46). */ #define MAX_CONTEXT ((1UL << CONTEXT_BITS) - 1)
Signature · 1 line
1.7.10
Quoted 6 lines · Aneesh Kumar K.V
Hi,
This patchset include patches for supporting 64TB with ppc64. I haven't booted this on hardware with 64TB memory yet. But they boot fine on real hardware with less memory. Changes extend VSID bits to 38 bits for a 256MB segment and 26 bits for 1TB segments.
Your series breaks the embedded 64-bit build. You seem to be hard wiring dependencies on slice stuff all over 64-bit stuff regardless of the MMU type or the value of CONFIG_MM_SLICES.
Also all these:
Review
Quoted 7 lines
(quoted diff) +7
-0+/* 4 bits per slice and we have one slice per 1TB */ +#if 0 /* We can't directly include pgtable.h hence this hack */ +#define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) +#else +/* Right now we only support 64TB */ +#define SLICE_ARRAY_SIZE 32 +#endif
Things are just too horrible. Find a different way of doing it, if necessary create a new range define somewhere, whatever but don't leave that crap as-is, it's too wrong.
Dropping the series for now.
Cheers,
Ben.
Quoted 31 lines
Changes from V7:
* Address review feedbackChanges from V6:
* rebase to latest upstream (5b716ac728bcc01b1f2a7ed6e437196602237c27)Changes from v5:
* Address review feedbackChanges from v4:
* Drop patch "arch/powerpc: properly offset the context bits for 1T segemnts" based on review feedback
* splitCONTEXT_BITSrelated changes from patch 12
* Add a new doc update patchChanges from v3:
* Address review comments.
* Added new patch to ensure proto-VSID isolation between kernel and user spaceChanges from V2:
* Fix few FIXMEs in the patchset. I have added them as separate patch for easier review. That should help us to drop those changes if we don't agree.Changes from V1:
* Drop the usage of structure (structvirt_addr) to carry virtual address. We now represent virtual address via vpn which is virtual address shifted right 12 bits.Thanks,
-aneesh
Quoted 26 lines · Benjamin Herrenschmidt
Quoted 6 lines · Aneesh Kumar K.V
Hi,
This patchset include patches for supporting 64TB with ppc64. I haven't booted this on hardware with 64TB memory yet. But they boot fine on real hardware with less memory. Changes extend VSID bits to 38 bits for a 256MB segment and 26 bits for 1TB segments.
Your series breaks the embedded 64-bit build. You seem to be hard wiring dependencies on slice stuff all over 64-bit stuff regardless of the MMU type or the value of
CONFIG_MM_SLICES.Also all these:
Review
Quoted 7 lines
(quoted diff) +7
-0+/* 4 bits per slice and we have one slice per 1TB */ +#if 0 /* We can't directly include pgtable.h hence this hack */ +#define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) +#else +/* Right now we only support 64TB */ +#define SLICE_ARRAY_SIZE 32 +#endifThings are just too horrible. Find a different way of doing it, if necessary create a new range define somewhere, whatever but don't leave that crap as-is, it's too wrong.
Quoted 2 lines
Dropping the series for now.
How about the change below. If you are ok moving the range details to new header, I can fold this into patch 7 and send a new series
-aneesh
arch/powerpc/include/asm/mmu-hash64.h +1 -5
@@ -14,6 +14,7 @@#include <asm/asm-compat.h> #include <asm/page.h> +#include <asm/pgtable-ppc64-range.h> /* * Segment table
@@ -415,12 +416,7 @@ extern void slb_set_size(u16 size); add rt,rt,rx/* 4 bits per slice and we have one slice per 1TB */ -#if 0 /* We can't directly include pgtable.h hence this hack */ #define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) -#else -/* Right now we only support 64TB */ -#define SLICE_ARRAY_SIZE 32 -#endif #ifndef __ASSEMBLY__
arch/powerpc/include/asm/page_64.h +3 -5
@@ -78,16 +78,14 @@ extern u64 ppc64_pft_size;#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT)#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) -/* 1 bit per slice and we have one slice per 1TB */ -#if 0 /* We can't directly include pgtable.h hence this hack */ -#define SLICE_MASK_SIZE (PGTABLE_RANGE >> 43) -#else -/* +/* 1 bit per slice and we have one slice per 1TB * Right now we support only 64TB. * IF we change this we will have to change the type * of high_slices */ #define SLICE_MASK_SIZE 8 +#if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE +#error PGTABLE_RANGE exceeds slice_mask high_slices size#endif #ifndef __ASSEMBLY__
arch/powerpc/include/asm/pgtable-ppc64-range.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ +#define _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ + +#ifdef CONFIG_PPC_64K_PAGES +#include <asm/pgtable-ppc64-64k.h> +#else +#include <asm/pgtable-ppc64-4k.h> +#endif + +/* +* Size of EA range mapped by our pagetables. +*/ +#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ + PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) +#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) +#endif
arch/powerpc/include/asm/pgtable-ppc64.h +1 -15
@@ -13,13 +13,7 @@#define FIRST_USER_ADDRESS 0 -/* -* Size of EA range mapped by our pagetables. -*/ -#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ - PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) -#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) - +#include <asm/pgtable-ppc64-range.h> /* Some sanity checking */ #if TASK_SIZE_USER64 >PGTABLE_RANGE
@@ -32,14 +26,6 @@#endif #endif -#if (PGTABLE_RANGE >>41 ) >SLICE_ARRAY_SIZE -#error PGTABLE_RANGE exceeds SLICE_ARRAY_SIZE -#endif - -#if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE -#error PGTABLE_RANGE exceeds slice_mask high_slices size -#endif -/* * Define the address range of the kernel non-linear virtual area */
arch/powerpc/include/asm/mmu-hash64.h line 17
Quoted 10 lines · Aneesh Kumar K.V
arch/powerpc/include/asm/mmu-hash64.h +1
-0@@ -14,6 +14,7 @@#include <asm/asm-compat.h> #include <asm/page.h> +#include <asm/pgtable-ppc64-range.h>
Nah, that's all too gross... I think the right thing to do is to move the slice stuff out of page_64.h
Quoted 85 lines
arch/powerpc/include/asm/mmu-hash64.h +0
-5/* * Segment table @@ -415,12 +416,7 @@ extern void slb_set_size(u16 size); add rt,rt,rx/* 4 bits per slice and we have one slice per 1TB */ -#if 0 /* We can't directly include pgtable.h hence this hack */ #define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) -#else -/* Right now we only support 64TB */ -#define SLICE_ARRAY_SIZE 32 -#endif #ifndef __ASSEMBLY__arch/powerpc/include/asm/page_64.h +3
-5@@ -78,16 +78,14 @@ extern u64 ppc64_pft_size;#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT)#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) -/* 1 bit per slice and we have one slice per 1TB */ -#if 0 /* We can't directly include pgtable.h hence this hack */ -#define SLICE_MASK_SIZE (PGTABLE_RANGE >> 43) -#else -/* +/* 1 bit per slice and we have one slice per 1TB * Right now we support only 64TB. * IF we change this we will have to change the type * of high_slices */ #define SLICE_MASK_SIZE 8 +#if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE +#error PGTABLE_RANGE exceeds slice_mask high_slices size#endif #ifndef __ASSEMBLY__arch/powerpc/include/asm/pgtable-ppc64-range.h new file +16
-0@@ -0,0 +1,16 @@ +#ifndef _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ +#define _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ + +#ifdef CONFIG_PPC_64K_PAGES +#include <asm/pgtable-ppc64-64k.h> +#else +#include <asm/pgtable-ppc64-4k.h> +#endif + +/* +* Size of EA range mapped by our pagetables. +*/ +#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ + PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) +#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) +#endif arch/powerpc/include/asm/pgtable-ppc64.h +1
-8@@ -13,13 +13,7 @@#define FIRST_USER_ADDRESS 0 -/* -* Size of EA range mapped by our pagetables. -*/ -#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ - PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) -#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) - +#include <asm/pgtable-ppc64-range.h> /* Some sanity checking */ #if TASK_SIZE_USER64 >PGTABLE_RANGE @@ -32,14 +26,6 @@#endif #endif -#if (PGTABLE_RANGE >>41 ) >SLICE_ARRAY_SIZE
arch/powerpc/include/asm/pgtable-ppc64.h line 31
Quoted 10 lines
arch/powerpc/include/asm/pgtable-ppc64.h +0
-7-#error PGTABLE_RANGE exceeds SLICE_ARRAY_SIZE -#endif - -#if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE -#error PGTABLE_RANGE exceeds slice_mask high_slices size -#endif -/* * Define the address range of the kernel non-linear virtual area */
Ben.
Quoted 26 lines · Benjamin Herrenschmidt
Quoted 6 lines · Aneesh Kumar K.V
Hi,
This patchset include patches for supporting 64TB with ppc64. I haven't booted this on hardware with 64TB memory yet. But they boot fine on real hardware with less memory. Changes extend VSID bits to 38 bits for a 256MB segment and 26 bits for 1TB segments.
Your series breaks the embedded 64-bit build. You seem to be hard wiring dependencies on slice stuff all over 64-bit stuff regardless of the MMU type or the value of
CONFIG_MM_SLICES.Also all these:
Review
Quoted 7 lines
(quoted diff) +7
-0+/* 4 bits per slice and we have one slice per 1TB */ +#if 0 /* We can't directly include pgtable.h hence this hack */ +#define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) +#else +/* Right now we only support 64TB */ +#define SLICE_ARRAY_SIZE 32 +#endifThings are just too horrible. Find a different way of doing it, if necessary create a new range define somewhere, whatever but don't leave that crap as-is, it's too wrong.
Quoted 2 lines
Dropping the series for now.
You can drop the patch [PATCH -V8 07/11] arch/powerpc: Make some of the PGTABLE_RANGE dependency explicit from the series. The above two problems are introduced by that patch and
as such can be looked up as a cleanup. I can rework the patch later. You
should be able to apply series without any conflicts even if you drop
that patch.
-aneesh
Quoted 28 lines · Aneesh Kumar K.V
Quoted 26 lines · Benjamin Herrenschmidt
Quoted 6 lines · Aneesh Kumar K.V
Hi,
This patchset include patches for supporting 64TB with ppc64. I haven't booted this on hardware with 64TB memory yet. But they boot fine on real hardware with less memory. Changes extend VSID bits to 38 bits for a 256MB segment and 26 bits for 1TB segments.
Your series breaks the embedded 64-bit build. You seem to be hard wiring dependencies on slice stuff all over 64-bit stuff regardless of the MMU type or the value of
CONFIG_MM_SLICES.Also all these:
Review
Quoted 7 lines
(quoted diff) +7
-0+/* 4 bits per slice and we have one slice per 1TB */ +#if 0 /* We can't directly include pgtable.h hence this hack */ +#define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41) +#else +/* Right now we only support 64TB */ +#define SLICE_ARRAY_SIZE 32 +#endifThings are just too horrible. Find a different way of doing it, if necessary create a new range define somewhere, whatever but don't leave that crap as-is, it's too wrong.
Quoted 9 lines
Quoted 2 lines
Dropping the series for now.
You can drop the patch [PATCH -V8 07/11]
arch/powerpc: Make some of thePGTABLE_RANGEdependency explicit from the series. The above two problems are introduced by that patch and
as such can be looked up as a cleanup. I can rework the patch later. You
should be able to apply series without any conflicts even if you drop
that patch.
I tried multiple changes to get the dependency isolated. But below is the most clean one I ended with. You have nacked it in the previous mail, but considering the mm_context_t dependency, IMHO this is better. Let me know if you have any other suggestion . This can go as a patch on top of the series after dropping patch 7 in this series.
Quoted 1 line
From
22a6f8c636112e54eb9c07e2bfbe4fd9b3861114Mon Sep 17 00:00:00 2001
From: "Aneesh Kumar K.V" <[email protected]>
Date: Fri, 7 Sep 2012 10:59:21 +0530
Subject: [PATCH] arch/powerpc: Make some of the PGTABLE_RANGE dependency
explicit
slice array size and slice mask size depend on PGTABLE_RANGE. We can't directly include pgtable.h in these header because there is a circular dependency. So split the pgtable range into a separate header and include that
--- arch/powerpc/include/asm/mmu-hash64.h | 9 ++++----- arch/powerpc/include/asm/page_64.h | 12 ++++++++---- arch/powerpc/include/asm/pgtable-ppc64-range.h | 16 ++++++++++++++++ arch/powerpc/include/asm/pgtable-ppc64.h | 14 +++++++------- 4 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 arch/powerpc/include/asm/pgtable-ppc64-range.h
arch/powerpc/include/asm/mmu-hash64.h +4 -5
@@ -14,6 +14,7 @@#include <asm/asm-compat.h> #include <asm/page.h> +#include <asm/pgtable-ppc64-range.h> /* * Segment table
@@ -414,6 +415,8 @@ extern void slb_set_size(u16 size); srdi rx,rx,VSID_BITS_##size; /* extract 2^VSID_BITS bit */ \ add rt,rt,rx +/* 4 bits per slice and we have one slice per 1TB */ +#define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41)#ifndef __ASSEMBLY__
@@ -458,11 +461,7 @@ typedef struct {#ifdef CONFIG_PPC_MM_SLICES u64 low_slices_psize;/* SLB page size encodings */ -/* -* Right now we support 64TB and 4 bits for each -* 1TB slice we need 32 bytes for 64TB. -*/ -unsigned char high_slices_psize[32 ];/* 4 bits per slice for now */ +unsigned char high_slices_psize[SLICE_ARRAY_SIZE ];#else u16 sllp;/* SLB page size encoding */ #endif
arch/powerpc/include/asm/page_64.h +8 -4
@@ -78,14 +78,18 @@ extern u64 ppc64_pft_size;#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT)#define GET_HIGH_SLICE_INDEX (addr) ((addr) >> SLICE_HIGH_SHIFT) +/* +* 1 bit per slice and we have one slice per 1TB +* Right now we support only 64TB. +* IF we change this we will have to change the type +* of high_slices +*/ +#define SLICE_MASK_SIZE 8 +#ifndef __ASSEMBLY__struct slice_mask {u16 low_slices; -/* -* This should be derived out of PGTABLE_RANGE. For the current -* max 64TB, u64 should be ok. -*/ u64 high_slices; };
arch/powerpc/include/asm/pgtable-ppc64-range.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ +#define _ASM_POWERPC_PGTABLE_PPC64_RANGE_H_ + +#ifdef CONFIG_PPC_64K_PAGES +#include <asm/pgtable-ppc64-64k.h> +#else +#include <asm/pgtable-ppc64-4k.h> +#endif + +/* +* Size of EA range mapped by our pagetables. +*/ +#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ + PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) +#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) +#endif
arch/powerpc/include/asm/pgtable-ppc64.h +7 -7
@@ -13,13 +13,7 @@#define FIRST_USER_ADDRESS 0 -/* -* Size of EA range mapped by our pagetables. -*/ -#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ - PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) -#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) - +#include <asm/pgtable-ppc64-range.h> /* Some sanity checking */ #if TASK_SIZE_USER64 >PGTABLE_RANGE
@@ -32,6 +26,12 @@#endif #endif +#ifdef CONFIG_PPC_MM_SLICES +#if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE +#error PGTABLE_RANGE exceeds slice_mask high_slices size +#endif +#endif +/* * Define the address range of the kernel non-linear virtual area */
Signature · 1 line
1.7.10
On Sat, 2012-09-08 at 22:27 +0530, Aneesh Kumar K.V wrote:
.../...
Quoted 4 lines
slice array size and slice mask size depend on
PGTABLE_RANGE. We can't directly includepgtable.hin these header because there is a circular dependency. So split the pgtable range into a separate header and include that
Not fan of that pgtable-*-range.h .... I did a quick hack on top of upstream and it looks like you can get away with something along the lines of: (fill in the gaps)
index 1c65a59..40f70085 100644
arch/powerpc/include/asm/mmu-hash64.h +9 -2
@@ -16,6 +16,14 @@#include <asm/page.h> /* +* This is necessary to get the definition of PGTABLE_RANGE which we +* need for various slices related matters. Note that this isn't the +* complete pgtable.h but only a portion of it. +*/ +#include <asm/pgtable-ppc64.h> + + +/* * Segment table */
@@ -371,8 +379,7 @@ extern void slb_set_size(u16 size); addi rx,rt,1; \ srdi rx,rx,VSID_BITS_##size; /* extract 2^VSID_BITS bit */ \add rt,rt,rx - - + #ifndef __ASSEMBLY__ #ifdef CONFIG_PPC_SUBPAGE_PROT
(quoted diff) +0 -0
b/arch/powerpc/include/asm/mmu.h
index e8a26db..0a3692d 100644
arch/powerpc/include/asm/mmu.h +0 -0
@@ -146,6 +146,16 @@ extern void setup_initial_memory_limit(phys_addr_t
first_memblock_base,
extern u64 ppc64_rma_size;
#endif /* CONFIG_PPC64 */
+struct mm_struct;
+
+#ifdef CONFIG_DEBUG_VM
+extern void assert_pte_locked(struct mm_struct *mm, unsigned long addr);
+#else /* CONFIG_DEBUG_VM */
+static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
+{
+}
+#endif /* !CONFIG_DEBUG_VM */
+
#endif /* !__ASSEMBLY__ */
/* The kernel use the constants below to index in the page sizes array.
(quoted diff) +0 -0
b/arch/powerpc/include/asm/pgtable-ppc64.h
index c420561..2871b00 100644
arch/powerpc/include/asm/pgtable-ppc64.h +3 -14
@@ -21,17 +21,6 @@#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) -/* Some sanity checking */ -#if TASK_SIZE_USER64 >PGTABLE_RANGE -#error TASK_SIZE_USER64 exceeds pagetable range -#endif - -#ifdef CONFIG_PPC_STD_MMU_64 -#if TASK_SIZE_USER64 > (1UL << (USER_ESID_BITS +SID_SHIFT )) -#error TASK_SIZE_USER64 exceeds user VSID range -#endif -#endif -/* * Define the address range of the kernel non-linear virtual area */
@@ -117,9 +106,6 @@#ifndef __ASSEMBLY__ -#include <linux/stddef.h> -#include <asm/tlbflush.h> -/* * This is the default implementation of various PTE accessors, it's * used in all cases except Book3S with 64K pages where we have a
@@ -200,6 +186,9 @@#define pgd_offset_k (address) pgd_offset(&init_mm, address) +extern void hpte_need_flush (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long pte,int huge); +/* Atomic PTE updates */ static inline unsigned long pte_update(struct mm_struct *mm, unsigned long addr,
(quoted diff) +0 -0
b/arch/powerpc/include/asm/pgtable.h
index 2e0e411..a9cbd3b 100644
arch/powerpc/include/asm/pgtable.h +0 -2
@@ -9,14 +9,6 @@struct mm_struct ; -#ifdef CONFIG_DEBUG_VM -extern void assert_pte_locked(struct mm_struct *mm, unsigned long
addr);
-#else /* CONFIG_DEBUG_VM */
-static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
-{
-}
-#endif /* !CONFIG_DEBUG_VM */
-
#endif /* !__ASSEMBLY__ */
#if defined(CONFIG_PPC64)
@@ -27,6 +19,8 @@ static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
#ifndef __ASSEMBLY__
+#include <asm/tlbflush.h>
+
/* Generic accessors to PTE bits */
static inline int pte_write(pte_t pte) { return pte_val(pte) &_PAGE_RW; }
static inline int pte_dirty(pte_t pte) { return pte_val(pte) &_PAGE_DIRTY; }
(quoted diff) +0 -0
b/arch/powerpc/include/asm/tlbflush.h
index 81143fc..2af6a03 100644
arch/powerpc/include/asm/tlbflush.h +0 -0
@@ -103,9 +103,6 @@ DECLARE_PER_CPU(struct ppc64_tlb_batch,
ppc64_tlb_batch);
extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
-extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
- pte_t *ptep, unsigned long pte, int huge);
-
#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
static inline void arch_enter_lazy_mmu_mode(void)
arch/powerpc/mm/mem.c +1 -0
@@ -41,6 +41,7 @@#include <asm/io.h> #include <asm/mmu_context.h> #include <asm/pgtable.h> +#include <asm/tlbflush.h> #include <asm/mmu.h> #include <asm/smp.h> #include <asm/machdep.h>
arch/powerpc/mm/pgtable_64.c +12 -0
@@ -327,3 +327,15 @@ EXPORT_SYMBOL(__ioremap_at);EXPORT_SYMBOL (iounmap);EXPORT_SYMBOL (__iounmap);EXPORT_SYMBOL (__iounmap_at); + +/* Some sanity checking */ +#if TASK_SIZE_USER64 >PGTABLE_RANGE +#error TASK_SIZE_USER64 exceeds pagetable range +#endif + +#ifdef CONFIG_PPC_STD_MMU_64 +#if TASK_SIZE_USER64 > (1UL << (USER_ESID_BITS +SID_SHIFT )) +#error TASK_SIZE_USER64 exceeds user VSID range +#endif +#endif +
A message that is not in the archive (sent off-list or not yet received): 1346945351-7672-5-git-send-email-aneesh.kumar__43423.5424655073$1346945525$gmane$org@linux.vnet.ibm.com
Re: [PATCH -V8 04/11] arch/powerpc: Convert virtual address to vpn
Quoted 14 lines · Aneesh Kumar K.V
arch/powerpc/kvm/book3s_32_mmu_host.c +1
-1@@ -141,7 +141,7 @@ extern char etext[];int kvmppc_mmu_map_page (struct kvm_vcpu *vcpu,struct kvmppc_pte *orig_pte) {pfn_t hpaddr; -u64 va; +u64 vpn;u64 vsid;struct kvmppc_sid_map *map;volatile u32 *pteg;
arch/powerpc/kvm/book3s_32_mmu_host.c int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) · line 176
Quoted 5 lines
arch/powerpc/kvm/book3s_32_mmu_host.c +1
-1@@ -173,7 +173,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)BUG_ON (!map); vsid = map->host_vsid; - va = (vsid <<SID_SHIFT ) | (eaddr & ~ESID_MASK ); + vpn = (vsid << (SID_SHIFT -VPN_SHIFT )) | ((eaddr & ~ESID_MASK ) >>VPN_SHIFT )
Where is VPN_SHIFT? Where is the semicolon?
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [PATCH -V8 04/11] arch/powerpc: Convert virtual address to vpn
Quoted 18 lines · Andreas Schwab
Quoted 16 lines · Aneesh Kumar K.V
arch/powerpc/kvm/book3s_32_mmu_host.c +1
-1@@ -141,7 +141,7 @@ extern char etext[];int kvmppc_mmu_map_page (struct kvm_vcpu *vcpu,struct kvmppc_pte *orig_pte) {pfn_t hpaddr; -u64 va; +u64 vpn;u64 vsid;struct kvmppc_sid_map *map;volatile u32 *pteg;@@ -173,7 +173,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)BUG_ON (!map);
Quoted 5 lines
arch/powerpc/kvm/book3s_32_mmu_host.c int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) · line 176
Quoted 3 lines
arch/powerpc/kvm/book3s_32_mmu_host.c +1
-1vsid = map->host_vsid; - va = (vsid <<SID_SHIFT ) | (eaddr & ~ESID_MASK ); + vpn = (vsid << (SID_SHIFT -VPN_SHIFT )) | ((eaddr & ~ESID_MASK ) >>VPN_SHIFT )Where is
VPN_SHIFT? Where is the semicolon?
I had done a kvm build test with the changes, but missed the fact that this is !SMP and PPC_BOOK3S_32. Will send a follow up patch.
-aneesh
Re: [PATCH -V8 04/11] arch/powerpc: Convert virtual address to vpn
Quoted 20 lines · Aneesh Kumar K.V
Quoted 18 lines · Andreas Schwab
Quoted 16 lines · Aneesh Kumar K.V
arch/powerpc/kvm/book3s_32_mmu_host.c +1
-1@@ -141,7 +141,7 @@ extern char etext[];int kvmppc_mmu_map_page (struct kvm_vcpu *vcpu,struct kvmppc_pte *orig_pte) {pfn_t hpaddr; -u64 va; +u64 vpn;u64 vsid;struct kvmppc_sid_map *map;volatile u32 *pteg;@@ -173,7 +173,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)BUG_ON (!map);
Quoted 8 lines
Quoted 5 lines
arch/powerpc/kvm/book3s_32_mmu_host.c int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) · line 176
Quoted 3 lines
arch/powerpc/kvm/book3s_32_mmu_host.c +1
-1vsid = map->host_vsid; - va = (vsid <<SID_SHIFT ) | (eaddr & ~ESID_MASK ); + vpn = (vsid << (SID_SHIFT -VPN_SHIFT )) | ((eaddr & ~ESID_MASK ) >>VPN_SHIFT )Where is
VPN_SHIFT? Where is the semicolon?I had done a kvm build test with the changes, but missed the fact that this is !SMP and
PPC_BOOK3S_32. Will send a follow up patch.
How about the below ? Any help on how to get this tested ?
arch/powerpc/include/asm/kvm_book3s_32.h +1 -0
@@ -42,5 +42,6 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)#define SID_SHIFT 28#define ESID_MASK 0xf0000000#define VSID_MASK 0x00fffffff0000000ULL +#define VPN_SHIFT 12#endif /* __ASM_KVM_BOOK3S_32_H__ */
arch/powerpc/kvm/book3s_32_mmu_host.c +2 -2
@@ -173,8 +173,8 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)BUG_ON (!map); vsid = map->host_vsid; - vpn = (vsid << (SID_SHIFT - VPN_SHIFT)) | ((eaddr & ~ESID_MASK) >> VPN_SHIFT) - + vpn = (vsid << (SID_SHIFT -VPN_SHIFT )) | + ((eaddr & ~ESID_MASK ) >>VPN_SHIFT ); next_pteg:if (rr ==16 ) { primary = !primary;