1*17312f25SChristophe Leroy/* 2*17312f25SChristophe Leroy * PowerPC version 3*17312f25SChristophe Leroy * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 4*17312f25SChristophe Leroy * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 5*17312f25SChristophe Leroy * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu> 6*17312f25SChristophe Leroy * Adapted for Power Macintosh by Paul Mackerras. 7*17312f25SChristophe Leroy * Low-level exception handlers and MMU support 8*17312f25SChristophe Leroy * rewritten by Paul Mackerras. 9*17312f25SChristophe Leroy * Copyright (C) 1996 Paul Mackerras. 10*17312f25SChristophe Leroy * 11*17312f25SChristophe Leroy * This file contains low-level assembler routines for managing 12*17312f25SChristophe Leroy * the PowerPC MMU hash table. (PPC 8xx processors don't use a 13*17312f25SChristophe Leroy * hash table, so this file is not used on them.) 14*17312f25SChristophe Leroy * 15*17312f25SChristophe Leroy * This program is free software; you can redistribute it and/or 16*17312f25SChristophe Leroy * modify it under the terms of the GNU General Public License 17*17312f25SChristophe Leroy * as published by the Free Software Foundation; either version 18*17312f25SChristophe Leroy * 2 of the License, or (at your option) any later version. 19*17312f25SChristophe Leroy * 20*17312f25SChristophe Leroy */ 21*17312f25SChristophe Leroy 22*17312f25SChristophe Leroy#include <asm/reg.h> 23*17312f25SChristophe Leroy#include <asm/page.h> 24*17312f25SChristophe Leroy#include <asm/pgtable.h> 25*17312f25SChristophe Leroy#include <asm/cputable.h> 26*17312f25SChristophe Leroy#include <asm/ppc_asm.h> 27*17312f25SChristophe Leroy#include <asm/thread_info.h> 28*17312f25SChristophe Leroy#include <asm/asm-offsets.h> 29*17312f25SChristophe Leroy#include <asm/export.h> 30*17312f25SChristophe Leroy#include <asm/feature-fixups.h> 31*17312f25SChristophe Leroy#include <asm/code-patching-asm.h> 32*17312f25SChristophe Leroy 33*17312f25SChristophe Leroy#ifdef CONFIG_SMP 34*17312f25SChristophe Leroy .section .bss 35*17312f25SChristophe Leroy .align 2 36*17312f25SChristophe Leroymmu_hash_lock: 37*17312f25SChristophe Leroy .space 4 38*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 39*17312f25SChristophe Leroy 40*17312f25SChristophe Leroy/* 41*17312f25SChristophe Leroy * Load a PTE into the hash table, if possible. 42*17312f25SChristophe Leroy * The address is in r4, and r3 contains an access flag: 43*17312f25SChristophe Leroy * _PAGE_RW (0x400) if a write. 44*17312f25SChristophe Leroy * r9 contains the SRR1 value, from which we use the MSR_PR bit. 45*17312f25SChristophe Leroy * SPRG_THREAD contains the physical address of the current task's thread. 46*17312f25SChristophe Leroy * 47*17312f25SChristophe Leroy * Returns to the caller if the access is illegal or there is no 48*17312f25SChristophe Leroy * mapping for the address. Otherwise it places an appropriate PTE 49*17312f25SChristophe Leroy * in the hash table and returns from the exception. 50*17312f25SChristophe Leroy * Uses r0, r3 - r6, r8, r10, ctr, lr. 51*17312f25SChristophe Leroy */ 52*17312f25SChristophe Leroy .text 53*17312f25SChristophe Leroy_GLOBAL(hash_page) 54*17312f25SChristophe Leroy#ifdef CONFIG_SMP 55*17312f25SChristophe Leroy lis r8, (mmu_hash_lock - PAGE_OFFSET)@h 56*17312f25SChristophe Leroy ori r8, r8, (mmu_hash_lock - PAGE_OFFSET)@l 57*17312f25SChristophe Leroy lis r0,0x0fff 58*17312f25SChristophe Leroy b 10f 59*17312f25SChristophe Leroy11: lwz r6,0(r8) 60*17312f25SChristophe Leroy cmpwi 0,r6,0 61*17312f25SChristophe Leroy bne 11b 62*17312f25SChristophe Leroy10: lwarx r6,0,r8 63*17312f25SChristophe Leroy cmpwi 0,r6,0 64*17312f25SChristophe Leroy bne- 11b 65*17312f25SChristophe Leroy stwcx. r0,0,r8 66*17312f25SChristophe Leroy bne- 10b 67*17312f25SChristophe Leroy isync 68*17312f25SChristophe Leroy#endif 69*17312f25SChristophe Leroy /* Get PTE (linux-style) and check access */ 70*17312f25SChristophe Leroy lis r0,KERNELBASE@h /* check if kernel address */ 71*17312f25SChristophe Leroy cmplw 0,r4,r0 72*17312f25SChristophe Leroy ori r3,r3,_PAGE_USER|_PAGE_PRESENT /* test low addresses as user */ 73*17312f25SChristophe Leroy mfspr r5, SPRN_SPRG_PGDIR /* phys page-table root */ 74*17312f25SChristophe Leroy blt+ 112f /* assume user more likely */ 75*17312f25SChristophe Leroy lis r5, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */ 76*17312f25SChristophe Leroy addi r5 ,r5 ,(swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */ 77*17312f25SChristophe Leroy rlwimi r3,r9,32-12,29,29 /* MSR_PR -> _PAGE_USER */ 78*17312f25SChristophe Leroy112: 79*17312f25SChristophe Leroy#ifndef CONFIG_PTE_64BIT 80*17312f25SChristophe Leroy rlwimi r5,r4,12,20,29 /* insert top 10 bits of address */ 81*17312f25SChristophe Leroy lwz r8,0(r5) /* get pmd entry */ 82*17312f25SChristophe Leroy rlwinm. r8,r8,0,0,19 /* extract address of pte page */ 83*17312f25SChristophe Leroy#else 84*17312f25SChristophe Leroy rlwinm r8,r4,13,19,29 /* Compute pgdir/pmd offset */ 85*17312f25SChristophe Leroy lwzx r8,r8,r5 /* Get L1 entry */ 86*17312f25SChristophe Leroy rlwinm. r8,r8,0,0,20 /* extract pt base address */ 87*17312f25SChristophe Leroy#endif 88*17312f25SChristophe Leroy#ifdef CONFIG_SMP 89*17312f25SChristophe Leroy beq- hash_page_out /* return if no mapping */ 90*17312f25SChristophe Leroy#else 91*17312f25SChristophe Leroy /* XXX it seems like the 601 will give a machine fault on the 92*17312f25SChristophe Leroy rfi if its alignment is wrong (bottom 4 bits of address are 93*17312f25SChristophe Leroy 8 or 0xc) and we have had a not-taken conditional branch 94*17312f25SChristophe Leroy to the address following the rfi. */ 95*17312f25SChristophe Leroy beqlr- 96*17312f25SChristophe Leroy#endif 97*17312f25SChristophe Leroy#ifndef CONFIG_PTE_64BIT 98*17312f25SChristophe Leroy rlwimi r8,r4,22,20,29 /* insert next 10 bits of address */ 99*17312f25SChristophe Leroy#else 100*17312f25SChristophe Leroy rlwimi r8,r4,23,20,28 /* compute pte address */ 101*17312f25SChristophe Leroy#endif 102*17312f25SChristophe Leroy rlwinm r0,r3,32-3,24,24 /* _PAGE_RW access -> _PAGE_DIRTY */ 103*17312f25SChristophe Leroy ori r0,r0,_PAGE_ACCESSED|_PAGE_HASHPTE 104*17312f25SChristophe Leroy 105*17312f25SChristophe Leroy /* 106*17312f25SChristophe Leroy * Update the linux PTE atomically. We do the lwarx up-front 107*17312f25SChristophe Leroy * because almost always, there won't be a permission violation 108*17312f25SChristophe Leroy * and there won't already be an HPTE, and thus we will have 109*17312f25SChristophe Leroy * to update the PTE to set _PAGE_HASHPTE. -- paulus. 110*17312f25SChristophe Leroy * 111*17312f25SChristophe Leroy * If PTE_64BIT is set, the low word is the flags word; use that 112*17312f25SChristophe Leroy * word for locking since it contains all the interesting bits. 113*17312f25SChristophe Leroy */ 114*17312f25SChristophe Leroy#if (PTE_FLAGS_OFFSET != 0) 115*17312f25SChristophe Leroy addi r8,r8,PTE_FLAGS_OFFSET 116*17312f25SChristophe Leroy#endif 117*17312f25SChristophe Leroyretry: 118*17312f25SChristophe Leroy lwarx r6,0,r8 /* get linux-style pte, flag word */ 119*17312f25SChristophe Leroy andc. r5,r3,r6 /* check access & ~permission */ 120*17312f25SChristophe Leroy#ifdef CONFIG_SMP 121*17312f25SChristophe Leroy bne- hash_page_out /* return if access not permitted */ 122*17312f25SChristophe Leroy#else 123*17312f25SChristophe Leroy bnelr- 124*17312f25SChristophe Leroy#endif 125*17312f25SChristophe Leroy or r5,r0,r6 /* set accessed/dirty bits */ 126*17312f25SChristophe Leroy#ifdef CONFIG_PTE_64BIT 127*17312f25SChristophe Leroy#ifdef CONFIG_SMP 128*17312f25SChristophe Leroy subf r10,r6,r8 /* create false data dependency */ 129*17312f25SChristophe Leroy subi r10,r10,PTE_FLAGS_OFFSET 130*17312f25SChristophe Leroy lwzx r10,r6,r10 /* Get upper PTE word */ 131*17312f25SChristophe Leroy#else 132*17312f25SChristophe Leroy lwz r10,-PTE_FLAGS_OFFSET(r8) 133*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 134*17312f25SChristophe Leroy#endif /* CONFIG_PTE_64BIT */ 135*17312f25SChristophe Leroy stwcx. r5,0,r8 /* attempt to update PTE */ 136*17312f25SChristophe Leroy bne- retry /* retry if someone got there first */ 137*17312f25SChristophe Leroy 138*17312f25SChristophe Leroy mfsrin r3,r4 /* get segment reg for segment */ 139*17312f25SChristophe Leroy mfctr r0 140*17312f25SChristophe Leroy stw r0,_CTR(r11) 141*17312f25SChristophe Leroy bl create_hpte /* add the hash table entry */ 142*17312f25SChristophe Leroy 143*17312f25SChristophe Leroy#ifdef CONFIG_SMP 144*17312f25SChristophe Leroy eieio 145*17312f25SChristophe Leroy lis r8, (mmu_hash_lock - PAGE_OFFSET)@ha 146*17312f25SChristophe Leroy li r0,0 147*17312f25SChristophe Leroy stw r0, (mmu_hash_lock - PAGE_OFFSET)@l(r8) 148*17312f25SChristophe Leroy#endif 149*17312f25SChristophe Leroy 150*17312f25SChristophe Leroy /* Return from the exception */ 151*17312f25SChristophe Leroy lwz r5,_CTR(r11) 152*17312f25SChristophe Leroy mtctr r5 153*17312f25SChristophe Leroy lwz r0,GPR0(r11) 154*17312f25SChristophe Leroy lwz r8,GPR8(r11) 155*17312f25SChristophe Leroy b fast_exception_return 156*17312f25SChristophe Leroy 157*17312f25SChristophe Leroy#ifdef CONFIG_SMP 158*17312f25SChristophe Leroyhash_page_out: 159*17312f25SChristophe Leroy eieio 160*17312f25SChristophe Leroy lis r8, (mmu_hash_lock - PAGE_OFFSET)@ha 161*17312f25SChristophe Leroy li r0,0 162*17312f25SChristophe Leroy stw r0, (mmu_hash_lock - PAGE_OFFSET)@l(r8) 163*17312f25SChristophe Leroy blr 164*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 165*17312f25SChristophe Leroy 166*17312f25SChristophe Leroy/* 167*17312f25SChristophe Leroy * Add an entry for a particular page to the hash table. 168*17312f25SChristophe Leroy * 169*17312f25SChristophe Leroy * add_hash_page(unsigned context, unsigned long va, unsigned long pmdval) 170*17312f25SChristophe Leroy * 171*17312f25SChristophe Leroy * We assume any necessary modifications to the pte (e.g. setting 172*17312f25SChristophe Leroy * the accessed bit) have already been done and that there is actually 173*17312f25SChristophe Leroy * a hash table in use (i.e. we're not on a 603). 174*17312f25SChristophe Leroy */ 175*17312f25SChristophe Leroy_GLOBAL(add_hash_page) 176*17312f25SChristophe Leroy mflr r0 177*17312f25SChristophe Leroy stw r0,4(r1) 178*17312f25SChristophe Leroy 179*17312f25SChristophe Leroy /* Convert context and va to VSID */ 180*17312f25SChristophe Leroy mulli r3,r3,897*16 /* multiply context by context skew */ 181*17312f25SChristophe Leroy rlwinm r0,r4,4,28,31 /* get ESID (top 4 bits of va) */ 182*17312f25SChristophe Leroy mulli r0,r0,0x111 /* multiply by ESID skew */ 183*17312f25SChristophe Leroy add r3,r3,r0 /* note create_hpte trims to 24 bits */ 184*17312f25SChristophe Leroy 185*17312f25SChristophe Leroy#ifdef CONFIG_SMP 186*17312f25SChristophe Leroy lwz r8,TASK_CPU(r2) /* to go in mmu_hash_lock */ 187*17312f25SChristophe Leroy oris r8,r8,12 188*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 189*17312f25SChristophe Leroy 190*17312f25SChristophe Leroy /* 191*17312f25SChristophe Leroy * We disable interrupts here, even on UP, because we don't 192*17312f25SChristophe Leroy * want to race with hash_page, and because we want the 193*17312f25SChristophe Leroy * _PAGE_HASHPTE bit to be a reliable indication of whether 194*17312f25SChristophe Leroy * the HPTE exists (or at least whether one did once). 195*17312f25SChristophe Leroy * We also turn off the MMU for data accesses so that we 196*17312f25SChristophe Leroy * we can't take a hash table miss (assuming the code is 197*17312f25SChristophe Leroy * covered by a BAT). -- paulus 198*17312f25SChristophe Leroy */ 199*17312f25SChristophe Leroy mfmsr r9 200*17312f25SChristophe Leroy SYNC 201*17312f25SChristophe Leroy rlwinm r0,r9,0,17,15 /* clear bit 16 (MSR_EE) */ 202*17312f25SChristophe Leroy rlwinm r0,r0,0,28,26 /* clear MSR_DR */ 203*17312f25SChristophe Leroy mtmsr r0 204*17312f25SChristophe Leroy SYNC_601 205*17312f25SChristophe Leroy isync 206*17312f25SChristophe Leroy 207*17312f25SChristophe Leroy#ifdef CONFIG_SMP 208*17312f25SChristophe Leroy lis r6, (mmu_hash_lock - PAGE_OFFSET)@ha 209*17312f25SChristophe Leroy addi r6, r6, (mmu_hash_lock - PAGE_OFFSET)@l 210*17312f25SChristophe Leroy10: lwarx r0,0,r6 /* take the mmu_hash_lock */ 211*17312f25SChristophe Leroy cmpi 0,r0,0 212*17312f25SChristophe Leroy bne- 11f 213*17312f25SChristophe Leroy stwcx. r8,0,r6 214*17312f25SChristophe Leroy beq+ 12f 215*17312f25SChristophe Leroy11: lwz r0,0(r6) 216*17312f25SChristophe Leroy cmpi 0,r0,0 217*17312f25SChristophe Leroy beq 10b 218*17312f25SChristophe Leroy b 11b 219*17312f25SChristophe Leroy12: isync 220*17312f25SChristophe Leroy#endif 221*17312f25SChristophe Leroy 222*17312f25SChristophe Leroy /* 223*17312f25SChristophe Leroy * Fetch the linux pte and test and set _PAGE_HASHPTE atomically. 224*17312f25SChristophe Leroy * If _PAGE_HASHPTE was already set, we don't replace the existing 225*17312f25SChristophe Leroy * HPTE, so we just unlock and return. 226*17312f25SChristophe Leroy */ 227*17312f25SChristophe Leroy mr r8,r5 228*17312f25SChristophe Leroy#ifndef CONFIG_PTE_64BIT 229*17312f25SChristophe Leroy rlwimi r8,r4,22,20,29 230*17312f25SChristophe Leroy#else 231*17312f25SChristophe Leroy rlwimi r8,r4,23,20,28 232*17312f25SChristophe Leroy addi r8,r8,PTE_FLAGS_OFFSET 233*17312f25SChristophe Leroy#endif 234*17312f25SChristophe Leroy1: lwarx r6,0,r8 235*17312f25SChristophe Leroy andi. r0,r6,_PAGE_HASHPTE 236*17312f25SChristophe Leroy bne 9f /* if HASHPTE already set, done */ 237*17312f25SChristophe Leroy#ifdef CONFIG_PTE_64BIT 238*17312f25SChristophe Leroy#ifdef CONFIG_SMP 239*17312f25SChristophe Leroy subf r10,r6,r8 /* create false data dependency */ 240*17312f25SChristophe Leroy subi r10,r10,PTE_FLAGS_OFFSET 241*17312f25SChristophe Leroy lwzx r10,r6,r10 /* Get upper PTE word */ 242*17312f25SChristophe Leroy#else 243*17312f25SChristophe Leroy lwz r10,-PTE_FLAGS_OFFSET(r8) 244*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 245*17312f25SChristophe Leroy#endif /* CONFIG_PTE_64BIT */ 246*17312f25SChristophe Leroy ori r5,r6,_PAGE_HASHPTE 247*17312f25SChristophe Leroy stwcx. r5,0,r8 248*17312f25SChristophe Leroy bne- 1b 249*17312f25SChristophe Leroy 250*17312f25SChristophe Leroy bl create_hpte 251*17312f25SChristophe Leroy 252*17312f25SChristophe Leroy9: 253*17312f25SChristophe Leroy#ifdef CONFIG_SMP 254*17312f25SChristophe Leroy lis r6, (mmu_hash_lock - PAGE_OFFSET)@ha 255*17312f25SChristophe Leroy addi r6, r6, (mmu_hash_lock - PAGE_OFFSET)@l 256*17312f25SChristophe Leroy eieio 257*17312f25SChristophe Leroy li r0,0 258*17312f25SChristophe Leroy stw r0,0(r6) /* clear mmu_hash_lock */ 259*17312f25SChristophe Leroy#endif 260*17312f25SChristophe Leroy 261*17312f25SChristophe Leroy /* reenable interrupts and DR */ 262*17312f25SChristophe Leroy mtmsr r9 263*17312f25SChristophe Leroy SYNC_601 264*17312f25SChristophe Leroy isync 265*17312f25SChristophe Leroy 266*17312f25SChristophe Leroy lwz r0,4(r1) 267*17312f25SChristophe Leroy mtlr r0 268*17312f25SChristophe Leroy blr 269*17312f25SChristophe Leroy 270*17312f25SChristophe Leroy/* 271*17312f25SChristophe Leroy * This routine adds a hardware PTE to the hash table. 272*17312f25SChristophe Leroy * It is designed to be called with the MMU either on or off. 273*17312f25SChristophe Leroy * r3 contains the VSID, r4 contains the virtual address, 274*17312f25SChristophe Leroy * r5 contains the linux PTE, r6 contains the old value of the 275*17312f25SChristophe Leroy * linux PTE (before setting _PAGE_HASHPTE). r10 contains the 276*17312f25SChristophe Leroy * upper half of the PTE if CONFIG_PTE_64BIT. 277*17312f25SChristophe Leroy * On SMP, the caller should have the mmu_hash_lock held. 278*17312f25SChristophe Leroy * We assume that the caller has (or will) set the _PAGE_HASHPTE 279*17312f25SChristophe Leroy * bit in the linux PTE in memory. The value passed in r6 should 280*17312f25SChristophe Leroy * be the old linux PTE value; if it doesn't have _PAGE_HASHPTE set 281*17312f25SChristophe Leroy * this routine will skip the search for an existing HPTE. 282*17312f25SChristophe Leroy * This procedure modifies r0, r3 - r6, r8, cr0. 283*17312f25SChristophe Leroy * -- paulus. 284*17312f25SChristophe Leroy * 285*17312f25SChristophe Leroy * For speed, 4 of the instructions get patched once the size and 286*17312f25SChristophe Leroy * physical address of the hash table are known. These definitions 287*17312f25SChristophe Leroy * of Hash_base and Hash_bits below are just an example. 288*17312f25SChristophe Leroy */ 289*17312f25SChristophe LeroyHash_base = 0xc0180000 290*17312f25SChristophe LeroyHash_bits = 12 /* e.g. 256kB hash table */ 291*17312f25SChristophe LeroyHash_msk = (((1 << Hash_bits) - 1) * 64) 292*17312f25SChristophe Leroy 293*17312f25SChristophe Leroy/* defines for the PTE format for 32-bit PPCs */ 294*17312f25SChristophe Leroy#define HPTE_SIZE 8 295*17312f25SChristophe Leroy#define PTEG_SIZE 64 296*17312f25SChristophe Leroy#define LG_PTEG_SIZE 6 297*17312f25SChristophe Leroy#define LDPTEu lwzu 298*17312f25SChristophe Leroy#define LDPTE lwz 299*17312f25SChristophe Leroy#define STPTE stw 300*17312f25SChristophe Leroy#define CMPPTE cmpw 301*17312f25SChristophe Leroy#define PTE_H 0x40 302*17312f25SChristophe Leroy#define PTE_V 0x80000000 303*17312f25SChristophe Leroy#define TST_V(r) rlwinm. r,r,0,0,0 304*17312f25SChristophe Leroy#define SET_V(r) oris r,r,PTE_V@h 305*17312f25SChristophe Leroy#define CLR_V(r,t) rlwinm r,r,0,1,31 306*17312f25SChristophe Leroy 307*17312f25SChristophe Leroy#define HASH_LEFT 31-(LG_PTEG_SIZE+Hash_bits-1) 308*17312f25SChristophe Leroy#define HASH_RIGHT 31-LG_PTEG_SIZE 309*17312f25SChristophe Leroy 310*17312f25SChristophe Leroy_GLOBAL(create_hpte) 311*17312f25SChristophe Leroy /* Convert linux-style PTE (r5) to low word of PPC-style PTE (r8) */ 312*17312f25SChristophe Leroy rlwinm r8,r5,32-9,30,30 /* _PAGE_RW -> PP msb */ 313*17312f25SChristophe Leroy rlwinm r0,r5,32-6,30,30 /* _PAGE_DIRTY -> PP msb */ 314*17312f25SChristophe Leroy and r8,r8,r0 /* writable if _RW & _DIRTY */ 315*17312f25SChristophe Leroy rlwimi r5,r5,32-1,30,30 /* _PAGE_USER -> PP msb */ 316*17312f25SChristophe Leroy rlwimi r5,r5,32-2,31,31 /* _PAGE_USER -> PP lsb */ 317*17312f25SChristophe Leroy ori r8,r8,0xe04 /* clear out reserved bits */ 318*17312f25SChristophe Leroy andc r8,r5,r8 /* PP = user? (rw&dirty? 1: 3): 0 */ 319*17312f25SChristophe LeroyBEGIN_FTR_SECTION 320*17312f25SChristophe Leroy rlwinm r8,r8,0,~_PAGE_COHERENT /* clear M (coherence not required) */ 321*17312f25SChristophe LeroyEND_FTR_SECTION_IFCLR(CPU_FTR_NEED_COHERENT) 322*17312f25SChristophe Leroy#ifdef CONFIG_PTE_64BIT 323*17312f25SChristophe Leroy /* Put the XPN bits into the PTE */ 324*17312f25SChristophe Leroy rlwimi r8,r10,8,20,22 325*17312f25SChristophe Leroy rlwimi r8,r10,2,29,29 326*17312f25SChristophe Leroy#endif 327*17312f25SChristophe Leroy 328*17312f25SChristophe Leroy /* Construct the high word of the PPC-style PTE (r5) */ 329*17312f25SChristophe Leroy rlwinm r5,r3,7,1,24 /* put VSID in 0x7fffff80 bits */ 330*17312f25SChristophe Leroy rlwimi r5,r4,10,26,31 /* put in API (abbrev page index) */ 331*17312f25SChristophe Leroy SET_V(r5) /* set V (valid) bit */ 332*17312f25SChristophe Leroy 333*17312f25SChristophe Leroy patch_site 0f, patch__hash_page_A0 334*17312f25SChristophe Leroy patch_site 1f, patch__hash_page_A1 335*17312f25SChristophe Leroy patch_site 2f, patch__hash_page_A2 336*17312f25SChristophe Leroy /* Get the address of the primary PTE group in the hash table (r3) */ 337*17312f25SChristophe Leroy0: lis r0, (Hash_base - PAGE_OFFSET)@h /* base address of hash table */ 338*17312f25SChristophe Leroy1: rlwimi r0,r3,LG_PTEG_SIZE,HASH_LEFT,HASH_RIGHT /* VSID -> hash */ 339*17312f25SChristophe Leroy2: rlwinm r3,r4,20+LG_PTEG_SIZE,HASH_LEFT,HASH_RIGHT /* PI -> hash */ 340*17312f25SChristophe Leroy xor r3,r3,r0 /* make primary hash */ 341*17312f25SChristophe Leroy li r0,8 /* PTEs/group */ 342*17312f25SChristophe Leroy 343*17312f25SChristophe Leroy /* 344*17312f25SChristophe Leroy * Test the _PAGE_HASHPTE bit in the old linux PTE, and skip the search 345*17312f25SChristophe Leroy * if it is clear, meaning that the HPTE isn't there already... 346*17312f25SChristophe Leroy */ 347*17312f25SChristophe Leroy andi. r6,r6,_PAGE_HASHPTE 348*17312f25SChristophe Leroy beq+ 10f /* no PTE: go look for an empty slot */ 349*17312f25SChristophe Leroy tlbie r4 350*17312f25SChristophe Leroy 351*17312f25SChristophe Leroy lis r4, (htab_hash_searches - PAGE_OFFSET)@ha 352*17312f25SChristophe Leroy lwz r6, (htab_hash_searches - PAGE_OFFSET)@l(r4) 353*17312f25SChristophe Leroy addi r6,r6,1 /* count how many searches we do */ 354*17312f25SChristophe Leroy stw r6, (htab_hash_searches - PAGE_OFFSET)@l(r4) 355*17312f25SChristophe Leroy 356*17312f25SChristophe Leroy /* Search the primary PTEG for a PTE whose 1st (d)word matches r5 */ 357*17312f25SChristophe Leroy mtctr r0 358*17312f25SChristophe Leroy addi r4,r3,-HPTE_SIZE 359*17312f25SChristophe Leroy1: LDPTEu r6,HPTE_SIZE(r4) /* get next PTE */ 360*17312f25SChristophe Leroy CMPPTE 0,r6,r5 361*17312f25SChristophe Leroy bdnzf 2,1b /* loop while ctr != 0 && !cr0.eq */ 362*17312f25SChristophe Leroy beq+ found_slot 363*17312f25SChristophe Leroy 364*17312f25SChristophe Leroy patch_site 0f, patch__hash_page_B 365*17312f25SChristophe Leroy /* Search the secondary PTEG for a matching PTE */ 366*17312f25SChristophe Leroy ori r5,r5,PTE_H /* set H (secondary hash) bit */ 367*17312f25SChristophe Leroy0: xoris r4,r3,Hash_msk>>16 /* compute secondary hash */ 368*17312f25SChristophe Leroy xori r4,r4,(-PTEG_SIZE & 0xffff) 369*17312f25SChristophe Leroy addi r4,r4,-HPTE_SIZE 370*17312f25SChristophe Leroy mtctr r0 371*17312f25SChristophe Leroy2: LDPTEu r6,HPTE_SIZE(r4) 372*17312f25SChristophe Leroy CMPPTE 0,r6,r5 373*17312f25SChristophe Leroy bdnzf 2,2b 374*17312f25SChristophe Leroy beq+ found_slot 375*17312f25SChristophe Leroy xori r5,r5,PTE_H /* clear H bit again */ 376*17312f25SChristophe Leroy 377*17312f25SChristophe Leroy /* Search the primary PTEG for an empty slot */ 378*17312f25SChristophe Leroy10: mtctr r0 379*17312f25SChristophe Leroy addi r4,r3,-HPTE_SIZE /* search primary PTEG */ 380*17312f25SChristophe Leroy1: LDPTEu r6,HPTE_SIZE(r4) /* get next PTE */ 381*17312f25SChristophe Leroy TST_V(r6) /* test valid bit */ 382*17312f25SChristophe Leroy bdnzf 2,1b /* loop while ctr != 0 && !cr0.eq */ 383*17312f25SChristophe Leroy beq+ found_empty 384*17312f25SChristophe Leroy 385*17312f25SChristophe Leroy /* update counter of times that the primary PTEG is full */ 386*17312f25SChristophe Leroy lis r4, (primary_pteg_full - PAGE_OFFSET)@ha 387*17312f25SChristophe Leroy lwz r6, (primary_pteg_full - PAGE_OFFSET)@l(r4) 388*17312f25SChristophe Leroy addi r6,r6,1 389*17312f25SChristophe Leroy stw r6, (primary_pteg_full - PAGE_OFFSET)@l(r4) 390*17312f25SChristophe Leroy 391*17312f25SChristophe Leroy patch_site 0f, patch__hash_page_C 392*17312f25SChristophe Leroy /* Search the secondary PTEG for an empty slot */ 393*17312f25SChristophe Leroy ori r5,r5,PTE_H /* set H (secondary hash) bit */ 394*17312f25SChristophe Leroy0: xoris r4,r3,Hash_msk>>16 /* compute secondary hash */ 395*17312f25SChristophe Leroy xori r4,r4,(-PTEG_SIZE & 0xffff) 396*17312f25SChristophe Leroy addi r4,r4,-HPTE_SIZE 397*17312f25SChristophe Leroy mtctr r0 398*17312f25SChristophe Leroy2: LDPTEu r6,HPTE_SIZE(r4) 399*17312f25SChristophe Leroy TST_V(r6) 400*17312f25SChristophe Leroy bdnzf 2,2b 401*17312f25SChristophe Leroy beq+ found_empty 402*17312f25SChristophe Leroy xori r5,r5,PTE_H /* clear H bit again */ 403*17312f25SChristophe Leroy 404*17312f25SChristophe Leroy /* 405*17312f25SChristophe Leroy * Choose an arbitrary slot in the primary PTEG to overwrite. 406*17312f25SChristophe Leroy * Since both the primary and secondary PTEGs are full, and we 407*17312f25SChristophe Leroy * have no information that the PTEs in the primary PTEG are 408*17312f25SChristophe Leroy * more important or useful than those in the secondary PTEG, 409*17312f25SChristophe Leroy * and we know there is a definite (although small) speed 410*17312f25SChristophe Leroy * advantage to putting the PTE in the primary PTEG, we always 411*17312f25SChristophe Leroy * put the PTE in the primary PTEG. 412*17312f25SChristophe Leroy * 413*17312f25SChristophe Leroy * In addition, we skip any slot that is mapping kernel text in 414*17312f25SChristophe Leroy * order to avoid a deadlock when not using BAT mappings if 415*17312f25SChristophe Leroy * trying to hash in the kernel hash code itself after it has 416*17312f25SChristophe Leroy * already taken the hash table lock. This works in conjunction 417*17312f25SChristophe Leroy * with pre-faulting of the kernel text. 418*17312f25SChristophe Leroy * 419*17312f25SChristophe Leroy * If the hash table bucket is full of kernel text entries, we'll 420*17312f25SChristophe Leroy * lockup here but that shouldn't happen 421*17312f25SChristophe Leroy */ 422*17312f25SChristophe Leroy 423*17312f25SChristophe Leroy1: lis r4, (next_slot - PAGE_OFFSET)@ha /* get next evict slot */ 424*17312f25SChristophe Leroy lwz r6, (next_slot - PAGE_OFFSET)@l(r4) 425*17312f25SChristophe Leroy addi r6,r6,HPTE_SIZE /* search for candidate */ 426*17312f25SChristophe Leroy andi. r6,r6,7*HPTE_SIZE 427*17312f25SChristophe Leroy stw r6,next_slot@l(r4) 428*17312f25SChristophe Leroy add r4,r3,r6 429*17312f25SChristophe Leroy LDPTE r0,HPTE_SIZE/2(r4) /* get PTE second word */ 430*17312f25SChristophe Leroy clrrwi r0,r0,12 431*17312f25SChristophe Leroy lis r6,etext@h 432*17312f25SChristophe Leroy ori r6,r6,etext@l /* get etext */ 433*17312f25SChristophe Leroy tophys(r6,r6) 434*17312f25SChristophe Leroy cmpl cr0,r0,r6 /* compare and try again */ 435*17312f25SChristophe Leroy blt 1b 436*17312f25SChristophe Leroy 437*17312f25SChristophe Leroy#ifndef CONFIG_SMP 438*17312f25SChristophe Leroy /* Store PTE in PTEG */ 439*17312f25SChristophe Leroyfound_empty: 440*17312f25SChristophe Leroy STPTE r5,0(r4) 441*17312f25SChristophe Leroyfound_slot: 442*17312f25SChristophe Leroy STPTE r8,HPTE_SIZE/2(r4) 443*17312f25SChristophe Leroy 444*17312f25SChristophe Leroy#else /* CONFIG_SMP */ 445*17312f25SChristophe Leroy/* 446*17312f25SChristophe Leroy * Between the tlbie above and updating the hash table entry below, 447*17312f25SChristophe Leroy * another CPU could read the hash table entry and put it in its TLB. 448*17312f25SChristophe Leroy * There are 3 cases: 449*17312f25SChristophe Leroy * 1. using an empty slot 450*17312f25SChristophe Leroy * 2. updating an earlier entry to change permissions (i.e. enable write) 451*17312f25SChristophe Leroy * 3. taking over the PTE for an unrelated address 452*17312f25SChristophe Leroy * 453*17312f25SChristophe Leroy * In each case it doesn't really matter if the other CPUs have the old 454*17312f25SChristophe Leroy * PTE in their TLB. So we don't need to bother with another tlbie here, 455*17312f25SChristophe Leroy * which is convenient as we've overwritten the register that had the 456*17312f25SChristophe Leroy * address. :-) The tlbie above is mainly to make sure that this CPU comes 457*17312f25SChristophe Leroy * and gets the new PTE from the hash table. 458*17312f25SChristophe Leroy * 459*17312f25SChristophe Leroy * We do however have to make sure that the PTE is never in an invalid 460*17312f25SChristophe Leroy * state with the V bit set. 461*17312f25SChristophe Leroy */ 462*17312f25SChristophe Leroyfound_empty: 463*17312f25SChristophe Leroyfound_slot: 464*17312f25SChristophe Leroy CLR_V(r5,r0) /* clear V (valid) bit in PTE */ 465*17312f25SChristophe Leroy STPTE r5,0(r4) 466*17312f25SChristophe Leroy sync 467*17312f25SChristophe Leroy TLBSYNC 468*17312f25SChristophe Leroy STPTE r8,HPTE_SIZE/2(r4) /* put in correct RPN, WIMG, PP bits */ 469*17312f25SChristophe Leroy sync 470*17312f25SChristophe Leroy SET_V(r5) 471*17312f25SChristophe Leroy STPTE r5,0(r4) /* finally set V bit in PTE */ 472*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 473*17312f25SChristophe Leroy 474*17312f25SChristophe Leroy sync /* make sure pte updates get to memory */ 475*17312f25SChristophe Leroy blr 476*17312f25SChristophe Leroy 477*17312f25SChristophe Leroy .section .bss 478*17312f25SChristophe Leroy .align 2 479*17312f25SChristophe Leroynext_slot: 480*17312f25SChristophe Leroy .space 4 481*17312f25SChristophe Leroyprimary_pteg_full: 482*17312f25SChristophe Leroy .space 4 483*17312f25SChristophe Leroyhtab_hash_searches: 484*17312f25SChristophe Leroy .space 4 485*17312f25SChristophe Leroy .previous 486*17312f25SChristophe Leroy 487*17312f25SChristophe Leroy/* 488*17312f25SChristophe Leroy * Flush the entry for a particular page from the hash table. 489*17312f25SChristophe Leroy * 490*17312f25SChristophe Leroy * flush_hash_pages(unsigned context, unsigned long va, unsigned long pmdval, 491*17312f25SChristophe Leroy * int count) 492*17312f25SChristophe Leroy * 493*17312f25SChristophe Leroy * We assume that there is a hash table in use (Hash != 0). 494*17312f25SChristophe Leroy */ 495*17312f25SChristophe Leroy_GLOBAL(flush_hash_pages) 496*17312f25SChristophe Leroy /* 497*17312f25SChristophe Leroy * We disable interrupts here, even on UP, because we want 498*17312f25SChristophe Leroy * the _PAGE_HASHPTE bit to be a reliable indication of 499*17312f25SChristophe Leroy * whether the HPTE exists (or at least whether one did once). 500*17312f25SChristophe Leroy * We also turn off the MMU for data accesses so that we 501*17312f25SChristophe Leroy * we can't take a hash table miss (assuming the code is 502*17312f25SChristophe Leroy * covered by a BAT). -- paulus 503*17312f25SChristophe Leroy */ 504*17312f25SChristophe Leroy mfmsr r10 505*17312f25SChristophe Leroy SYNC 506*17312f25SChristophe Leroy rlwinm r0,r10,0,17,15 /* clear bit 16 (MSR_EE) */ 507*17312f25SChristophe Leroy rlwinm r0,r0,0,28,26 /* clear MSR_DR */ 508*17312f25SChristophe Leroy mtmsr r0 509*17312f25SChristophe Leroy SYNC_601 510*17312f25SChristophe Leroy isync 511*17312f25SChristophe Leroy 512*17312f25SChristophe Leroy /* First find a PTE in the range that has _PAGE_HASHPTE set */ 513*17312f25SChristophe Leroy#ifndef CONFIG_PTE_64BIT 514*17312f25SChristophe Leroy rlwimi r5,r4,22,20,29 515*17312f25SChristophe Leroy#else 516*17312f25SChristophe Leroy rlwimi r5,r4,23,20,28 517*17312f25SChristophe Leroy#endif 518*17312f25SChristophe Leroy1: lwz r0,PTE_FLAGS_OFFSET(r5) 519*17312f25SChristophe Leroy cmpwi cr1,r6,1 520*17312f25SChristophe Leroy andi. r0,r0,_PAGE_HASHPTE 521*17312f25SChristophe Leroy bne 2f 522*17312f25SChristophe Leroy ble cr1,19f 523*17312f25SChristophe Leroy addi r4,r4,0x1000 524*17312f25SChristophe Leroy addi r5,r5,PTE_SIZE 525*17312f25SChristophe Leroy addi r6,r6,-1 526*17312f25SChristophe Leroy b 1b 527*17312f25SChristophe Leroy 528*17312f25SChristophe Leroy /* Convert context and va to VSID */ 529*17312f25SChristophe Leroy2: mulli r3,r3,897*16 /* multiply context by context skew */ 530*17312f25SChristophe Leroy rlwinm r0,r4,4,28,31 /* get ESID (top 4 bits of va) */ 531*17312f25SChristophe Leroy mulli r0,r0,0x111 /* multiply by ESID skew */ 532*17312f25SChristophe Leroy add r3,r3,r0 /* note code below trims to 24 bits */ 533*17312f25SChristophe Leroy 534*17312f25SChristophe Leroy /* Construct the high word of the PPC-style PTE (r11) */ 535*17312f25SChristophe Leroy rlwinm r11,r3,7,1,24 /* put VSID in 0x7fffff80 bits */ 536*17312f25SChristophe Leroy rlwimi r11,r4,10,26,31 /* put in API (abbrev page index) */ 537*17312f25SChristophe Leroy SET_V(r11) /* set V (valid) bit */ 538*17312f25SChristophe Leroy 539*17312f25SChristophe Leroy#ifdef CONFIG_SMP 540*17312f25SChristophe Leroy lis r9, (mmu_hash_lock - PAGE_OFFSET)@ha 541*17312f25SChristophe Leroy addi r9, r9, (mmu_hash_lock - PAGE_OFFSET)@l 542*17312f25SChristophe Leroy lwz r8,TASK_CPU(r2) 543*17312f25SChristophe Leroy oris r8,r8,9 544*17312f25SChristophe Leroy10: lwarx r0,0,r9 545*17312f25SChristophe Leroy cmpi 0,r0,0 546*17312f25SChristophe Leroy bne- 11f 547*17312f25SChristophe Leroy stwcx. r8,0,r9 548*17312f25SChristophe Leroy beq+ 12f 549*17312f25SChristophe Leroy11: lwz r0,0(r9) 550*17312f25SChristophe Leroy cmpi 0,r0,0 551*17312f25SChristophe Leroy beq 10b 552*17312f25SChristophe Leroy b 11b 553*17312f25SChristophe Leroy12: isync 554*17312f25SChristophe Leroy#endif 555*17312f25SChristophe Leroy 556*17312f25SChristophe Leroy /* 557*17312f25SChristophe Leroy * Check the _PAGE_HASHPTE bit in the linux PTE. If it is 558*17312f25SChristophe Leroy * already clear, we're done (for this pte). If not, 559*17312f25SChristophe Leroy * clear it (atomically) and proceed. -- paulus. 560*17312f25SChristophe Leroy */ 561*17312f25SChristophe Leroy#if (PTE_FLAGS_OFFSET != 0) 562*17312f25SChristophe Leroy addi r5,r5,PTE_FLAGS_OFFSET 563*17312f25SChristophe Leroy#endif 564*17312f25SChristophe Leroy33: lwarx r8,0,r5 /* fetch the pte flags word */ 565*17312f25SChristophe Leroy andi. r0,r8,_PAGE_HASHPTE 566*17312f25SChristophe Leroy beq 8f /* done if HASHPTE is already clear */ 567*17312f25SChristophe Leroy rlwinm r8,r8,0,31,29 /* clear HASHPTE bit */ 568*17312f25SChristophe Leroy stwcx. r8,0,r5 /* update the pte */ 569*17312f25SChristophe Leroy bne- 33b 570*17312f25SChristophe Leroy 571*17312f25SChristophe Leroy patch_site 0f, patch__flush_hash_A0 572*17312f25SChristophe Leroy patch_site 1f, patch__flush_hash_A1 573*17312f25SChristophe Leroy patch_site 2f, patch__flush_hash_A2 574*17312f25SChristophe Leroy /* Get the address of the primary PTE group in the hash table (r3) */ 575*17312f25SChristophe Leroy0: lis r8, (Hash_base - PAGE_OFFSET)@h /* base address of hash table */ 576*17312f25SChristophe Leroy1: rlwimi r8,r3,LG_PTEG_SIZE,HASH_LEFT,HASH_RIGHT /* VSID -> hash */ 577*17312f25SChristophe Leroy2: rlwinm r0,r4,20+LG_PTEG_SIZE,HASH_LEFT,HASH_RIGHT /* PI -> hash */ 578*17312f25SChristophe Leroy xor r8,r0,r8 /* make primary hash */ 579*17312f25SChristophe Leroy 580*17312f25SChristophe Leroy /* Search the primary PTEG for a PTE whose 1st (d)word matches r5 */ 581*17312f25SChristophe Leroy li r0,8 /* PTEs/group */ 582*17312f25SChristophe Leroy mtctr r0 583*17312f25SChristophe Leroy addi r12,r8,-HPTE_SIZE 584*17312f25SChristophe Leroy1: LDPTEu r0,HPTE_SIZE(r12) /* get next PTE */ 585*17312f25SChristophe Leroy CMPPTE 0,r0,r11 586*17312f25SChristophe Leroy bdnzf 2,1b /* loop while ctr != 0 && !cr0.eq */ 587*17312f25SChristophe Leroy beq+ 3f 588*17312f25SChristophe Leroy 589*17312f25SChristophe Leroy patch_site 0f, patch__flush_hash_B 590*17312f25SChristophe Leroy /* Search the secondary PTEG for a matching PTE */ 591*17312f25SChristophe Leroy ori r11,r11,PTE_H /* set H (secondary hash) bit */ 592*17312f25SChristophe Leroy li r0,8 /* PTEs/group */ 593*17312f25SChristophe Leroy0: xoris r12,r8,Hash_msk>>16 /* compute secondary hash */ 594*17312f25SChristophe Leroy xori r12,r12,(-PTEG_SIZE & 0xffff) 595*17312f25SChristophe Leroy addi r12,r12,-HPTE_SIZE 596*17312f25SChristophe Leroy mtctr r0 597*17312f25SChristophe Leroy2: LDPTEu r0,HPTE_SIZE(r12) 598*17312f25SChristophe Leroy CMPPTE 0,r0,r11 599*17312f25SChristophe Leroy bdnzf 2,2b 600*17312f25SChristophe Leroy xori r11,r11,PTE_H /* clear H again */ 601*17312f25SChristophe Leroy bne- 4f /* should rarely fail to find it */ 602*17312f25SChristophe Leroy 603*17312f25SChristophe Leroy3: li r0,0 604*17312f25SChristophe Leroy STPTE r0,0(r12) /* invalidate entry */ 605*17312f25SChristophe Leroy4: sync 606*17312f25SChristophe Leroy tlbie r4 /* in hw tlb too */ 607*17312f25SChristophe Leroy sync 608*17312f25SChristophe Leroy 609*17312f25SChristophe Leroy8: ble cr1,9f /* if all ptes checked */ 610*17312f25SChristophe Leroy81: addi r6,r6,-1 611*17312f25SChristophe Leroy addi r5,r5,PTE_SIZE 612*17312f25SChristophe Leroy addi r4,r4,0x1000 613*17312f25SChristophe Leroy lwz r0,0(r5) /* check next pte */ 614*17312f25SChristophe Leroy cmpwi cr1,r6,1 615*17312f25SChristophe Leroy andi. r0,r0,_PAGE_HASHPTE 616*17312f25SChristophe Leroy bne 33b 617*17312f25SChristophe Leroy bgt cr1,81b 618*17312f25SChristophe Leroy 619*17312f25SChristophe Leroy9: 620*17312f25SChristophe Leroy#ifdef CONFIG_SMP 621*17312f25SChristophe Leroy TLBSYNC 622*17312f25SChristophe Leroy li r0,0 623*17312f25SChristophe Leroy stw r0,0(r9) /* clear mmu_hash_lock */ 624*17312f25SChristophe Leroy#endif 625*17312f25SChristophe Leroy 626*17312f25SChristophe Leroy19: mtmsr r10 627*17312f25SChristophe Leroy SYNC_601 628*17312f25SChristophe Leroy isync 629*17312f25SChristophe Leroy blr 630*17312f25SChristophe LeroyEXPORT_SYMBOL(flush_hash_pages) 631*17312f25SChristophe Leroy 632*17312f25SChristophe Leroy/* 633*17312f25SChristophe Leroy * Flush an entry from the TLB 634*17312f25SChristophe Leroy */ 635*17312f25SChristophe Leroy_GLOBAL(_tlbie) 636*17312f25SChristophe Leroy#ifdef CONFIG_SMP 637*17312f25SChristophe Leroy lwz r8,TASK_CPU(r2) 638*17312f25SChristophe Leroy oris r8,r8,11 639*17312f25SChristophe Leroy mfmsr r10 640*17312f25SChristophe Leroy SYNC 641*17312f25SChristophe Leroy rlwinm r0,r10,0,17,15 /* clear bit 16 (MSR_EE) */ 642*17312f25SChristophe Leroy rlwinm r0,r0,0,28,26 /* clear DR */ 643*17312f25SChristophe Leroy mtmsr r0 644*17312f25SChristophe Leroy SYNC_601 645*17312f25SChristophe Leroy isync 646*17312f25SChristophe Leroy lis r9,mmu_hash_lock@h 647*17312f25SChristophe Leroy ori r9,r9,mmu_hash_lock@l 648*17312f25SChristophe Leroy tophys(r9,r9) 649*17312f25SChristophe Leroy10: lwarx r7,0,r9 650*17312f25SChristophe Leroy cmpwi 0,r7,0 651*17312f25SChristophe Leroy bne- 10b 652*17312f25SChristophe Leroy stwcx. r8,0,r9 653*17312f25SChristophe Leroy bne- 10b 654*17312f25SChristophe Leroy eieio 655*17312f25SChristophe Leroy tlbie r3 656*17312f25SChristophe Leroy sync 657*17312f25SChristophe Leroy TLBSYNC 658*17312f25SChristophe Leroy li r0,0 659*17312f25SChristophe Leroy stw r0,0(r9) /* clear mmu_hash_lock */ 660*17312f25SChristophe Leroy mtmsr r10 661*17312f25SChristophe Leroy SYNC_601 662*17312f25SChristophe Leroy isync 663*17312f25SChristophe Leroy#else /* CONFIG_SMP */ 664*17312f25SChristophe Leroy tlbie r3 665*17312f25SChristophe Leroy sync 666*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 667*17312f25SChristophe Leroy blr 668*17312f25SChristophe Leroy 669*17312f25SChristophe Leroy/* 670*17312f25SChristophe Leroy * Flush the entire TLB. 603/603e only 671*17312f25SChristophe Leroy */ 672*17312f25SChristophe Leroy_GLOBAL(_tlbia) 673*17312f25SChristophe Leroy#if defined(CONFIG_SMP) 674*17312f25SChristophe Leroy lwz r8,TASK_CPU(r2) 675*17312f25SChristophe Leroy oris r8,r8,10 676*17312f25SChristophe Leroy mfmsr r10 677*17312f25SChristophe Leroy SYNC 678*17312f25SChristophe Leroy rlwinm r0,r10,0,17,15 /* clear bit 16 (MSR_EE) */ 679*17312f25SChristophe Leroy rlwinm r0,r0,0,28,26 /* clear DR */ 680*17312f25SChristophe Leroy mtmsr r0 681*17312f25SChristophe Leroy SYNC_601 682*17312f25SChristophe Leroy isync 683*17312f25SChristophe Leroy lis r9,mmu_hash_lock@h 684*17312f25SChristophe Leroy ori r9,r9,mmu_hash_lock@l 685*17312f25SChristophe Leroy tophys(r9,r9) 686*17312f25SChristophe Leroy10: lwarx r7,0,r9 687*17312f25SChristophe Leroy cmpwi 0,r7,0 688*17312f25SChristophe Leroy bne- 10b 689*17312f25SChristophe Leroy stwcx. r8,0,r9 690*17312f25SChristophe Leroy bne- 10b 691*17312f25SChristophe Leroy sync 692*17312f25SChristophe Leroy tlbia 693*17312f25SChristophe Leroy sync 694*17312f25SChristophe Leroy TLBSYNC 695*17312f25SChristophe Leroy li r0,0 696*17312f25SChristophe Leroy stw r0,0(r9) /* clear mmu_hash_lock */ 697*17312f25SChristophe Leroy mtmsr r10 698*17312f25SChristophe Leroy SYNC_601 699*17312f25SChristophe Leroy isync 700*17312f25SChristophe Leroy#else /* CONFIG_SMP */ 701*17312f25SChristophe Leroy sync 702*17312f25SChristophe Leroy tlbia 703*17312f25SChristophe Leroy sync 704*17312f25SChristophe Leroy#endif /* CONFIG_SMP */ 705*17312f25SChristophe Leroy blr 706