Commit | Line | Data |
---|---|---|
14cf11af | 1 | /* |
14cf11af PM |
2 | * PowerPC version |
3 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) | |
4 | * | |
5 | * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP | |
6 | * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu> | |
7 | * Adapted for Power Macintosh by Paul Mackerras. | |
8 | * Low-level exception handlers and MMU support | |
9 | * rewritten by Paul Mackerras. | |
10 | * Copyright (C) 1996 Paul Mackerras. | |
11 | * | |
12 | * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and | |
13 | * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com | |
14 | * | |
15 | * This file contains the low-level support and setup for the | |
16 | * PowerPC-64 platform, including trap and interrupt dispatch. | |
17 | * | |
18 | * This program is free software; you can redistribute it and/or | |
19 | * modify it under the terms of the GNU General Public License | |
20 | * as published by the Free Software Foundation; either version | |
21 | * 2 of the License, or (at your option) any later version. | |
22 | */ | |
23 | ||
24 | #include <linux/config.h> | |
25 | #include <linux/threads.h> | |
b5bbeb23 | 26 | #include <asm/reg.h> |
14cf11af PM |
27 | #include <asm/page.h> |
28 | #include <asm/mmu.h> | |
14cf11af PM |
29 | #include <asm/ppc_asm.h> |
30 | #include <asm/asm-offsets.h> | |
31 | #include <asm/bug.h> | |
32 | #include <asm/cputable.h> | |
33 | #include <asm/setup.h> | |
34 | #include <asm/hvcall.h> | |
c43a55ff | 35 | #include <asm/iseries/lpar_map.h> |
6cb7bfeb | 36 | #include <asm/thread_info.h> |
14cf11af PM |
37 | |
38 | #ifdef CONFIG_PPC_ISERIES | |
39 | #define DO_SOFT_DISABLE | |
40 | #endif | |
41 | ||
42 | /* | |
43 | * We layout physical memory as follows: | |
44 | * 0x0000 - 0x00ff : Secondary processor spin code | |
45 | * 0x0100 - 0x2fff : pSeries Interrupt prologs | |
46 | * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs | |
47 | * 0x6000 - 0x6fff : Initial (CPU0) segment table | |
48 | * 0x7000 - 0x7fff : FWNMI data area | |
49 | * 0x8000 - : Early init and support code | |
50 | */ | |
51 | ||
52 | /* | |
53 | * SPRG Usage | |
54 | * | |
55 | * Register Definition | |
56 | * | |
57 | * SPRG0 reserved for hypervisor | |
58 | * SPRG1 temp - used to save gpr | |
59 | * SPRG2 temp - used to save gpr | |
60 | * SPRG3 virt addr of paca | |
61 | */ | |
62 | ||
63 | /* | |
64 | * Entering into this code we make the following assumptions: | |
65 | * For pSeries: | |
66 | * 1. The MMU is off & open firmware is running in real mode. | |
67 | * 2. The kernel is entered at __start | |
68 | * | |
69 | * For iSeries: | |
70 | * 1. The MMU is on (as it always is for iSeries) | |
71 | * 2. The kernel is entered at system_reset_iSeries | |
72 | */ | |
73 | ||
74 | .text | |
75 | .globl _stext | |
76 | _stext: | |
77 | #ifdef CONFIG_PPC_MULTIPLATFORM | |
78 | _GLOBAL(__start) | |
79 | /* NOP this out unconditionally */ | |
80 | BEGIN_FTR_SECTION | |
b85a046a | 81 | b .__start_initialization_multiplatform |
14cf11af PM |
82 | END_FTR_SECTION(0, 1) |
83 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | |
84 | ||
85 | /* Catch branch to 0 in real mode */ | |
86 | trap | |
87 | ||
14cf11af PM |
88 | /* Secondary processors spin on this value until it goes to 1. */ |
89 | .globl __secondary_hold_spinloop | |
90 | __secondary_hold_spinloop: | |
91 | .llong 0x0 | |
92 | ||
93 | /* Secondary processors write this value with their cpu # */ | |
94 | /* after they enter the spin loop immediately below. */ | |
95 | .globl __secondary_hold_acknowledge | |
96 | __secondary_hold_acknowledge: | |
97 | .llong 0x0 | |
98 | ||
1dce0e30 ME |
99 | #ifdef CONFIG_PPC_ISERIES |
100 | /* | |
101 | * At offset 0x20, there is a pointer to iSeries LPAR data. | |
102 | * This is required by the hypervisor | |
103 | */ | |
104 | . = 0x20 | |
105 | .llong hvReleaseData-KERNELBASE | |
106 | #endif /* CONFIG_PPC_ISERIES */ | |
107 | ||
14cf11af PM |
108 | . = 0x60 |
109 | /* | |
110 | * The following code is used on pSeries to hold secondary processors | |
111 | * in a spin loop after they have been freed from OpenFirmware, but | |
112 | * before the bulk of the kernel has been relocated. This code | |
113 | * is relocated to physical address 0x60 before prom_init is run. | |
114 | * All of it must fit below the first exception vector at 0x100. | |
115 | */ | |
116 | _GLOBAL(__secondary_hold) | |
117 | mfmsr r24 | |
118 | ori r24,r24,MSR_RI | |
119 | mtmsrd r24 /* RI on */ | |
120 | ||
f1870f77 | 121 | /* Grab our physical cpu number */ |
14cf11af PM |
122 | mr r24,r3 |
123 | ||
124 | /* Tell the master cpu we're here */ | |
125 | /* Relocation is off & we are located at an address less */ | |
126 | /* than 0x100, so only need to grab low order offset. */ | |
127 | std r24,__secondary_hold_acknowledge@l(0) | |
128 | sync | |
129 | ||
130 | /* All secondary cpus wait here until told to start. */ | |
131 | 100: ld r4,__secondary_hold_spinloop@l(0) | |
132 | cmpdi 0,r4,1 | |
133 | bne 100b | |
134 | ||
f1870f77 | 135 | #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) |
e58c3495 | 136 | LOAD_REG_IMMEDIATE(r4, .pSeries_secondary_smp_init) |
758438a7 | 137 | mtctr r4 |
14cf11af | 138 | mr r3,r24 |
758438a7 | 139 | bctr |
14cf11af PM |
140 | #else |
141 | BUG_OPCODE | |
142 | #endif | |
14cf11af PM |
143 | |
144 | /* This value is used to mark exception frames on the stack. */ | |
145 | .section ".toc","aw" | |
146 | exception_marker: | |
147 | .tc ID_72656773_68657265[TC],0x7265677368657265 | |
148 | .text | |
149 | ||
150 | /* | |
151 | * The following macros define the code that appears as | |
152 | * the prologue to each of the exception handlers. They | |
153 | * are split into two parts to allow a single kernel binary | |
154 | * to be used for pSeries and iSeries. | |
155 | * LOL. One day... - paulus | |
156 | */ | |
157 | ||
158 | /* | |
159 | * We make as much of the exception code common between native | |
160 | * exception handlers (including pSeries LPAR) and iSeries LPAR | |
161 | * implementations as possible. | |
162 | */ | |
163 | ||
164 | /* | |
165 | * This is the start of the interrupt handlers for pSeries | |
166 | * This code runs with relocation off. | |
167 | */ | |
168 | #define EX_R9 0 | |
169 | #define EX_R10 8 | |
170 | #define EX_R11 16 | |
171 | #define EX_R12 24 | |
172 | #define EX_R13 32 | |
173 | #define EX_SRR0 40 | |
14cf11af | 174 | #define EX_DAR 48 |
14cf11af PM |
175 | #define EX_DSISR 56 |
176 | #define EX_CCR 60 | |
3c726f8d BH |
177 | #define EX_R3 64 |
178 | #define EX_LR 72 | |
14cf11af | 179 | |
758438a7 | 180 | /* |
e58c3495 DG |
181 | * We're short on space and time in the exception prolog, so we can't |
182 | * use the normal SET_REG_IMMEDIATE macro. Normally we just need the | |
183 | * low halfword of the address, but for Kdump we need the whole low | |
184 | * word. | |
758438a7 ME |
185 | */ |
186 | #ifdef CONFIG_CRASH_DUMP | |
187 | #define LOAD_HANDLER(reg, label) \ | |
188 | oris reg,reg,(label)@h; /* virt addr of handler ... */ \ | |
189 | ori reg,reg,(label)@l; /* .. and the rest */ | |
190 | #else | |
191 | #define LOAD_HANDLER(reg, label) \ | |
192 | ori reg,reg,(label)@l; /* virt addr of handler ... */ | |
193 | #endif | |
194 | ||
14cf11af | 195 | #define EXCEPTION_PROLOG_PSERIES(area, label) \ |
b5bbeb23 | 196 | mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \ |
14cf11af PM |
197 | std r9,area+EX_R9(r13); /* save r9 - r12 */ \ |
198 | std r10,area+EX_R10(r13); \ | |
199 | std r11,area+EX_R11(r13); \ | |
200 | std r12,area+EX_R12(r13); \ | |
b5bbeb23 | 201 | mfspr r9,SPRN_SPRG1; \ |
14cf11af PM |
202 | std r9,area+EX_R13(r13); \ |
203 | mfcr r9; \ | |
204 | clrrdi r12,r13,32; /* get high part of &label */ \ | |
205 | mfmsr r10; \ | |
b5bbeb23 | 206 | mfspr r11,SPRN_SRR0; /* save SRR0 */ \ |
758438a7 | 207 | LOAD_HANDLER(r12,label) \ |
14cf11af | 208 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI; \ |
b5bbeb23 PM |
209 | mtspr SPRN_SRR0,r12; \ |
210 | mfspr r12,SPRN_SRR1; /* and SRR1 */ \ | |
211 | mtspr SPRN_SRR1,r10; \ | |
14cf11af PM |
212 | rfid; \ |
213 | b . /* prevent speculative execution */ | |
214 | ||
215 | /* | |
216 | * This is the start of the interrupt handlers for iSeries | |
217 | * This code runs with relocation on. | |
218 | */ | |
219 | #define EXCEPTION_PROLOG_ISERIES_1(area) \ | |
b5bbeb23 | 220 | mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \ |
14cf11af PM |
221 | std r9,area+EX_R9(r13); /* save r9 - r12 */ \ |
222 | std r10,area+EX_R10(r13); \ | |
223 | std r11,area+EX_R11(r13); \ | |
224 | std r12,area+EX_R12(r13); \ | |
b5bbeb23 | 225 | mfspr r9,SPRN_SPRG1; \ |
14cf11af PM |
226 | std r9,area+EX_R13(r13); \ |
227 | mfcr r9 | |
228 | ||
229 | #define EXCEPTION_PROLOG_ISERIES_2 \ | |
230 | mfmsr r10; \ | |
3356bb9f DG |
231 | ld r12,PACALPPACAPTR(r13); \ |
232 | ld r11,LPPACASRR0(r12); \ | |
233 | ld r12,LPPACASRR1(r12); \ | |
14cf11af PM |
234 | ori r10,r10,MSR_RI; \ |
235 | mtmsrd r10,1 | |
236 | ||
237 | /* | |
238 | * The common exception prolog is used for all except a few exceptions | |
239 | * such as a segment miss on a kernel address. We have to be prepared | |
240 | * to take another exception from the point where we first touch the | |
241 | * kernel stack onwards. | |
242 | * | |
243 | * On entry r13 points to the paca, r9-r13 are saved in the paca, | |
244 | * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and | |
245 | * SRR1, and relocation is on. | |
246 | */ | |
247 | #define EXCEPTION_PROLOG_COMMON(n, area) \ | |
248 | andi. r10,r12,MSR_PR; /* See if coming from user */ \ | |
249 | mr r10,r1; /* Save r1 */ \ | |
250 | subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ | |
251 | beq- 1f; \ | |
252 | ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ | |
253 | 1: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \ | |
254 | bge- cr1,bad_stack; /* abort if it is */ \ | |
255 | std r9,_CCR(r1); /* save CR in stackframe */ \ | |
256 | std r11,_NIP(r1); /* save SRR0 in stackframe */ \ | |
257 | std r12,_MSR(r1); /* save SRR1 in stackframe */ \ | |
258 | std r10,0(r1); /* make stack chain pointer */ \ | |
259 | std r0,GPR0(r1); /* save r0 in stackframe */ \ | |
260 | std r10,GPR1(r1); /* save r1 in stackframe */ \ | |
c6622f63 | 261 | ACCOUNT_CPU_USER_ENTRY(r9, r10); \ |
14cf11af PM |
262 | std r2,GPR2(r1); /* save r2 in stackframe */ \ |
263 | SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ | |
264 | SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ | |
265 | ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \ | |
266 | ld r10,area+EX_R10(r13); \ | |
267 | std r9,GPR9(r1); \ | |
268 | std r10,GPR10(r1); \ | |
269 | ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \ | |
270 | ld r10,area+EX_R12(r13); \ | |
271 | ld r11,area+EX_R13(r13); \ | |
272 | std r9,GPR11(r1); \ | |
273 | std r10,GPR12(r1); \ | |
274 | std r11,GPR13(r1); \ | |
275 | ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ | |
276 | mflr r9; /* save LR in stackframe */ \ | |
277 | std r9,_LINK(r1); \ | |
278 | mfctr r10; /* save CTR in stackframe */ \ | |
279 | std r10,_CTR(r1); \ | |
b5bbeb23 | 280 | mfspr r11,SPRN_XER; /* save XER in stackframe */ \ |
14cf11af PM |
281 | std r11,_XER(r1); \ |
282 | li r9,(n)+1; \ | |
283 | std r9,_TRAP(r1); /* set trap number */ \ | |
284 | li r10,0; \ | |
285 | ld r11,exception_marker@toc(r2); \ | |
286 | std r10,RESULT(r1); /* clear regs->result */ \ | |
287 | std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ | |
288 | ||
289 | /* | |
290 | * Exception vectors. | |
291 | */ | |
292 | #define STD_EXCEPTION_PSERIES(n, label) \ | |
293 | . = n; \ | |
294 | .globl label##_pSeries; \ | |
295 | label##_pSeries: \ | |
296 | HMT_MEDIUM; \ | |
b5bbeb23 | 297 | mtspr SPRN_SPRG1,r13; /* save r13 */ \ |
14cf11af PM |
298 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) |
299 | ||
acf7d768 BH |
300 | #define HSTD_EXCEPTION_PSERIES(n, label) \ |
301 | . = n; \ | |
302 | .globl label##_pSeries; \ | |
303 | label##_pSeries: \ | |
304 | HMT_MEDIUM; \ | |
305 | mtspr SPRN_SPRG1,r20; /* save r20 */ \ | |
306 | mfspr r20,SPRN_HSRR0; /* copy HSRR0 to SRR0 */ \ | |
307 | mtspr SPRN_SRR0,r20; \ | |
308 | mfspr r20,SPRN_HSRR1; /* copy HSRR0 to SRR0 */ \ | |
309 | mtspr SPRN_SRR1,r20; \ | |
310 | mfspr r20,SPRN_SPRG1; /* restore r20 */ \ | |
311 | mtspr SPRN_SPRG1,r13; /* save r13 */ \ | |
312 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) | |
313 | ||
314 | ||
14cf11af PM |
315 | #define STD_EXCEPTION_ISERIES(n, label, area) \ |
316 | .globl label##_iSeries; \ | |
317 | label##_iSeries: \ | |
318 | HMT_MEDIUM; \ | |
b5bbeb23 | 319 | mtspr SPRN_SPRG1,r13; /* save r13 */ \ |
14cf11af PM |
320 | EXCEPTION_PROLOG_ISERIES_1(area); \ |
321 | EXCEPTION_PROLOG_ISERIES_2; \ | |
322 | b label##_common | |
323 | ||
324 | #define MASKABLE_EXCEPTION_ISERIES(n, label) \ | |
325 | .globl label##_iSeries; \ | |
326 | label##_iSeries: \ | |
327 | HMT_MEDIUM; \ | |
b5bbeb23 | 328 | mtspr SPRN_SPRG1,r13; /* save r13 */ \ |
14cf11af PM |
329 | EXCEPTION_PROLOG_ISERIES_1(PACA_EXGEN); \ |
330 | lbz r10,PACAPROCENABLED(r13); \ | |
331 | cmpwi 0,r10,0; \ | |
332 | beq- label##_iSeries_masked; \ | |
333 | EXCEPTION_PROLOG_ISERIES_2; \ | |
334 | b label##_common; \ | |
335 | ||
336 | #ifdef DO_SOFT_DISABLE | |
337 | #define DISABLE_INTS \ | |
338 | lbz r10,PACAPROCENABLED(r13); \ | |
339 | li r11,0; \ | |
340 | std r10,SOFTE(r1); \ | |
341 | mfmsr r10; \ | |
342 | stb r11,PACAPROCENABLED(r13); \ | |
343 | ori r10,r10,MSR_EE; \ | |
344 | mtmsrd r10,1 | |
345 | ||
346 | #define ENABLE_INTS \ | |
347 | lbz r10,PACAPROCENABLED(r13); \ | |
348 | mfmsr r11; \ | |
349 | std r10,SOFTE(r1); \ | |
350 | ori r11,r11,MSR_EE; \ | |
351 | mtmsrd r11,1 | |
352 | ||
353 | #else /* hard enable/disable interrupts */ | |
354 | #define DISABLE_INTS | |
355 | ||
356 | #define ENABLE_INTS \ | |
357 | ld r12,_MSR(r1); \ | |
358 | mfmsr r11; \ | |
359 | rlwimi r11,r12,0,MSR_EE; \ | |
360 | mtmsrd r11,1 | |
361 | ||
362 | #endif | |
363 | ||
364 | #define STD_EXCEPTION_COMMON(trap, label, hdlr) \ | |
365 | .align 7; \ | |
366 | .globl label##_common; \ | |
367 | label##_common: \ | |
368 | EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ | |
369 | DISABLE_INTS; \ | |
370 | bl .save_nvgprs; \ | |
371 | addi r3,r1,STACK_FRAME_OVERHEAD; \ | |
372 | bl hdlr; \ | |
373 | b .ret_from_except | |
374 | ||
f39224a8 PM |
375 | /* |
376 | * Like STD_EXCEPTION_COMMON, but for exceptions that can occur | |
377 | * in the idle task and therefore need the special idle handling. | |
378 | */ | |
379 | #define STD_EXCEPTION_COMMON_IDLE(trap, label, hdlr) \ | |
380 | .align 7; \ | |
381 | .globl label##_common; \ | |
382 | label##_common: \ | |
383 | EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ | |
384 | FINISH_NAP; \ | |
385 | DISABLE_INTS; \ | |
386 | bl .save_nvgprs; \ | |
387 | addi r3,r1,STACK_FRAME_OVERHEAD; \ | |
388 | bl hdlr; \ | |
389 | b .ret_from_except | |
390 | ||
14cf11af PM |
391 | #define STD_EXCEPTION_COMMON_LITE(trap, label, hdlr) \ |
392 | .align 7; \ | |
393 | .globl label##_common; \ | |
394 | label##_common: \ | |
395 | EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \ | |
f39224a8 | 396 | FINISH_NAP; \ |
14cf11af | 397 | DISABLE_INTS; \ |
cb2c9b27 | 398 | bl .ppc64_runlatch_on; \ |
14cf11af PM |
399 | addi r3,r1,STACK_FRAME_OVERHEAD; \ |
400 | bl hdlr; \ | |
401 | b .ret_from_except_lite | |
402 | ||
f39224a8 PM |
403 | /* |
404 | * When the idle code in power4_idle puts the CPU into NAP mode, | |
405 | * it has to do so in a loop, and relies on the external interrupt | |
406 | * and decrementer interrupt entry code to get it out of the loop. | |
407 | * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags | |
408 | * to signal that it is in the loop and needs help to get out. | |
409 | */ | |
410 | #ifdef CONFIG_PPC_970_NAP | |
411 | #define FINISH_NAP \ | |
412 | BEGIN_FTR_SECTION \ | |
413 | clrrdi r11,r1,THREAD_SHIFT; \ | |
414 | ld r9,TI_LOCAL_FLAGS(r11); \ | |
415 | andi. r10,r9,_TLF_NAPPING; \ | |
416 | bnel power4_fixup_nap; \ | |
417 | END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) | |
418 | #else | |
419 | #define FINISH_NAP | |
420 | #endif | |
421 | ||
14cf11af PM |
422 | /* |
423 | * Start of pSeries system interrupt routines | |
424 | */ | |
425 | . = 0x100 | |
426 | .globl __start_interrupts | |
427 | __start_interrupts: | |
428 | ||
429 | STD_EXCEPTION_PSERIES(0x100, system_reset) | |
430 | ||
431 | . = 0x200 | |
432 | _machine_check_pSeries: | |
433 | HMT_MEDIUM | |
b5bbeb23 | 434 | mtspr SPRN_SPRG1,r13 /* save r13 */ |
14cf11af PM |
435 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common) |
436 | ||
437 | . = 0x300 | |
438 | .globl data_access_pSeries | |
439 | data_access_pSeries: | |
440 | HMT_MEDIUM | |
b5bbeb23 | 441 | mtspr SPRN_SPRG1,r13 |
14cf11af | 442 | BEGIN_FTR_SECTION |
b5bbeb23 PM |
443 | mtspr SPRN_SPRG2,r12 |
444 | mfspr r13,SPRN_DAR | |
445 | mfspr r12,SPRN_DSISR | |
14cf11af PM |
446 | srdi r13,r13,60 |
447 | rlwimi r13,r12,16,0x20 | |
448 | mfcr r12 | |
449 | cmpwi r13,0x2c | |
450 | beq .do_stab_bolted_pSeries | |
451 | mtcrf 0x80,r12 | |
b5bbeb23 | 452 | mfspr r12,SPRN_SPRG2 |
14cf11af PM |
453 | END_FTR_SECTION_IFCLR(CPU_FTR_SLB) |
454 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common) | |
455 | ||
456 | . = 0x380 | |
457 | .globl data_access_slb_pSeries | |
458 | data_access_slb_pSeries: | |
459 | HMT_MEDIUM | |
b5bbeb23 | 460 | mtspr SPRN_SPRG1,r13 |
b5bbeb23 | 461 | mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ |
3c726f8d BH |
462 | std r3,PACA_EXSLB+EX_R3(r13) |
463 | mfspr r3,SPRN_DAR | |
14cf11af | 464 | std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ |
3c726f8d BH |
465 | mfcr r9 |
466 | #ifdef __DISABLED__ | |
467 | /* Keep that around for when we re-implement dynamic VSIDs */ | |
468 | cmpdi r3,0 | |
469 | bge slb_miss_user_pseries | |
470 | #endif /* __DISABLED__ */ | |
14cf11af PM |
471 | std r10,PACA_EXSLB+EX_R10(r13) |
472 | std r11,PACA_EXSLB+EX_R11(r13) | |
473 | std r12,PACA_EXSLB+EX_R12(r13) | |
3c726f8d BH |
474 | mfspr r10,SPRN_SPRG1 |
475 | std r10,PACA_EXSLB+EX_R13(r13) | |
b5bbeb23 | 476 | mfspr r12,SPRN_SRR1 /* and SRR1 */ |
3c726f8d | 477 | b .slb_miss_realmode /* Rel. branch works in real mode */ |
14cf11af PM |
478 | |
479 | STD_EXCEPTION_PSERIES(0x400, instruction_access) | |
480 | ||
481 | . = 0x480 | |
482 | .globl instruction_access_slb_pSeries | |
483 | instruction_access_slb_pSeries: | |
484 | HMT_MEDIUM | |
b5bbeb23 | 485 | mtspr SPRN_SPRG1,r13 |
b5bbeb23 | 486 | mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ |
3c726f8d BH |
487 | std r3,PACA_EXSLB+EX_R3(r13) |
488 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ | |
14cf11af | 489 | std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ |
3c726f8d BH |
490 | mfcr r9 |
491 | #ifdef __DISABLED__ | |
492 | /* Keep that around for when we re-implement dynamic VSIDs */ | |
493 | cmpdi r3,0 | |
494 | bge slb_miss_user_pseries | |
495 | #endif /* __DISABLED__ */ | |
14cf11af PM |
496 | std r10,PACA_EXSLB+EX_R10(r13) |
497 | std r11,PACA_EXSLB+EX_R11(r13) | |
498 | std r12,PACA_EXSLB+EX_R12(r13) | |
3c726f8d BH |
499 | mfspr r10,SPRN_SPRG1 |
500 | std r10,PACA_EXSLB+EX_R13(r13) | |
b5bbeb23 | 501 | mfspr r12,SPRN_SRR1 /* and SRR1 */ |
3c726f8d | 502 | b .slb_miss_realmode /* Rel. branch works in real mode */ |
14cf11af PM |
503 | |
504 | STD_EXCEPTION_PSERIES(0x500, hardware_interrupt) | |
505 | STD_EXCEPTION_PSERIES(0x600, alignment) | |
506 | STD_EXCEPTION_PSERIES(0x700, program_check) | |
507 | STD_EXCEPTION_PSERIES(0x800, fp_unavailable) | |
508 | STD_EXCEPTION_PSERIES(0x900, decrementer) | |
509 | STD_EXCEPTION_PSERIES(0xa00, trap_0a) | |
510 | STD_EXCEPTION_PSERIES(0xb00, trap_0b) | |
511 | ||
512 | . = 0xc00 | |
513 | .globl system_call_pSeries | |
514 | system_call_pSeries: | |
515 | HMT_MEDIUM | |
14cf11af PM |
516 | mr r9,r13 |
517 | mfmsr r10 | |
b5bbeb23 PM |
518 | mfspr r13,SPRN_SPRG3 |
519 | mfspr r11,SPRN_SRR0 | |
14cf11af PM |
520 | clrrdi r12,r13,32 |
521 | oris r12,r12,system_call_common@h | |
522 | ori r12,r12,system_call_common@l | |
b5bbeb23 | 523 | mtspr SPRN_SRR0,r12 |
14cf11af | 524 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI |
b5bbeb23 PM |
525 | mfspr r12,SPRN_SRR1 |
526 | mtspr SPRN_SRR1,r10 | |
14cf11af PM |
527 | rfid |
528 | b . /* prevent speculative execution */ | |
529 | ||
530 | STD_EXCEPTION_PSERIES(0xd00, single_step) | |
531 | STD_EXCEPTION_PSERIES(0xe00, trap_0e) | |
532 | ||
533 | /* We need to deal with the Altivec unavailable exception | |
534 | * here which is at 0xf20, thus in the middle of the | |
535 | * prolog code of the PerformanceMonitor one. A little | |
536 | * trickery is thus necessary | |
537 | */ | |
538 | . = 0xf00 | |
539 | b performance_monitor_pSeries | |
540 | ||
541 | STD_EXCEPTION_PSERIES(0xf20, altivec_unavailable) | |
542 | ||
acf7d768 BH |
543 | #ifdef CONFIG_CBE_RAS |
544 | HSTD_EXCEPTION_PSERIES(0x1200, cbe_system_error) | |
545 | #endif /* CONFIG_CBE_RAS */ | |
14cf11af | 546 | STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint) |
acf7d768 BH |
547 | #ifdef CONFIG_CBE_RAS |
548 | HSTD_EXCEPTION_PSERIES(0x1600, cbe_maintenance) | |
549 | #endif /* CONFIG_CBE_RAS */ | |
14cf11af | 550 | STD_EXCEPTION_PSERIES(0x1700, altivec_assist) |
acf7d768 BH |
551 | #ifdef CONFIG_CBE_RAS |
552 | HSTD_EXCEPTION_PSERIES(0x1800, cbe_thermal) | |
553 | #endif /* CONFIG_CBE_RAS */ | |
14cf11af PM |
554 | |
555 | . = 0x3000 | |
556 | ||
557 | /*** pSeries interrupt support ***/ | |
558 | ||
559 | /* moved from 0xf00 */ | |
560 | STD_EXCEPTION_PSERIES(., performance_monitor) | |
561 | ||
562 | .align 7 | |
563 | _GLOBAL(do_stab_bolted_pSeries) | |
564 | mtcrf 0x80,r12 | |
b5bbeb23 | 565 | mfspr r12,SPRN_SPRG2 |
14cf11af PM |
566 | EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted) |
567 | ||
3c726f8d BH |
568 | /* |
569 | * We have some room here we use that to put | |
570 | * the peries slb miss user trampoline code so it's reasonably | |
571 | * away from slb_miss_user_common to avoid problems with rfid | |
572 | * | |
573 | * This is used for when the SLB miss handler has to go virtual, | |
574 | * which doesn't happen for now anymore but will once we re-implement | |
575 | * dynamic VSIDs for shared page tables | |
576 | */ | |
577 | #ifdef __DISABLED__ | |
578 | slb_miss_user_pseries: | |
579 | std r10,PACA_EXGEN+EX_R10(r13) | |
580 | std r11,PACA_EXGEN+EX_R11(r13) | |
581 | std r12,PACA_EXGEN+EX_R12(r13) | |
582 | mfspr r10,SPRG1 | |
583 | ld r11,PACA_EXSLB+EX_R9(r13) | |
584 | ld r12,PACA_EXSLB+EX_R3(r13) | |
585 | std r10,PACA_EXGEN+EX_R13(r13) | |
586 | std r11,PACA_EXGEN+EX_R9(r13) | |
587 | std r12,PACA_EXGEN+EX_R3(r13) | |
588 | clrrdi r12,r13,32 | |
589 | mfmsr r10 | |
590 | mfspr r11,SRR0 /* save SRR0 */ | |
591 | ori r12,r12,slb_miss_user_common@l /* virt addr of handler */ | |
592 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI | |
593 | mtspr SRR0,r12 | |
594 | mfspr r12,SRR1 /* and SRR1 */ | |
595 | mtspr SRR1,r10 | |
596 | rfid | |
597 | b . /* prevent spec. execution */ | |
598 | #endif /* __DISABLED__ */ | |
599 | ||
14cf11af PM |
600 | /* |
601 | * Vectors for the FWNMI option. Share common code. | |
602 | */ | |
b5bbeb23 | 603 | .globl system_reset_fwnmi |
8c4f1f29 | 604 | .align 7 |
14cf11af | 605 | system_reset_fwnmi: |
b5bbeb23 PM |
606 | HMT_MEDIUM |
607 | mtspr SPRN_SPRG1,r13 /* save r13 */ | |
b5bbeb23 | 608 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common) |
14cf11af | 609 | |
b5bbeb23 | 610 | .globl machine_check_fwnmi |
8c4f1f29 | 611 | .align 7 |
14cf11af | 612 | machine_check_fwnmi: |
b5bbeb23 PM |
613 | HMT_MEDIUM |
614 | mtspr SPRN_SPRG1,r13 /* save r13 */ | |
b5bbeb23 | 615 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common) |
14cf11af PM |
616 | |
617 | #ifdef CONFIG_PPC_ISERIES | |
618 | /*** ISeries-LPAR interrupt handlers ***/ | |
619 | ||
620 | STD_EXCEPTION_ISERIES(0x200, machine_check, PACA_EXMC) | |
621 | ||
622 | .globl data_access_iSeries | |
623 | data_access_iSeries: | |
b5bbeb23 | 624 | mtspr SPRN_SPRG1,r13 |
14cf11af | 625 | BEGIN_FTR_SECTION |
b5bbeb23 PM |
626 | mtspr SPRN_SPRG2,r12 |
627 | mfspr r13,SPRN_DAR | |
628 | mfspr r12,SPRN_DSISR | |
14cf11af PM |
629 | srdi r13,r13,60 |
630 | rlwimi r13,r12,16,0x20 | |
631 | mfcr r12 | |
632 | cmpwi r13,0x2c | |
633 | beq .do_stab_bolted_iSeries | |
634 | mtcrf 0x80,r12 | |
b5bbeb23 | 635 | mfspr r12,SPRN_SPRG2 |
14cf11af PM |
636 | END_FTR_SECTION_IFCLR(CPU_FTR_SLB) |
637 | EXCEPTION_PROLOG_ISERIES_1(PACA_EXGEN) | |
638 | EXCEPTION_PROLOG_ISERIES_2 | |
639 | b data_access_common | |
640 | ||
641 | .do_stab_bolted_iSeries: | |
642 | mtcrf 0x80,r12 | |
b5bbeb23 | 643 | mfspr r12,SPRN_SPRG2 |
14cf11af PM |
644 | EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB) |
645 | EXCEPTION_PROLOG_ISERIES_2 | |
646 | b .do_stab_bolted | |
647 | ||
648 | .globl data_access_slb_iSeries | |
649 | data_access_slb_iSeries: | |
b5bbeb23 | 650 | mtspr SPRN_SPRG1,r13 /* save r13 */ |
3c726f8d | 651 | mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ |
14cf11af | 652 | std r3,PACA_EXSLB+EX_R3(r13) |
b5bbeb23 | 653 | mfspr r3,SPRN_DAR |
3c726f8d BH |
654 | std r9,PACA_EXSLB+EX_R9(r13) |
655 | mfcr r9 | |
656 | #ifdef __DISABLED__ | |
657 | cmpdi r3,0 | |
658 | bge slb_miss_user_iseries | |
659 | #endif | |
660 | std r10,PACA_EXSLB+EX_R10(r13) | |
661 | std r11,PACA_EXSLB+EX_R11(r13) | |
662 | std r12,PACA_EXSLB+EX_R12(r13) | |
663 | mfspr r10,SPRN_SPRG1 | |
664 | std r10,PACA_EXSLB+EX_R13(r13) | |
3356bb9f DG |
665 | ld r12,PACALPPACAPTR(r13) |
666 | ld r12,LPPACASRR1(r12) | |
3c726f8d | 667 | b .slb_miss_realmode |
14cf11af PM |
668 | |
669 | STD_EXCEPTION_ISERIES(0x400, instruction_access, PACA_EXGEN) | |
670 | ||
671 | .globl instruction_access_slb_iSeries | |
672 | instruction_access_slb_iSeries: | |
b5bbeb23 | 673 | mtspr SPRN_SPRG1,r13 /* save r13 */ |
3c726f8d | 674 | mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ |
14cf11af | 675 | std r3,PACA_EXSLB+EX_R3(r13) |
3356bb9f DG |
676 | ld r3,PACALPPACAPTR(r13) |
677 | ld r3,LPPACASRR0(r3) /* get SRR0 value */ | |
3c726f8d BH |
678 | std r9,PACA_EXSLB+EX_R9(r13) |
679 | mfcr r9 | |
680 | #ifdef __DISABLED__ | |
681 | cmpdi r3,0 | |
682 | bge .slb_miss_user_iseries | |
683 | #endif | |
684 | std r10,PACA_EXSLB+EX_R10(r13) | |
685 | std r11,PACA_EXSLB+EX_R11(r13) | |
686 | std r12,PACA_EXSLB+EX_R12(r13) | |
687 | mfspr r10,SPRN_SPRG1 | |
688 | std r10,PACA_EXSLB+EX_R13(r13) | |
3356bb9f DG |
689 | ld r12,PACALPPACAPTR(r13) |
690 | ld r12,LPPACASRR1(r12) | |
3c726f8d BH |
691 | b .slb_miss_realmode |
692 | ||
693 | #ifdef __DISABLED__ | |
694 | slb_miss_user_iseries: | |
695 | std r10,PACA_EXGEN+EX_R10(r13) | |
696 | std r11,PACA_EXGEN+EX_R11(r13) | |
697 | std r12,PACA_EXGEN+EX_R12(r13) | |
698 | mfspr r10,SPRG1 | |
699 | ld r11,PACA_EXSLB+EX_R9(r13) | |
700 | ld r12,PACA_EXSLB+EX_R3(r13) | |
701 | std r10,PACA_EXGEN+EX_R13(r13) | |
702 | std r11,PACA_EXGEN+EX_R9(r13) | |
703 | std r12,PACA_EXGEN+EX_R3(r13) | |
704 | EXCEPTION_PROLOG_ISERIES_2 | |
705 | b slb_miss_user_common | |
706 | #endif | |
14cf11af PM |
707 | |
708 | MASKABLE_EXCEPTION_ISERIES(0x500, hardware_interrupt) | |
709 | STD_EXCEPTION_ISERIES(0x600, alignment, PACA_EXGEN) | |
710 | STD_EXCEPTION_ISERIES(0x700, program_check, PACA_EXGEN) | |
711 | STD_EXCEPTION_ISERIES(0x800, fp_unavailable, PACA_EXGEN) | |
712 | MASKABLE_EXCEPTION_ISERIES(0x900, decrementer) | |
713 | STD_EXCEPTION_ISERIES(0xa00, trap_0a, PACA_EXGEN) | |
714 | STD_EXCEPTION_ISERIES(0xb00, trap_0b, PACA_EXGEN) | |
715 | ||
716 | .globl system_call_iSeries | |
717 | system_call_iSeries: | |
718 | mr r9,r13 | |
b5bbeb23 | 719 | mfspr r13,SPRN_SPRG3 |
14cf11af PM |
720 | EXCEPTION_PROLOG_ISERIES_2 |
721 | b system_call_common | |
722 | ||
723 | STD_EXCEPTION_ISERIES( 0xd00, single_step, PACA_EXGEN) | |
724 | STD_EXCEPTION_ISERIES( 0xe00, trap_0e, PACA_EXGEN) | |
725 | STD_EXCEPTION_ISERIES( 0xf00, performance_monitor, PACA_EXGEN) | |
726 | ||
727 | .globl system_reset_iSeries | |
728 | system_reset_iSeries: | |
b5bbeb23 | 729 | mfspr r13,SPRN_SPRG3 /* Get paca address */ |
14cf11af PM |
730 | mfmsr r24 |
731 | ori r24,r24,MSR_RI | |
732 | mtmsrd r24 /* RI on */ | |
733 | lhz r24,PACAPACAINDEX(r13) /* Get processor # */ | |
734 | cmpwi 0,r24,0 /* Are we processor 0? */ | |
735 | beq .__start_initialization_iSeries /* Start up the first processor */ | |
736 | mfspr r4,SPRN_CTRLF | |
737 | li r5,CTRL_RUNLATCH /* Turn off the run light */ | |
738 | andc r4,r4,r5 | |
739 | mtspr SPRN_CTRLT,r4 | |
740 | ||
741 | 1: | |
742 | HMT_LOW | |
743 | #ifdef CONFIG_SMP | |
744 | lbz r23,PACAPROCSTART(r13) /* Test if this processor | |
745 | * should start */ | |
746 | sync | |
e58c3495 | 747 | LOAD_REG_IMMEDIATE(r3,current_set) |
14cf11af PM |
748 | sldi r28,r24,3 /* get current_set[cpu#] */ |
749 | ldx r3,r3,r28 | |
750 | addi r1,r3,THREAD_SIZE | |
751 | subi r1,r1,STACK_FRAME_OVERHEAD | |
752 | ||
753 | cmpwi 0,r23,0 | |
754 | beq iSeries_secondary_smp_loop /* Loop until told to go */ | |
755 | bne .__secondary_start /* Loop until told to go */ | |
756 | iSeries_secondary_smp_loop: | |
757 | /* Let the Hypervisor know we are alive */ | |
758 | /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */ | |
759 | lis r3,0x8002 | |
760 | rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */ | |
761 | #else /* CONFIG_SMP */ | |
762 | /* Yield the processor. This is required for non-SMP kernels | |
763 | which are running on multi-threaded machines. */ | |
764 | lis r3,0x8000 | |
765 | rldicr r3,r3,32,15 /* r3 = (r3 << 32) & 0xffff000000000000 */ | |
766 | addi r3,r3,18 /* r3 = 0x8000000000000012 which is "yield" */ | |
767 | li r4,0 /* "yield timed" */ | |
768 | li r5,-1 /* "yield forever" */ | |
769 | #endif /* CONFIG_SMP */ | |
770 | li r0,-1 /* r0=-1 indicates a Hypervisor call */ | |
771 | sc /* Invoke the hypervisor via a system call */ | |
b5bbeb23 | 772 | mfspr r13,SPRN_SPRG3 /* Put r13 back ???? */ |
14cf11af PM |
773 | b 1b /* If SMP not configured, secondaries |
774 | * loop forever */ | |
775 | ||
776 | .globl decrementer_iSeries_masked | |
777 | decrementer_iSeries_masked: | |
f9b4045d | 778 | /* We may not have a valid TOC pointer in here. */ |
14cf11af | 779 | li r11,1 |
3356bb9f DG |
780 | ld r12,PACALPPACAPTR(r13) |
781 | stb r11,LPPACADECRINT(r12) | |
f9b4045d ME |
782 | LOAD_REG_IMMEDIATE(r12, tb_ticks_per_jiffy) |
783 | lwz r12,0(r12) | |
14cf11af PM |
784 | mtspr SPRN_DEC,r12 |
785 | /* fall through */ | |
786 | ||
787 | .globl hardware_interrupt_iSeries_masked | |
788 | hardware_interrupt_iSeries_masked: | |
789 | mtcrf 0x80,r9 /* Restore regs */ | |
3356bb9f DG |
790 | ld r12,PACALPPACAPTR(r13) |
791 | ld r11,LPPACASRR0(r12) | |
792 | ld r12,LPPACASRR1(r12) | |
b5bbeb23 PM |
793 | mtspr SPRN_SRR0,r11 |
794 | mtspr SPRN_SRR1,r12 | |
14cf11af PM |
795 | ld r9,PACA_EXGEN+EX_R9(r13) |
796 | ld r10,PACA_EXGEN+EX_R10(r13) | |
797 | ld r11,PACA_EXGEN+EX_R11(r13) | |
798 | ld r12,PACA_EXGEN+EX_R12(r13) | |
799 | ld r13,PACA_EXGEN+EX_R13(r13) | |
800 | rfid | |
801 | b . /* prevent speculative execution */ | |
802 | #endif /* CONFIG_PPC_ISERIES */ | |
803 | ||
804 | /*** Common interrupt handlers ***/ | |
805 | ||
806 | STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception) | |
807 | ||
808 | /* | |
809 | * Machine check is different because we use a different | |
810 | * save area: PACA_EXMC instead of PACA_EXGEN. | |
811 | */ | |
812 | .align 7 | |
813 | .globl machine_check_common | |
814 | machine_check_common: | |
815 | EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) | |
f39224a8 | 816 | FINISH_NAP |
14cf11af PM |
817 | DISABLE_INTS |
818 | bl .save_nvgprs | |
819 | addi r3,r1,STACK_FRAME_OVERHEAD | |
820 | bl .machine_check_exception | |
821 | b .ret_from_except | |
822 | ||
823 | STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt) | |
824 | STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception) | |
825 | STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) | |
826 | STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) | |
827 | STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) | |
f39224a8 | 828 | STD_EXCEPTION_COMMON_IDLE(0xf00, performance_monitor, .performance_monitor_exception) |
14cf11af PM |
829 | STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) |
830 | #ifdef CONFIG_ALTIVEC | |
831 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception) | |
832 | #else | |
833 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception) | |
834 | #endif | |
acf7d768 BH |
835 | #ifdef CONFIG_CBE_RAS |
836 | STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception) | |
837 | STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception) | |
838 | STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) | |
839 | #endif /* CONFIG_CBE_RAS */ | |
14cf11af PM |
840 | |
841 | /* | |
842 | * Here we have detected that the kernel stack pointer is bad. | |
843 | * R9 contains the saved CR, r13 points to the paca, | |
844 | * r10 contains the (bad) kernel stack pointer, | |
845 | * r11 and r12 contain the saved SRR0 and SRR1. | |
846 | * We switch to using an emergency stack, save the registers there, | |
847 | * and call kernel_bad_stack(), which panics. | |
848 | */ | |
849 | bad_stack: | |
850 | ld r1,PACAEMERGSP(r13) | |
851 | subi r1,r1,64+INT_FRAME_SIZE | |
852 | std r9,_CCR(r1) | |
853 | std r10,GPR1(r1) | |
854 | std r11,_NIP(r1) | |
855 | std r12,_MSR(r1) | |
b5bbeb23 PM |
856 | mfspr r11,SPRN_DAR |
857 | mfspr r12,SPRN_DSISR | |
14cf11af PM |
858 | std r11,_DAR(r1) |
859 | std r12,_DSISR(r1) | |
860 | mflr r10 | |
861 | mfctr r11 | |
862 | mfxer r12 | |
863 | std r10,_LINK(r1) | |
864 | std r11,_CTR(r1) | |
865 | std r12,_XER(r1) | |
866 | SAVE_GPR(0,r1) | |
867 | SAVE_GPR(2,r1) | |
868 | SAVE_4GPRS(3,r1) | |
869 | SAVE_2GPRS(7,r1) | |
870 | SAVE_10GPRS(12,r1) | |
871 | SAVE_10GPRS(22,r1) | |
872 | addi r11,r1,INT_FRAME_SIZE | |
873 | std r11,0(r1) | |
874 | li r12,0 | |
875 | std r12,0(r11) | |
876 | ld r2,PACATOC(r13) | |
877 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
878 | bl .kernel_bad_stack | |
879 | b 1b | |
880 | ||
881 | /* | |
882 | * Return from an exception with minimal checks. | |
883 | * The caller is assumed to have done EXCEPTION_PROLOG_COMMON. | |
884 | * If interrupts have been enabled, or anything has been | |
885 | * done that might have changed the scheduling status of | |
886 | * any task or sent any task a signal, you should use | |
887 | * ret_from_except or ret_from_except_lite instead of this. | |
888 | */ | |
40ef8cbc | 889 | .globl fast_exception_return |
14cf11af PM |
890 | fast_exception_return: |
891 | ld r12,_MSR(r1) | |
892 | ld r11,_NIP(r1) | |
893 | andi. r3,r12,MSR_RI /* check if RI is set */ | |
894 | beq- unrecov_fer | |
c6622f63 PM |
895 | |
896 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | |
897 | andi. r3,r12,MSR_PR | |
898 | beq 2f | |
899 | ACCOUNT_CPU_USER_EXIT(r3, r4) | |
900 | 2: | |
901 | #endif | |
902 | ||
14cf11af PM |
903 | ld r3,_CCR(r1) |
904 | ld r4,_LINK(r1) | |
905 | ld r5,_CTR(r1) | |
906 | ld r6,_XER(r1) | |
907 | mtcr r3 | |
908 | mtlr r4 | |
909 | mtctr r5 | |
910 | mtxer r6 | |
911 | REST_GPR(0, r1) | |
912 | REST_8GPRS(2, r1) | |
913 | ||
914 | mfmsr r10 | |
915 | clrrdi r10,r10,2 /* clear RI (LE is 0 already) */ | |
916 | mtmsrd r10,1 | |
917 | ||
b5bbeb23 PM |
918 | mtspr SPRN_SRR1,r12 |
919 | mtspr SPRN_SRR0,r11 | |
14cf11af PM |
920 | REST_4GPRS(10, r1) |
921 | ld r1,GPR1(r1) | |
922 | rfid | |
923 | b . /* prevent speculative execution */ | |
924 | ||
925 | unrecov_fer: | |
926 | bl .save_nvgprs | |
927 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
928 | bl .unrecoverable_exception | |
929 | b 1b | |
930 | ||
931 | /* | |
932 | * Here r13 points to the paca, r9 contains the saved CR, | |
933 | * SRR0 and SRR1 are saved in r11 and r12, | |
934 | * r9 - r13 are saved in paca->exgen. | |
935 | */ | |
936 | .align 7 | |
937 | .globl data_access_common | |
938 | data_access_common: | |
b5bbeb23 | 939 | mfspr r10,SPRN_DAR |
14cf11af | 940 | std r10,PACA_EXGEN+EX_DAR(r13) |
b5bbeb23 | 941 | mfspr r10,SPRN_DSISR |
14cf11af PM |
942 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
943 | EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) | |
944 | ld r3,PACA_EXGEN+EX_DAR(r13) | |
945 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
946 | li r5,0x300 | |
947 | b .do_hash_page /* Try to handle as hpte fault */ | |
948 | ||
949 | .align 7 | |
950 | .globl instruction_access_common | |
951 | instruction_access_common: | |
952 | EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN) | |
953 | ld r3,_NIP(r1) | |
954 | andis. r4,r12,0x5820 | |
955 | li r5,0x400 | |
956 | b .do_hash_page /* Try to handle as hpte fault */ | |
957 | ||
3c726f8d BH |
958 | /* |
959 | * Here is the common SLB miss user that is used when going to virtual | |
960 | * mode for SLB misses, that is currently not used | |
961 | */ | |
962 | #ifdef __DISABLED__ | |
963 | .align 7 | |
964 | .globl slb_miss_user_common | |
965 | slb_miss_user_common: | |
966 | mflr r10 | |
967 | std r3,PACA_EXGEN+EX_DAR(r13) | |
968 | stw r9,PACA_EXGEN+EX_CCR(r13) | |
969 | std r10,PACA_EXGEN+EX_LR(r13) | |
970 | std r11,PACA_EXGEN+EX_SRR0(r13) | |
971 | bl .slb_allocate_user | |
972 | ||
973 | ld r10,PACA_EXGEN+EX_LR(r13) | |
974 | ld r3,PACA_EXGEN+EX_R3(r13) | |
975 | lwz r9,PACA_EXGEN+EX_CCR(r13) | |
976 | ld r11,PACA_EXGEN+EX_SRR0(r13) | |
977 | mtlr r10 | |
978 | beq- slb_miss_fault | |
979 | ||
980 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ | |
981 | beq- unrecov_user_slb | |
982 | mfmsr r10 | |
983 | ||
984 | .machine push | |
985 | .machine "power4" | |
986 | mtcrf 0x80,r9 | |
987 | .machine pop | |
988 | ||
989 | clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */ | |
990 | mtmsrd r10,1 | |
991 | ||
992 | mtspr SRR0,r11 | |
993 | mtspr SRR1,r12 | |
994 | ||
995 | ld r9,PACA_EXGEN+EX_R9(r13) | |
996 | ld r10,PACA_EXGEN+EX_R10(r13) | |
997 | ld r11,PACA_EXGEN+EX_R11(r13) | |
998 | ld r12,PACA_EXGEN+EX_R12(r13) | |
999 | ld r13,PACA_EXGEN+EX_R13(r13) | |
1000 | rfid | |
1001 | b . | |
1002 | ||
1003 | slb_miss_fault: | |
1004 | EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN) | |
1005 | ld r4,PACA_EXGEN+EX_DAR(r13) | |
1006 | li r5,0 | |
1007 | std r4,_DAR(r1) | |
1008 | std r5,_DSISR(r1) | |
1009 | b .handle_page_fault | |
1010 | ||
1011 | unrecov_user_slb: | |
1012 | EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) | |
1013 | DISABLE_INTS | |
1014 | bl .save_nvgprs | |
1015 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
1016 | bl .unrecoverable_exception | |
1017 | b 1b | |
1018 | ||
1019 | #endif /* __DISABLED__ */ | |
1020 | ||
1021 | ||
1022 | /* | |
1023 | * r13 points to the PACA, r9 contains the saved CR, | |
1024 | * r12 contain the saved SRR1, SRR0 is still ready for return | |
1025 | * r3 has the faulting address | |
1026 | * r9 - r13 are saved in paca->exslb. | |
1027 | * r3 is saved in paca->slb_r3 | |
1028 | * We assume we aren't going to take any exceptions during this procedure. | |
1029 | */ | |
1030 | _GLOBAL(slb_miss_realmode) | |
1031 | mflr r10 | |
1032 | ||
1033 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ | |
1034 | std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ | |
1035 | ||
1036 | bl .slb_allocate_realmode | |
1037 | ||
1038 | /* All done -- return from exception. */ | |
1039 | ||
1040 | ld r10,PACA_EXSLB+EX_LR(r13) | |
1041 | ld r3,PACA_EXSLB+EX_R3(r13) | |
1042 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ | |
1043 | #ifdef CONFIG_PPC_ISERIES | |
3356bb9f DG |
1044 | ld r11,PACALPPACAPTR(r13) |
1045 | ld r11,LPPACASRR0(r11) /* get SRR0 value */ | |
3c726f8d BH |
1046 | #endif /* CONFIG_PPC_ISERIES */ |
1047 | ||
1048 | mtlr r10 | |
1049 | ||
1050 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ | |
1051 | beq- unrecov_slb | |
1052 | ||
1053 | .machine push | |
1054 | .machine "power4" | |
1055 | mtcrf 0x80,r9 | |
1056 | mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ | |
1057 | .machine pop | |
1058 | ||
1059 | #ifdef CONFIG_PPC_ISERIES | |
1060 | mtspr SPRN_SRR0,r11 | |
1061 | mtspr SPRN_SRR1,r12 | |
1062 | #endif /* CONFIG_PPC_ISERIES */ | |
1063 | ld r9,PACA_EXSLB+EX_R9(r13) | |
1064 | ld r10,PACA_EXSLB+EX_R10(r13) | |
1065 | ld r11,PACA_EXSLB+EX_R11(r13) | |
1066 | ld r12,PACA_EXSLB+EX_R12(r13) | |
1067 | ld r13,PACA_EXSLB+EX_R13(r13) | |
1068 | rfid | |
1069 | b . /* prevent speculative execution */ | |
1070 | ||
1071 | unrecov_slb: | |
1072 | EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB) | |
1073 | DISABLE_INTS | |
1074 | bl .save_nvgprs | |
1075 | 1: addi r3,r1,STACK_FRAME_OVERHEAD | |
1076 | bl .unrecoverable_exception | |
1077 | b 1b | |
1078 | ||
14cf11af PM |
1079 | .align 7 |
1080 | .globl hardware_interrupt_common | |
1081 | .globl hardware_interrupt_entry | |
1082 | hardware_interrupt_common: | |
1083 | EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN) | |
f39224a8 | 1084 | FINISH_NAP |
14cf11af PM |
1085 | hardware_interrupt_entry: |
1086 | DISABLE_INTS | |
cb2c9b27 | 1087 | bl .ppc64_runlatch_on |
14cf11af PM |
1088 | addi r3,r1,STACK_FRAME_OVERHEAD |
1089 | bl .do_IRQ | |
1090 | b .ret_from_except_lite | |
1091 | ||
f39224a8 PM |
1092 | #ifdef CONFIG_PPC_970_NAP |
1093 | power4_fixup_nap: | |
1094 | andc r9,r9,r10 | |
1095 | std r9,TI_LOCAL_FLAGS(r11) | |
1096 | ld r10,_LINK(r1) /* make idle task do the */ | |
1097 | std r10,_NIP(r1) /* equivalent of a blr */ | |
1098 | blr | |
1099 | #endif | |
1100 | ||
14cf11af PM |
1101 | .align 7 |
1102 | .globl alignment_common | |
1103 | alignment_common: | |
b5bbeb23 | 1104 | mfspr r10,SPRN_DAR |
14cf11af | 1105 | std r10,PACA_EXGEN+EX_DAR(r13) |
b5bbeb23 | 1106 | mfspr r10,SPRN_DSISR |
14cf11af PM |
1107 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
1108 | EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) | |
1109 | ld r3,PACA_EXGEN+EX_DAR(r13) | |
1110 | lwz r4,PACA_EXGEN+EX_DSISR(r13) | |
1111 | std r3,_DAR(r1) | |
1112 | std r4,_DSISR(r1) | |
1113 | bl .save_nvgprs | |
1114 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1115 | ENABLE_INTS | |
1116 | bl .alignment_exception | |
1117 | b .ret_from_except | |
1118 | ||
1119 | .align 7 | |
1120 | .globl program_check_common | |
1121 | program_check_common: | |
1122 | EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) | |
1123 | bl .save_nvgprs | |
1124 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1125 | ENABLE_INTS | |
1126 | bl .program_check_exception | |
1127 | b .ret_from_except | |
1128 | ||
1129 | .align 7 | |
1130 | .globl fp_unavailable_common | |
1131 | fp_unavailable_common: | |
1132 | EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) | |
1133 | bne .load_up_fpu /* if from user, just load it up */ | |
1134 | bl .save_nvgprs | |
1135 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1136 | ENABLE_INTS | |
1137 | bl .kernel_fp_unavailable_exception | |
1138 | BUG_OPCODE | |
1139 | ||
14cf11af PM |
1140 | .align 7 |
1141 | .globl altivec_unavailable_common | |
1142 | altivec_unavailable_common: | |
1143 | EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN) | |
1144 | #ifdef CONFIG_ALTIVEC | |
1145 | BEGIN_FTR_SECTION | |
1146 | bne .load_up_altivec /* if from user, just load it up */ | |
1147 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) | |
1148 | #endif | |
1149 | bl .save_nvgprs | |
1150 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1151 | ENABLE_INTS | |
1152 | bl .altivec_unavailable_exception | |
1153 | b .ret_from_except | |
1154 | ||
1155 | #ifdef CONFIG_ALTIVEC | |
1156 | /* | |
1157 | * load_up_altivec(unused, unused, tsk) | |
1158 | * Disable VMX for the task which had it previously, | |
1159 | * and save its vector registers in its thread_struct. | |
1160 | * Enables the VMX for use in the kernel on return. | |
1161 | * On SMP we know the VMX is free, since we give it up every | |
1162 | * switch (ie, no lazy save of the vector registers). | |
1163 | * On entry: r13 == 'current' && last_task_used_altivec != 'current' | |
1164 | */ | |
1165 | _STATIC(load_up_altivec) | |
1166 | mfmsr r5 /* grab the current MSR */ | |
1167 | oris r5,r5,MSR_VEC@h | |
1168 | mtmsrd r5 /* enable use of VMX now */ | |
1169 | isync | |
1170 | ||
1171 | /* | |
1172 | * For SMP, we don't do lazy VMX switching because it just gets too | |
1173 | * horrendously complex, especially when a task switches from one CPU | |
1174 | * to another. Instead we call giveup_altvec in switch_to. | |
1175 | * VRSAVE isn't dealt with here, that is done in the normal context | |
1176 | * switch code. Note that we could rely on vrsave value to eventually | |
1177 | * avoid saving all of the VREGs here... | |
1178 | */ | |
1179 | #ifndef CONFIG_SMP | |
1180 | ld r3,last_task_used_altivec@got(r2) | |
1181 | ld r4,0(r3) | |
1182 | cmpdi 0,r4,0 | |
1183 | beq 1f | |
1184 | /* Save VMX state to last_task_used_altivec's THREAD struct */ | |
1185 | addi r4,r4,THREAD | |
1186 | SAVE_32VRS(0,r5,r4) | |
1187 | mfvscr vr0 | |
1188 | li r10,THREAD_VSCR | |
1189 | stvx vr0,r10,r4 | |
1190 | /* Disable VMX for last_task_used_altivec */ | |
1191 | ld r5,PT_REGS(r4) | |
1192 | ld r4,_MSR-STACK_FRAME_OVERHEAD(r5) | |
1193 | lis r6,MSR_VEC@h | |
1194 | andc r4,r4,r6 | |
1195 | std r4,_MSR-STACK_FRAME_OVERHEAD(r5) | |
1196 | 1: | |
1197 | #endif /* CONFIG_SMP */ | |
1198 | /* Hack: if we get an altivec unavailable trap with VRSAVE | |
1199 | * set to all zeros, we assume this is a broken application | |
1200 | * that fails to set it properly, and thus we switch it to | |
1201 | * all 1's | |
1202 | */ | |
1203 | mfspr r4,SPRN_VRSAVE | |
1204 | cmpdi 0,r4,0 | |
1205 | bne+ 1f | |
1206 | li r4,-1 | |
1207 | mtspr SPRN_VRSAVE,r4 | |
1208 | 1: | |
1209 | /* enable use of VMX after return */ | |
1210 | ld r4,PACACURRENT(r13) | |
1211 | addi r5,r4,THREAD /* Get THREAD */ | |
1212 | oris r12,r12,MSR_VEC@h | |
1213 | std r12,_MSR(r1) | |
1214 | li r4,1 | |
1215 | li r10,THREAD_VSCR | |
1216 | stw r4,THREAD_USED_VR(r5) | |
1217 | lvx vr0,r10,r5 | |
1218 | mtvscr vr0 | |
1219 | REST_32VRS(0,r4,r5) | |
1220 | #ifndef CONFIG_SMP | |
1221 | /* Update last_task_used_math to 'current' */ | |
1222 | subi r4,r5,THREAD /* Back to 'current' */ | |
1223 | std r4,0(r3) | |
1224 | #endif /* CONFIG_SMP */ | |
1225 | /* restore registers and return */ | |
1226 | b fast_exception_return | |
1227 | #endif /* CONFIG_ALTIVEC */ | |
1228 | ||
1229 | /* | |
1230 | * Hash table stuff | |
1231 | */ | |
1232 | .align 7 | |
1233 | _GLOBAL(do_hash_page) | |
1234 | std r3,_DAR(r1) | |
1235 | std r4,_DSISR(r1) | |
1236 | ||
1237 | andis. r0,r4,0xa450 /* weird error? */ | |
1238 | bne- .handle_page_fault /* if not, try to insert a HPTE */ | |
1239 | BEGIN_FTR_SECTION | |
1240 | andis. r0,r4,0x0020 /* Is it a segment table fault? */ | |
1241 | bne- .do_ste_alloc /* If so handle it */ | |
1242 | END_FTR_SECTION_IFCLR(CPU_FTR_SLB) | |
1243 | ||
1244 | /* | |
1245 | * We need to set the _PAGE_USER bit if MSR_PR is set or if we are | |
1246 | * accessing a userspace segment (even from the kernel). We assume | |
1247 | * kernel addresses always have the high bit set. | |
1248 | */ | |
1249 | rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */ | |
1250 | rotldi r0,r3,15 /* Move high bit into MSR_PR posn */ | |
1251 | orc r0,r12,r0 /* MSR_PR | ~high_bit */ | |
1252 | rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */ | |
1253 | ori r4,r4,1 /* add _PAGE_PRESENT */ | |
1254 | rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */ | |
1255 | ||
1256 | /* | |
1257 | * On iSeries, we soft-disable interrupts here, then | |
1258 | * hard-enable interrupts so that the hash_page code can spin on | |
1259 | * the hash_table_lock without problems on a shared processor. | |
1260 | */ | |
1261 | DISABLE_INTS | |
1262 | ||
1263 | /* | |
1264 | * r3 contains the faulting address | |
1265 | * r4 contains the required access permissions | |
1266 | * r5 contains the trap number | |
1267 | * | |
1268 | * at return r3 = 0 for success | |
1269 | */ | |
1270 | bl .hash_page /* build HPTE if possible */ | |
1271 | cmpdi r3,0 /* see if hash_page succeeded */ | |
1272 | ||
1273 | #ifdef DO_SOFT_DISABLE | |
1274 | /* | |
1275 | * If we had interrupts soft-enabled at the point where the | |
1276 | * DSI/ISI occurred, and an interrupt came in during hash_page, | |
1277 | * handle it now. | |
1278 | * We jump to ret_from_except_lite rather than fast_exception_return | |
1279 | * because ret_from_except_lite will check for and handle pending | |
1280 | * interrupts if necessary. | |
1281 | */ | |
1282 | beq .ret_from_except_lite | |
1283 | /* For a hash failure, we don't bother re-enabling interrupts */ | |
1284 | ble- 12f | |
1285 | ||
1286 | /* | |
1287 | * hash_page couldn't handle it, set soft interrupt enable back | |
1288 | * to what it was before the trap. Note that .local_irq_restore | |
1289 | * handles any interrupts pending at this point. | |
1290 | */ | |
1291 | ld r3,SOFTE(r1) | |
1292 | bl .local_irq_restore | |
1293 | b 11f | |
1294 | #else | |
1295 | beq fast_exception_return /* Return from exception on success */ | |
1296 | ble- 12f /* Failure return from hash_page */ | |
1297 | ||
1298 | /* fall through */ | |
1299 | #endif | |
1300 | ||
1301 | /* Here we have a page fault that hash_page can't handle. */ | |
1302 | _GLOBAL(handle_page_fault) | |
1303 | ENABLE_INTS | |
1304 | 11: ld r4,_DAR(r1) | |
1305 | ld r5,_DSISR(r1) | |
1306 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1307 | bl .do_page_fault | |
1308 | cmpdi r3,0 | |
1309 | beq+ .ret_from_except_lite | |
1310 | bl .save_nvgprs | |
1311 | mr r5,r3 | |
1312 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1313 | lwz r4,_DAR(r1) | |
1314 | bl .bad_page_fault | |
1315 | b .ret_from_except | |
1316 | ||
1317 | /* We have a page fault that hash_page could handle but HV refused | |
1318 | * the PTE insertion | |
1319 | */ | |
1320 | 12: bl .save_nvgprs | |
1321 | addi r3,r1,STACK_FRAME_OVERHEAD | |
1322 | lwz r4,_DAR(r1) | |
1323 | bl .low_hash_fault | |
1324 | b .ret_from_except | |
1325 | ||
1326 | /* here we have a segment miss */ | |
1327 | _GLOBAL(do_ste_alloc) | |
1328 | bl .ste_allocate /* try to insert stab entry */ | |
1329 | cmpdi r3,0 | |
1330 | beq+ fast_exception_return | |
1331 | b .handle_page_fault | |
1332 | ||
1333 | /* | |
1334 | * r13 points to the PACA, r9 contains the saved CR, | |
1335 | * r11 and r12 contain the saved SRR0 and SRR1. | |
1336 | * r9 - r13 are saved in paca->exslb. | |
1337 | * We assume we aren't going to take any exceptions during this procedure. | |
1338 | * We assume (DAR >> 60) == 0xc. | |
1339 | */ | |
1340 | .align 7 | |
1341 | _GLOBAL(do_stab_bolted) | |
1342 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ | |
1343 | std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */ | |
1344 | ||
1345 | /* Hash to the primary group */ | |
1346 | ld r10,PACASTABVIRT(r13) | |
b5bbeb23 | 1347 | mfspr r11,SPRN_DAR |
14cf11af PM |
1348 | srdi r11,r11,28 |
1349 | rldimi r10,r11,7,52 /* r10 = first ste of the group */ | |
1350 | ||
1351 | /* Calculate VSID */ | |
1352 | /* This is a kernel address, so protovsid = ESID */ | |
1353 | ASM_VSID_SCRAMBLE(r11, r9) | |
1354 | rldic r9,r11,12,16 /* r9 = vsid << 12 */ | |
1355 | ||
1356 | /* Search the primary group for a free entry */ | |
1357 | 1: ld r11,0(r10) /* Test valid bit of the current ste */ | |
1358 | andi. r11,r11,0x80 | |
1359 | beq 2f | |
1360 | addi r10,r10,16 | |
1361 | andi. r11,r10,0x70 | |
1362 | bne 1b | |
1363 | ||
1364 | /* Stick for only searching the primary group for now. */ | |
1365 | /* At least for now, we use a very simple random castout scheme */ | |
1366 | /* Use the TB as a random number ; OR in 1 to avoid entry 0 */ | |
1367 | mftb r11 | |
1368 | rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */ | |
1369 | ori r11,r11,0x10 | |
1370 | ||
1371 | /* r10 currently points to an ste one past the group of interest */ | |
1372 | /* make it point to the randomly selected entry */ | |
1373 | subi r10,r10,128 | |
1374 | or r10,r10,r11 /* r10 is the entry to invalidate */ | |
1375 | ||
1376 | isync /* mark the entry invalid */ | |
1377 | ld r11,0(r10) | |
1378 | rldicl r11,r11,56,1 /* clear the valid bit */ | |
1379 | rotldi r11,r11,8 | |
1380 | std r11,0(r10) | |
1381 | sync | |
1382 | ||
1383 | clrrdi r11,r11,28 /* Get the esid part of the ste */ | |
1384 | slbie r11 | |
1385 | ||
1386 | 2: std r9,8(r10) /* Store the vsid part of the ste */ | |
1387 | eieio | |
1388 | ||
b5bbeb23 | 1389 | mfspr r11,SPRN_DAR /* Get the new esid */ |
14cf11af PM |
1390 | clrrdi r11,r11,28 /* Permits a full 32b of ESID */ |
1391 | ori r11,r11,0x90 /* Turn on valid and kp */ | |
1392 | std r11,0(r10) /* Put new entry back into the stab */ | |
1393 | ||
1394 | sync | |
1395 | ||
1396 | /* All done -- return from exception. */ | |
1397 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ | |
1398 | ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */ | |
1399 | ||
1400 | andi. r10,r12,MSR_RI | |
1401 | beq- unrecov_slb | |
1402 | ||
1403 | mtcrf 0x80,r9 /* restore CR */ | |
1404 | ||
1405 | mfmsr r10 | |
1406 | clrrdi r10,r10,2 | |
1407 | mtmsrd r10,1 | |
1408 | ||
b5bbeb23 PM |
1409 | mtspr SPRN_SRR0,r11 |
1410 | mtspr SPRN_SRR1,r12 | |
14cf11af PM |
1411 | ld r9,PACA_EXSLB+EX_R9(r13) |
1412 | ld r10,PACA_EXSLB+EX_R10(r13) | |
1413 | ld r11,PACA_EXSLB+EX_R11(r13) | |
1414 | ld r12,PACA_EXSLB+EX_R12(r13) | |
1415 | ld r13,PACA_EXSLB+EX_R13(r13) | |
1416 | rfid | |
1417 | b . /* prevent speculative execution */ | |
1418 | ||
14cf11af PM |
1419 | /* |
1420 | * Space for CPU0's segment table. | |
1421 | * | |
1422 | * On iSeries, the hypervisor must fill in at least one entry before | |
1423 | * we get control (with relocate on). The address is give to the hv | |
ee400b63 | 1424 | * as a page number (see xLparMap in lpardata.c), so this must be at a |
14cf11af PM |
1425 | * fixed address (the linker can't compute (u64)&initial_stab >> |
1426 | * PAGE_SHIFT). | |
1427 | */ | |
758438a7 | 1428 | . = STAB0_OFFSET /* 0x6000 */ |
14cf11af PM |
1429 | .globl initial_stab |
1430 | initial_stab: | |
1431 | .space 4096 | |
1432 | ||
1433 | /* | |
1434 | * Data area reserved for FWNMI option. | |
1435 | * This address (0x7000) is fixed by the RPA. | |
1436 | */ | |
1437 | .= 0x7000 | |
1438 | .globl fwnmi_data_area | |
1439 | fwnmi_data_area: | |
1440 | ||
1441 | /* iSeries does not use the FWNMI stuff, so it is safe to put | |
1442 | * this here, even if we later allow kernels that will boot on | |
1443 | * both pSeries and iSeries */ | |
1444 | #ifdef CONFIG_PPC_ISERIES | |
1445 | . = LPARMAP_PHYS | |
1446 | #include "lparmap.s" | |
1447 | /* | |
1448 | * This ".text" is here for old compilers that generate a trailing | |
1449 | * .note section when compiling .c files to .s | |
1450 | */ | |
1451 | .text | |
1452 | #endif /* CONFIG_PPC_ISERIES */ | |
1453 | ||
1454 | . = 0x8000 | |
1455 | ||
1456 | /* | |
1457 | * On pSeries, secondary processors spin in the following code. | |
1458 | * At entry, r3 = this processor's number (physical cpu id) | |
1459 | */ | |
1460 | _GLOBAL(pSeries_secondary_smp_init) | |
1461 | mr r24,r3 | |
1462 | ||
1463 | /* turn on 64-bit mode */ | |
1464 | bl .enable_64b_mode | |
1465 | isync | |
1466 | ||
1467 | /* Copy some CPU settings from CPU 0 */ | |
1468 | bl .__restore_cpu_setup | |
1469 | ||
1470 | /* Set up a paca value for this processor. Since we have the | |
1471 | * physical cpu id in r24, we need to search the pacas to find | |
1472 | * which logical id maps to our physical one. | |
1473 | */ | |
e58c3495 | 1474 | LOAD_REG_IMMEDIATE(r13, paca) /* Get base vaddr of paca array */ |
14cf11af PM |
1475 | li r5,0 /* logical cpu id */ |
1476 | 1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */ | |
1477 | cmpw r6,r24 /* Compare to our id */ | |
1478 | beq 2f | |
1479 | addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */ | |
1480 | addi r5,r5,1 | |
1481 | cmpwi r5,NR_CPUS | |
1482 | blt 1b | |
1483 | ||
1484 | mr r3,r24 /* not found, copy phys to r3 */ | |
1485 | b .kexec_wait /* next kernel might do better */ | |
1486 | ||
b5bbeb23 | 1487 | 2: mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */ |
14cf11af PM |
1488 | /* From now on, r24 is expected to be logical cpuid */ |
1489 | mr r24,r5 | |
1490 | 3: HMT_LOW | |
1491 | lbz r23,PACAPROCSTART(r13) /* Test if this processor should */ | |
1492 | /* start. */ | |
1493 | sync | |
1494 | ||
1495 | /* Create a temp kernel stack for use before relocation is on. */ | |
1496 | ld r1,PACAEMERGSP(r13) | |
1497 | subi r1,r1,STACK_FRAME_OVERHEAD | |
1498 | ||
1499 | cmpwi 0,r23,0 | |
1500 | #ifdef CONFIG_SMP | |
1501 | bne .__secondary_start | |
1502 | #endif | |
1503 | b 3b /* Loop until told to go */ | |
1504 | ||
1505 | #ifdef CONFIG_PPC_ISERIES | |
1506 | _STATIC(__start_initialization_iSeries) | |
1507 | /* Clear out the BSS */ | |
e58c3495 DG |
1508 | LOAD_REG_IMMEDIATE(r11,__bss_stop) |
1509 | LOAD_REG_IMMEDIATE(r8,__bss_start) | |
14cf11af PM |
1510 | sub r11,r11,r8 /* bss size */ |
1511 | addi r11,r11,7 /* round up to an even double word */ | |
1512 | rldicl. r11,r11,61,3 /* shift right by 3 */ | |
1513 | beq 4f | |
1514 | addi r8,r8,-8 | |
1515 | li r0,0 | |
1516 | mtctr r11 /* zero this many doublewords */ | |
1517 | 3: stdu r0,8(r8) | |
1518 | bdnz 3b | |
1519 | 4: | |
e58c3495 | 1520 | LOAD_REG_IMMEDIATE(r1,init_thread_union) |
14cf11af PM |
1521 | addi r1,r1,THREAD_SIZE |
1522 | li r0,0 | |
1523 | stdu r0,-STACK_FRAME_OVERHEAD(r1) | |
1524 | ||
e58c3495 DG |
1525 | LOAD_REG_IMMEDIATE(r3,cpu_specs) |
1526 | LOAD_REG_IMMEDIATE(r4,cur_cpu_spec) | |
14cf11af PM |
1527 | li r5,0 |
1528 | bl .identify_cpu | |
1529 | ||
e58c3495 | 1530 | LOAD_REG_IMMEDIATE(r2,__toc_start) |
14cf11af PM |
1531 | addi r2,r2,0x4000 |
1532 | addi r2,r2,0x4000 | |
1533 | ||
1534 | bl .iSeries_early_setup | |
ee400b63 | 1535 | bl .early_setup |
14cf11af PM |
1536 | |
1537 | /* relocation is on at this point */ | |
1538 | ||
1539 | b .start_here_common | |
1540 | #endif /* CONFIG_PPC_ISERIES */ | |
1541 | ||
1542 | #ifdef CONFIG_PPC_MULTIPLATFORM | |
1543 | ||
1544 | _STATIC(__mmu_off) | |
1545 | mfmsr r3 | |
1546 | andi. r0,r3,MSR_IR|MSR_DR | |
1547 | beqlr | |
1548 | andc r3,r3,r0 | |
1549 | mtspr SPRN_SRR0,r4 | |
1550 | mtspr SPRN_SRR1,r3 | |
1551 | sync | |
1552 | rfid | |
1553 | b . /* prevent speculative execution */ | |
1554 | ||
1555 | ||
1556 | /* | |
1557 | * Here is our main kernel entry point. We support currently 2 kind of entries | |
1558 | * depending on the value of r5. | |
1559 | * | |
1560 | * r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content | |
1561 | * in r3...r7 | |
1562 | * | |
1563 | * r5 == NULL -> kexec style entry. r3 is a physical pointer to the | |
1564 | * DT block, r4 is a physical pointer to the kernel itself | |
1565 | * | |
1566 | */ | |
1567 | _GLOBAL(__start_initialization_multiplatform) | |
be42d5fa | 1568 | #ifdef CONFIG_PPC_MULTIPLATFORM |
14cf11af PM |
1569 | /* |
1570 | * Are we booted from a PROM Of-type client-interface ? | |
1571 | */ | |
1572 | cmpldi cr0,r5,0 | |
1573 | bne .__boot_from_prom /* yes -> prom */ | |
be42d5fa | 1574 | #endif |
14cf11af PM |
1575 | |
1576 | /* Save parameters */ | |
1577 | mr r31,r3 | |
1578 | mr r30,r4 | |
1579 | ||
1580 | /* Make sure we are running in 64 bits mode */ | |
1581 | bl .enable_64b_mode | |
1582 | ||
1583 | /* Setup some critical 970 SPRs before switching MMU off */ | |
1584 | bl .__970_cpu_preinit | |
1585 | ||
1586 | /* cpu # */ | |
1587 | li r24,0 | |
1588 | ||
1589 | /* Switch off MMU if not already */ | |
e58c3495 | 1590 | LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE) |
14cf11af PM |
1591 | add r4,r4,r30 |
1592 | bl .__mmu_off | |
1593 | b .__after_prom_start | |
1594 | ||
be42d5fa | 1595 | #ifdef CONFIG_PPC_MULTIPLATFORM |
14cf11af PM |
1596 | _STATIC(__boot_from_prom) |
1597 | /* Save parameters */ | |
1598 | mr r31,r3 | |
1599 | mr r30,r4 | |
1600 | mr r29,r5 | |
1601 | mr r28,r6 | |
1602 | mr r27,r7 | |
1603 | ||
6088857b OH |
1604 | /* |
1605 | * Align the stack to 16-byte boundary | |
1606 | * Depending on the size and layout of the ELF sections in the initial | |
1607 | * boot binary, the stack pointer will be unalignet on PowerMac | |
1608 | */ | |
c05b4770 LT |
1609 | rldicr r1,r1,0,59 |
1610 | ||
14cf11af PM |
1611 | /* Make sure we are running in 64 bits mode */ |
1612 | bl .enable_64b_mode | |
1613 | ||
1614 | /* put a relocation offset into r3 */ | |
1615 | bl .reloc_offset | |
1616 | ||
e58c3495 | 1617 | LOAD_REG_IMMEDIATE(r2,__toc_start) |
14cf11af PM |
1618 | addi r2,r2,0x4000 |
1619 | addi r2,r2,0x4000 | |
1620 | ||
1621 | /* Relocate the TOC from a virt addr to a real addr */ | |
5a408329 | 1622 | add r2,r2,r3 |
14cf11af PM |
1623 | |
1624 | /* Restore parameters */ | |
1625 | mr r3,r31 | |
1626 | mr r4,r30 | |
1627 | mr r5,r29 | |
1628 | mr r6,r28 | |
1629 | mr r7,r27 | |
1630 | ||
1631 | /* Do all of the interaction with OF client interface */ | |
1632 | bl .prom_init | |
1633 | /* We never return */ | |
1634 | trap | |
be42d5fa | 1635 | #endif |
14cf11af PM |
1636 | |
1637 | /* | |
1638 | * At this point, r3 contains the physical address we are running at, | |
1639 | * returned by prom_init() | |
1640 | */ | |
1641 | _STATIC(__after_prom_start) | |
1642 | ||
1643 | /* | |
758438a7 | 1644 | * We need to run with __start at physical address PHYSICAL_START. |
14cf11af PM |
1645 | * This will leave some code in the first 256B of |
1646 | * real memory, which are reserved for software use. | |
1647 | * The remainder of the first page is loaded with the fixed | |
1648 | * interrupt vectors. The next two pages are filled with | |
1649 | * unknown exception placeholders. | |
1650 | * | |
1651 | * Note: This process overwrites the OF exception vectors. | |
1652 | * r26 == relocation offset | |
1653 | * r27 == KERNELBASE | |
1654 | */ | |
1655 | bl .reloc_offset | |
1656 | mr r26,r3 | |
e58c3495 | 1657 | LOAD_REG_IMMEDIATE(r27, KERNELBASE) |
14cf11af | 1658 | |
e58c3495 | 1659 | LOAD_REG_IMMEDIATE(r3, PHYSICAL_START) /* target addr */ |
14cf11af PM |
1660 | |
1661 | // XXX FIXME: Use phys returned by OF (r30) | |
5a408329 | 1662 | add r4,r27,r26 /* source addr */ |
14cf11af PM |
1663 | /* current address of _start */ |
1664 | /* i.e. where we are running */ | |
1665 | /* the source addr */ | |
1666 | ||
e58c3495 | 1667 | LOAD_REG_IMMEDIATE(r5,copy_to_here) /* # bytes of memory to copy */ |
14cf11af PM |
1668 | sub r5,r5,r27 |
1669 | ||
1670 | li r6,0x100 /* Start offset, the first 0x100 */ | |
1671 | /* bytes were copied earlier. */ | |
1672 | ||
1673 | bl .copy_and_flush /* copy the first n bytes */ | |
1674 | /* this includes the code being */ | |
1675 | /* executed here. */ | |
1676 | ||
e58c3495 | 1677 | LOAD_REG_IMMEDIATE(r0, 4f) /* Jump to the copy of this code */ |
14cf11af PM |
1678 | mtctr r0 /* that we just made/relocated */ |
1679 | bctr | |
1680 | ||
e58c3495 | 1681 | 4: LOAD_REG_IMMEDIATE(r5,klimit) |
5a408329 | 1682 | add r5,r5,r26 |
14cf11af PM |
1683 | ld r5,0(r5) /* get the value of klimit */ |
1684 | sub r5,r5,r27 | |
1685 | bl .copy_and_flush /* copy the rest */ | |
1686 | b .start_here_multiplatform | |
1687 | ||
1688 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | |
1689 | ||
1690 | /* | |
1691 | * Copy routine used to copy the kernel to start at physical address 0 | |
1692 | * and flush and invalidate the caches as needed. | |
1693 | * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset | |
1694 | * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5. | |
1695 | * | |
1696 | * Note: this routine *only* clobbers r0, r6 and lr | |
1697 | */ | |
1698 | _GLOBAL(copy_and_flush) | |
1699 | addi r5,r5,-8 | |
1700 | addi r6,r6,-8 | |
1701 | 4: li r0,16 /* Use the least common */ | |
1702 | /* denominator cache line */ | |
1703 | /* size. This results in */ | |
1704 | /* extra cache line flushes */ | |
1705 | /* but operation is correct. */ | |
1706 | /* Can't get cache line size */ | |
1707 | /* from NACA as it is being */ | |
1708 | /* moved too. */ | |
1709 | ||
1710 | mtctr r0 /* put # words/line in ctr */ | |
1711 | 3: addi r6,r6,8 /* copy a cache line */ | |
1712 | ldx r0,r6,r4 | |
1713 | stdx r0,r6,r3 | |
1714 | bdnz 3b | |
1715 | dcbst r6,r3 /* write it to memory */ | |
1716 | sync | |
1717 | icbi r6,r3 /* flush the icache line */ | |
1718 | cmpld 0,r6,r5 | |
1719 | blt 4b | |
1720 | sync | |
1721 | addi r5,r5,8 | |
1722 | addi r6,r6,8 | |
1723 | blr | |
1724 | ||
1725 | .align 8 | |
1726 | copy_to_here: | |
1727 | ||
1728 | #ifdef CONFIG_SMP | |
1729 | #ifdef CONFIG_PPC_PMAC | |
1730 | /* | |
1731 | * On PowerMac, secondary processors starts from the reset vector, which | |
1732 | * is temporarily turned into a call to one of the functions below. | |
1733 | */ | |
1734 | .section ".text"; | |
1735 | .align 2 ; | |
1736 | ||
35499c01 PM |
1737 | .globl __secondary_start_pmac_0 |
1738 | __secondary_start_pmac_0: | |
1739 | /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */ | |
1740 | li r24,0 | |
1741 | b 1f | |
1742 | li r24,1 | |
1743 | b 1f | |
1744 | li r24,2 | |
1745 | b 1f | |
1746 | li r24,3 | |
1747 | 1: | |
14cf11af PM |
1748 | |
1749 | _GLOBAL(pmac_secondary_start) | |
1750 | /* turn on 64-bit mode */ | |
1751 | bl .enable_64b_mode | |
1752 | isync | |
1753 | ||
1754 | /* Copy some CPU settings from CPU 0 */ | |
1755 | bl .__restore_cpu_setup | |
1756 | ||
1757 | /* pSeries do that early though I don't think we really need it */ | |
1758 | mfmsr r3 | |
1759 | ori r3,r3,MSR_RI | |
1760 | mtmsrd r3 /* RI on */ | |
1761 | ||
1762 | /* Set up a paca value for this processor. */ | |
e58c3495 | 1763 | LOAD_REG_IMMEDIATE(r4, paca) /* Get base vaddr of paca array */ |
14cf11af PM |
1764 | mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */ |
1765 | add r13,r13,r4 /* for this processor. */ | |
b5bbeb23 | 1766 | mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */ |
14cf11af PM |
1767 | |
1768 | /* Create a temp kernel stack for use before relocation is on. */ | |
1769 | ld r1,PACAEMERGSP(r13) | |
1770 | subi r1,r1,STACK_FRAME_OVERHEAD | |
1771 | ||
1772 | b .__secondary_start | |
1773 | ||
1774 | #endif /* CONFIG_PPC_PMAC */ | |
1775 | ||
1776 | /* | |
1777 | * This function is called after the master CPU has released the | |
1778 | * secondary processors. The execution environment is relocation off. | |
1779 | * The paca for this processor has the following fields initialized at | |
1780 | * this point: | |
1781 | * 1. Processor number | |
1782 | * 2. Segment table pointer (virtual address) | |
1783 | * On entry the following are set: | |
1784 | * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries | |
1785 | * r24 = cpu# (in Linux terms) | |
1786 | * r13 = paca virtual address | |
1787 | * SPRG3 = paca virtual address | |
1788 | */ | |
1789 | _GLOBAL(__secondary_start) | |
799d6046 PM |
1790 | /* Set thread priority to MEDIUM */ |
1791 | HMT_MEDIUM | |
14cf11af | 1792 | |
799d6046 | 1793 | /* Load TOC */ |
14cf11af | 1794 | ld r2,PACATOC(r13) |
799d6046 PM |
1795 | |
1796 | /* Do early setup for that CPU (stab, slb, hash table pointer) */ | |
1797 | bl .early_setup_secondary | |
14cf11af PM |
1798 | |
1799 | /* Initialize the kernel stack. Just a repeat for iSeries. */ | |
e58c3495 | 1800 | LOAD_REG_ADDR(r3, current_set) |
14cf11af PM |
1801 | sldi r28,r24,3 /* get current_set[cpu#] */ |
1802 | ldx r1,r3,r28 | |
1803 | addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD | |
1804 | std r1,PACAKSAVE(r13) | |
1805 | ||
799d6046 | 1806 | /* Clear backchain so we get nice backtraces */ |
14cf11af PM |
1807 | li r7,0 |
1808 | mtlr r7 | |
1809 | ||
1810 | /* enable MMU and jump to start_secondary */ | |
e58c3495 DG |
1811 | LOAD_REG_ADDR(r3, .start_secondary_prolog) |
1812 | LOAD_REG_IMMEDIATE(r4, MSR_KERNEL) | |
14cf11af PM |
1813 | #ifdef DO_SOFT_DISABLE |
1814 | ori r4,r4,MSR_EE | |
1815 | #endif | |
b5bbeb23 PM |
1816 | mtspr SPRN_SRR0,r3 |
1817 | mtspr SPRN_SRR1,r4 | |
14cf11af PM |
1818 | rfid |
1819 | b . /* prevent speculative execution */ | |
1820 | ||
1821 | /* | |
1822 | * Running with relocation on at this point. All we want to do is | |
1823 | * zero the stack back-chain pointer before going into C code. | |
1824 | */ | |
1825 | _GLOBAL(start_secondary_prolog) | |
1826 | li r3,0 | |
1827 | std r3,0(r1) /* Zero the stack frame pointer */ | |
1828 | bl .start_secondary | |
799d6046 | 1829 | b . |
14cf11af PM |
1830 | #endif |
1831 | ||
1832 | /* | |
1833 | * This subroutine clobbers r11 and r12 | |
1834 | */ | |
1835 | _GLOBAL(enable_64b_mode) | |
1836 | mfmsr r11 /* grab the current MSR */ | |
1837 | li r12,1 | |
1838 | rldicr r12,r12,MSR_SF_LG,(63-MSR_SF_LG) | |
1839 | or r11,r11,r12 | |
1840 | li r12,1 | |
1841 | rldicr r12,r12,MSR_ISF_LG,(63-MSR_ISF_LG) | |
1842 | or r11,r11,r12 | |
1843 | mtmsrd r11 | |
1844 | isync | |
1845 | blr | |
1846 | ||
1847 | #ifdef CONFIG_PPC_MULTIPLATFORM | |
1848 | /* | |
1849 | * This is where the main kernel code starts. | |
1850 | */ | |
1851 | _STATIC(start_here_multiplatform) | |
1852 | /* get a new offset, now that the kernel has moved. */ | |
1853 | bl .reloc_offset | |
1854 | mr r26,r3 | |
1855 | ||
1856 | /* Clear out the BSS. It may have been done in prom_init, | |
1857 | * already but that's irrelevant since prom_init will soon | |
1858 | * be detached from the kernel completely. Besides, we need | |
1859 | * to clear it now for kexec-style entry. | |
1860 | */ | |
e58c3495 DG |
1861 | LOAD_REG_IMMEDIATE(r11,__bss_stop) |
1862 | LOAD_REG_IMMEDIATE(r8,__bss_start) | |
14cf11af PM |
1863 | sub r11,r11,r8 /* bss size */ |
1864 | addi r11,r11,7 /* round up to an even double word */ | |
1865 | rldicl. r11,r11,61,3 /* shift right by 3 */ | |
1866 | beq 4f | |
1867 | addi r8,r8,-8 | |
1868 | li r0,0 | |
1869 | mtctr r11 /* zero this many doublewords */ | |
1870 | 3: stdu r0,8(r8) | |
1871 | bdnz 3b | |
1872 | 4: | |
1873 | ||
1874 | mfmsr r6 | |
1875 | ori r6,r6,MSR_RI | |
1876 | mtmsrd r6 /* RI on */ | |
1877 | ||
14cf11af PM |
1878 | /* The following gets the stack and TOC set up with the regs */ |
1879 | /* pointing to the real addr of the kernel stack. This is */ | |
1880 | /* all done to support the C function call below which sets */ | |
1881 | /* up the htab. This is done because we have relocated the */ | |
1882 | /* kernel but are still running in real mode. */ | |
1883 | ||
e58c3495 | 1884 | LOAD_REG_IMMEDIATE(r3,init_thread_union) |
5a408329 | 1885 | add r3,r3,r26 |
14cf11af PM |
1886 | |
1887 | /* set up a stack pointer (physical address) */ | |
1888 | addi r1,r3,THREAD_SIZE | |
1889 | li r0,0 | |
1890 | stdu r0,-STACK_FRAME_OVERHEAD(r1) | |
1891 | ||
1892 | /* set up the TOC (physical address) */ | |
e58c3495 | 1893 | LOAD_REG_IMMEDIATE(r2,__toc_start) |
14cf11af PM |
1894 | addi r2,r2,0x4000 |
1895 | addi r2,r2,0x4000 | |
5a408329 | 1896 | add r2,r2,r26 |
14cf11af | 1897 | |
e58c3495 | 1898 | LOAD_REG_IMMEDIATE(r3, cpu_specs) |
5a408329 | 1899 | add r3,r3,r26 |
e58c3495 | 1900 | LOAD_REG_IMMEDIATE(r4,cur_cpu_spec) |
5a408329 | 1901 | add r4,r4,r26 |
14cf11af PM |
1902 | mr r5,r26 |
1903 | bl .identify_cpu | |
1904 | ||
1905 | /* Save some low level config HIDs of CPU0 to be copied to | |
1906 | * other CPUs later on, or used for suspend/resume | |
1907 | */ | |
1908 | bl .__save_cpu_setup | |
1909 | sync | |
1910 | ||
14cf11af PM |
1911 | /* Do very early kernel initializations, including initial hash table, |
1912 | * stab and slb setup before we turn on relocation. */ | |
1913 | ||
1914 | /* Restore parameters passed from prom_init/kexec */ | |
1915 | mr r3,r31 | |
1916 | bl .early_setup | |
1917 | ||
e58c3495 DG |
1918 | LOAD_REG_IMMEDIATE(r3, .start_here_common) |
1919 | LOAD_REG_IMMEDIATE(r4, MSR_KERNEL) | |
b5bbeb23 PM |
1920 | mtspr SPRN_SRR0,r3 |
1921 | mtspr SPRN_SRR1,r4 | |
14cf11af PM |
1922 | rfid |
1923 | b . /* prevent speculative execution */ | |
1924 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | |
1925 | ||
1926 | /* This is where all platforms converge execution */ | |
1927 | _STATIC(start_here_common) | |
1928 | /* relocation is on at this point */ | |
1929 | ||
1930 | /* The following code sets up the SP and TOC now that we are */ | |
1931 | /* running with translation enabled. */ | |
1932 | ||
e58c3495 | 1933 | LOAD_REG_IMMEDIATE(r3,init_thread_union) |
14cf11af PM |
1934 | |
1935 | /* set up the stack */ | |
1936 | addi r1,r3,THREAD_SIZE | |
1937 | li r0,0 | |
1938 | stdu r0,-STACK_FRAME_OVERHEAD(r1) | |
1939 | ||
1940 | /* Apply the CPUs-specific fixups (nop out sections not relevant | |
1941 | * to this CPU | |
1942 | */ | |
1943 | li r3,0 | |
1944 | bl .do_cpu_ftr_fixups | |
1945 | ||
e58c3495 | 1946 | LOAD_REG_IMMEDIATE(r26, boot_cpuid) |
14cf11af PM |
1947 | lwz r26,0(r26) |
1948 | ||
e58c3495 | 1949 | LOAD_REG_IMMEDIATE(r24, paca) /* Get base vaddr of paca array */ |
14cf11af PM |
1950 | mulli r13,r26,PACA_SIZE /* Calculate vaddr of right paca */ |
1951 | add r13,r13,r24 /* for this processor. */ | |
b5bbeb23 | 1952 | mtspr SPRN_SPRG3,r13 |
14cf11af PM |
1953 | |
1954 | /* ptr to current */ | |
e58c3495 | 1955 | LOAD_REG_IMMEDIATE(r4, init_task) |
14cf11af PM |
1956 | std r4,PACACURRENT(r13) |
1957 | ||
1958 | /* Load the TOC */ | |
1959 | ld r2,PACATOC(r13) | |
1960 | std r1,PACAKSAVE(r13) | |
1961 | ||
1962 | bl .setup_system | |
1963 | ||
1964 | /* Load up the kernel context */ | |
1965 | 5: | |
1966 | #ifdef DO_SOFT_DISABLE | |
1967 | li r5,0 | |
1968 | stb r5,PACAPROCENABLED(r13) /* Soft Disabled */ | |
1969 | mfmsr r5 | |
1970 | ori r5,r5,MSR_EE /* Hard Enabled */ | |
1971 | mtmsrd r5 | |
1972 | #endif | |
1973 | ||
1974 | bl .start_kernel | |
1975 | ||
f1870f77 AB |
1976 | /* Not reached */ |
1977 | BUG_OPCODE | |
14cf11af | 1978 | |
14cf11af PM |
1979 | /* |
1980 | * We put a few things here that have to be page-aligned. | |
1981 | * This stuff goes at the beginning of the bss, which is page-aligned. | |
1982 | */ | |
1983 | .section ".bss" | |
1984 | ||
1985 | .align PAGE_SHIFT | |
1986 | ||
1987 | .globl empty_zero_page | |
1988 | empty_zero_page: | |
1989 | .space PAGE_SIZE | |
1990 | ||
1991 | .globl swapper_pg_dir | |
1992 | swapper_pg_dir: | |
1993 | .space PAGE_SIZE | |
1994 | ||
1995 | /* | |
1996 | * This space gets a copy of optional info passed to us by the bootstrap | |
1997 | * Used to pass parameters into the kernel like root=/dev/sda1, etc. | |
1998 | */ | |
1999 | .globl cmd_line | |
2000 | cmd_line: | |
2001 | .space COMMAND_LINE_SIZE |