1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* 1. Find the index of the entry we're executing in */
4 bl invstr /* Find our address */
5 invstr: mflr r6 /* Make it accessible */
7 rlwinm r4,r7,27,31,31 /* extract MSR[IS] */
12 tlbsx 0,r6 /* search MSR[IS], SPID=PID0 */
14 andis. r7,r7,MAS1_VALID@h
18 rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
20 bne match_TLB /* skip if NPIDS != 3 */
26 tlbsx 0,r6 /* search MSR[IS], SPID=PID1 */
28 andis. r7,r7,MAS1_VALID@h
34 tlbsx 0,r6 /* Fall through, we had to match */
38 rlwinm r3,r7,16,20,31 /* Extract MAS0(Entry) */
40 mfspr r7,SPRN_MAS1 /* Insure IPROT set */
41 oris r7,r7,MAS1_IPROT@h
45 /* 2. Invalidate all entries except the entry we're executing in */
48 li r6,0 /* Set Entry counter to 0 */
49 1: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
50 rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */
54 rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */
56 beq skpinv /* Dont update the current execution TLB */
60 skpinv: addi r6,r6,1 /* Increment */
61 cmpw r6,r9 /* Are we done? */
62 bne 1b /* If not, repeat */
73 /* 3. Setup a temp mapping and jump to it */
74 andi. r5, r3, 0x1 /* Find an entry not used and is non-zero */
76 lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
77 rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
81 /* grab and fixup the RPN */
82 mfspr r6,SPRN_MAS1 /* extract MAS1[SIZE] */
86 slw r6,r8,r6 /* convert to mask */
88 bl 1f /* Find our address */
92 #ifdef CONFIG_PHYS_64BIT
100 ori r8,r25,(MAS3_SX|MAS3_SW|MAS3_SR)
102 /* Just modify the entry ID and EPN for the temp mapping */
103 lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
104 rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
106 xori r6,r4,1 /* Setup TMP mapping in the other Address space */
108 oris r6,r6,(MAS1_VALID|MAS1_IPROT)@h
109 ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_4K))@l
112 li r7,0 /* temp EPN = 0 */
119 slwi r6,r6,5 /* setup new context with other address space */
120 bl 1f /* Find our address */
128 /* 4. Clear out PIDs & Search info */
134 rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
136 bne 2f /* skip if NPIDS != 3 */
141 /* 5. Invalidate mapping we started in */
143 lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
144 rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
148 rlwinm r6,r6,0,2,0 /* clear IPROT */
151 /* Invalidate TLB1 */
156 #if defined(ENTRY_MAPPING_BOOT_SETUP)
158 /* 6. Setup kernstart_virt_addr mapping in TLB1[0] */
159 lis r6,0x1000 /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
161 lis r6,(MAS1_VALID|MAS1_IPROT)@h
162 ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_64M))@l
164 lis r6,MAS2_EPN_MASK(BOOK3E_PAGESZ_64M)@h
165 ori r6,r6,MAS2_EPN_MASK(BOOK3E_PAGESZ_64M)@l
167 ori r6,r6,MAS2_M_IF_NEEDED@l
172 /* 7. Jump to kernstart_virt_addr mapping */
175 #elif defined(ENTRY_MAPPING_KEXEC_SETUP)
177 * 6. Setup a 1:1 mapping in TLB1. Esel 0 is unsued, 1 or 2 contains the tmp
178 * mapping so we start at 3. We setup 8 mappings, each 256MiB in size. This
179 * will cover the first 2GiB of memory.
182 lis r10, (MAS1_VALID|MAS1_IPROT)@h
183 ori r10,r10, (MAS1_TSIZE(BOOK3E_PAGESZ_256M))@l
190 rlwinm r0, r0, 16, 4, 15 // Compute esel
191 rlwinm r9, r11, 28, 0, 3 // Compute [ER]PN
192 oris r0, r0, (MAS0_TLBSEL(1))@h
196 ori r9, r9, (MAS3_SX|MAS3_SW|MAS3_SR)
202 /* 7. Jump to our 1:1 mapping */
205 #error You need to specify the mapping or not use this at all.
209 ori r7,r7,MSR_KERNEL@l
210 bl 1f /* Find our address */
216 rfi /* start execution out of TLB1[0] entry */
218 /* 8. Clear out the temp mapping */
219 2: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
220 rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
224 rlwinm r8,r8,0,2,0 /* clear IPROT */
227 /* Invalidate TLB1 */