|
10 | 10 | * We assume sprg3 has the physical address of the current |
11 | 11 | * task's thread_struct. |
12 | 12 | */ |
13 | | -.macro EXCEPTION_PROLOG |
14 | | - EXCEPTION_PROLOG_0 |
| 13 | +.macro EXCEPTION_PROLOG handle_dar_dsisr=0 |
| 14 | + EXCEPTION_PROLOG_0 handle_dar_dsisr=\handle_dar_dsisr |
15 | 15 | EXCEPTION_PROLOG_1 |
16 | | - EXCEPTION_PROLOG_2 |
| 16 | + EXCEPTION_PROLOG_2 handle_dar_dsisr=\handle_dar_dsisr |
17 | 17 | .endm |
18 | 18 |
|
19 | | -.macro EXCEPTION_PROLOG_0 |
| 19 | +.macro EXCEPTION_PROLOG_0 handle_dar_dsisr=0 |
20 | 20 | mtspr SPRN_SPRG_SCRATCH0,r10 |
21 | 21 | mtspr SPRN_SPRG_SCRATCH1,r11 |
| 22 | +#ifdef CONFIG_VMAP_STACK |
| 23 | + mfspr r10, SPRN_SPRG_THREAD |
| 24 | + .if \handle_dar_dsisr |
| 25 | + mfspr r11, SPRN_DAR |
| 26 | + stw r11, DAR(r10) |
| 27 | + mfspr r11, SPRN_DSISR |
| 28 | + stw r11, DSISR(r10) |
| 29 | + .endif |
| 30 | + mfspr r11, SPRN_SRR0 |
| 31 | + stw r11, SRR0(r10) |
| 32 | +#endif |
22 | 33 | mfspr r11, SPRN_SRR1 /* check whether user or kernel */ |
| 34 | +#ifdef CONFIG_VMAP_STACK |
| 35 | + stw r11, SRR1(r10) |
| 36 | +#endif |
23 | 37 | mfcr r10 |
24 | 38 | andi. r11, r11, MSR_PR |
25 | 39 | .endm |
26 | 40 |
|
27 | 41 | .macro EXCEPTION_PROLOG_1 |
| 42 | +#ifdef CONFIG_VMAP_STACK |
| 43 | + li r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ |
| 44 | + mtmsr r11 |
| 45 | + isync |
| 46 | + subi r11, r1, INT_FRAME_SIZE /* use r1 if kernel */ |
| 47 | +#else |
28 | 48 | tophys(r11,r1) /* use tophys(r1) if kernel */ |
| 49 | + subi r11, r11, INT_FRAME_SIZE /* alloc exc. frame */ |
| 50 | +#endif |
29 | 51 | beq 1f |
30 | 52 | mfspr r11,SPRN_SPRG_THREAD |
| 53 | + tovirt_vmstack r11, r11 |
31 | 54 | lwz r11,TASK_STACK-THREAD(r11) |
32 | | - addi r11,r11,THREAD_SIZE |
33 | | - tophys(r11,r11) |
34 | | -1: subi r11,r11,INT_FRAME_SIZE /* alloc exc. frame */ |
| 55 | + addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE |
| 56 | + tophys_novmstack r11, r11 |
| 57 | +1: |
35 | 58 | .endm |
36 | 59 |
|
37 | | -.macro EXCEPTION_PROLOG_2 |
| 60 | +.macro EXCEPTION_PROLOG_2 handle_dar_dsisr=0 |
38 | 61 | stw r10,_CCR(r11) /* save registers */ |
39 | 62 | stw r12,GPR12(r11) |
40 | 63 | stw r9,GPR9(r11) |
|
44 | 67 | stw r12,GPR11(r11) |
45 | 68 | mflr r10 |
46 | 69 | stw r10,_LINK(r11) |
| 70 | +#ifdef CONFIG_VMAP_STACK |
| 71 | + mfspr r12, SPRN_SPRG_THREAD |
| 72 | + tovirt(r12, r12) |
| 73 | + .if \handle_dar_dsisr |
| 74 | + lwz r10, DAR(r12) |
| 75 | + stw r10, _DAR(r11) |
| 76 | + lwz r10, DSISR(r12) |
| 77 | + stw r10, _DSISR(r11) |
| 78 | + .endif |
| 79 | + lwz r9, SRR1(r12) |
| 80 | + lwz r12, SRR0(r12) |
| 81 | +#else |
47 | 82 | mfspr r12,SPRN_SRR0 |
48 | 83 | mfspr r9,SPRN_SRR1 |
| 84 | +#endif |
49 | 85 | stw r1,GPR1(r11) |
50 | 86 | stw r1,0(r11) |
51 | | - tovirt(r1,r11) /* set new kernel sp */ |
| 87 | + tovirt_novmstack r1, r11 /* set new kernel sp */ |
52 | 88 | #ifdef CONFIG_40x |
53 | 89 | rlwinm r9,r9,0,14,12 /* clear MSR_WE (necessary?) */ |
| 90 | +#else |
| 91 | +#ifdef CONFIG_VMAP_STACK |
| 92 | + li r10, MSR_KERNEL & ~MSR_IR /* can take exceptions */ |
54 | 93 | #else |
55 | 94 | li r10,MSR_KERNEL & ~(MSR_IR|MSR_DR) /* can take exceptions */ |
| 95 | +#endif |
56 | 96 | mtmsr r10 /* (except for mach check in rtas) */ |
57 | 97 | #endif |
58 | 98 | stw r0,GPR0(r11) |
|
65 | 105 |
|
66 | 106 | .macro SYSCALL_ENTRY trapno |
67 | 107 | mfspr r12,SPRN_SPRG_THREAD |
| 108 | +#ifdef CONFIG_VMAP_STACK |
| 109 | + mfspr r9, SPRN_SRR0 |
| 110 | + mfspr r11, SPRN_SRR1 |
| 111 | + stw r9, SRR0(r12) |
| 112 | + stw r11, SRR1(r12) |
| 113 | +#endif |
68 | 114 | mfcr r10 |
69 | 115 | lwz r11,TASK_STACK-THREAD(r12) |
70 | | - mflr r9 |
71 | | - addi r11,r11,THREAD_SIZE - INT_FRAME_SIZE |
72 | 116 | rlwinm r10,r10,0,4,2 /* Clear SO bit in CR */ |
73 | | - tophys(r11,r11) |
| 117 | + addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE |
| 118 | +#ifdef CONFIG_VMAP_STACK |
| 119 | + li r9, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ |
| 120 | + mtmsr r9 |
| 121 | + isync |
| 122 | +#endif |
| 123 | + tovirt_vmstack r12, r12 |
| 124 | + tophys_novmstack r11, r11 |
| 125 | + mflr r9 |
74 | 126 | stw r10,_CCR(r11) /* save registers */ |
| 127 | + stw r9, _LINK(r11) |
| 128 | +#ifdef CONFIG_VMAP_STACK |
| 129 | + lwz r10, SRR0(r12) |
| 130 | + lwz r9, SRR1(r12) |
| 131 | +#else |
75 | 132 | mfspr r10,SPRN_SRR0 |
76 | | - stw r9,_LINK(r11) |
77 | 133 | mfspr r9,SPRN_SRR1 |
| 134 | +#endif |
78 | 135 | stw r1,GPR1(r11) |
79 | 136 | stw r1,0(r11) |
80 | | - tovirt(r1,r11) /* set new kernel sp */ |
| 137 | + tovirt_novmstack r1, r11 /* set new kernel sp */ |
81 | 138 | stw r10,_NIP(r11) |
82 | 139 | #ifdef CONFIG_40x |
83 | 140 | rlwinm r9,r9,0,14,12 /* clear MSR_WE (necessary?) */ |
| 141 | +#else |
| 142 | +#ifdef CONFIG_VMAP_STACK |
| 143 | + LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~MSR_IR) /* can take exceptions */ |
84 | 144 | #else |
85 | 145 | LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR|MSR_DR)) /* can take exceptions */ |
| 146 | +#endif |
86 | 147 | mtmsr r10 /* (except for mach check in rtas) */ |
87 | 148 | #endif |
88 | 149 | lis r10,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */ |
|
121 | 182 | #endif |
122 | 183 |
|
123 | 184 | 3: |
124 | | - tovirt(r2, r2) /* set r2 to current */ |
| 185 | + tovirt_novmstack r2, r2 /* set r2 to current */ |
125 | 186 | lis r11, transfer_to_syscall@h |
126 | 187 | ori r11, r11, transfer_to_syscall@l |
127 | 188 | #ifdef CONFIG_TRACE_IRQFLAGS |
|
145 | 206 | .endm |
146 | 207 |
|
147 | 208 | .macro save_dar_dsisr_on_stack reg1, reg2, sp |
| 209 | +#ifndef CONFIG_VMAP_STACK |
148 | 210 | mfspr \reg1, SPRN_DAR |
149 | 211 | mfspr \reg2, SPRN_DSISR |
150 | 212 | stw \reg1, _DAR(\sp) |
151 | 213 | stw \reg2, _DSISR(\sp) |
| 214 | +#endif |
152 | 215 | .endm |
153 | 216 |
|
154 | 217 | .macro get_and_save_dar_dsisr_on_stack reg1, reg2, sp |
| 218 | +#ifdef CONFIG_VMAP_STACK |
| 219 | + lwz \reg1, _DAR(\sp) |
| 220 | + lwz \reg2, _DSISR(\sp) |
| 221 | +#else |
155 | 222 | save_dar_dsisr_on_stack \reg1, \reg2, \sp |
| 223 | +#endif |
| 224 | +.endm |
| 225 | + |
| 226 | +.macro tovirt_vmstack dst, src |
| 227 | +#ifdef CONFIG_VMAP_STACK |
| 228 | + tovirt(\dst, \src) |
| 229 | +#else |
| 230 | + .ifnc \dst, \src |
| 231 | + mr \dst, \src |
| 232 | + .endif |
| 233 | +#endif |
| 234 | +.endm |
| 235 | + |
| 236 | +.macro tovirt_novmstack dst, src |
| 237 | +#ifndef CONFIG_VMAP_STACK |
| 238 | + tovirt(\dst, \src) |
| 239 | +#else |
| 240 | + .ifnc \dst, \src |
| 241 | + mr \dst, \src |
| 242 | + .endif |
| 243 | +#endif |
| 244 | +.endm |
| 245 | + |
| 246 | +.macro tophys_novmstack dst, src |
| 247 | +#ifndef CONFIG_VMAP_STACK |
| 248 | + tophys(\dst, \src) |
| 249 | +#else |
| 250 | + .ifnc \dst, \src |
| 251 | + mr \dst, \src |
| 252 | + .endif |
| 253 | +#endif |
156 | 254 | .endm |
157 | 255 |
|
158 | 256 | /* |
|
0 commit comments