diff options
Diffstat (limited to 'arch/xtensa/kernel/entry.S')
-rw-r--r-- | arch/xtensa/kernel/entry.S | 449 |
1 files changed, 231 insertions, 218 deletions
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S index 21dbe6bdb8ed..ef7f4990722b 100644 --- a/arch/xtensa/kernel/entry.S +++ b/arch/xtensa/kernel/entry.S | |||
@@ -1081,196 +1081,53 @@ ENTRY(fast_syscall_spill_registers) | |||
1081 | 1081 | ||
1082 | rsr a0, sar | 1082 | rsr a0, sar |
1083 | s32i a3, a2, PT_AREG3 | 1083 | s32i a3, a2, PT_AREG3 |
1084 | s32i a4, a2, PT_AREG4 | 1084 | s32i a0, a2, PT_SAR |
1085 | s32i a0, a2, PT_AREG5 # store SAR to PT_AREG5 | ||
1086 | 1085 | ||
1087 | /* The spill routine might clobber a7, a11, and a15. */ | 1086 | /* The spill routine might clobber a4, a7, a8, a11, a12, and a15. */ |
1088 | 1087 | ||
1088 | s32i a4, a2, PT_AREG4 | ||
1089 | s32i a7, a2, PT_AREG7 | 1089 | s32i a7, a2, PT_AREG7 |
1090 | s32i a8, a2, PT_AREG8 | ||
1090 | s32i a11, a2, PT_AREG11 | 1091 | s32i a11, a2, PT_AREG11 |
1092 | s32i a12, a2, PT_AREG12 | ||
1091 | s32i a15, a2, PT_AREG15 | 1093 | s32i a15, a2, PT_AREG15 |
1092 | 1094 | ||
1093 | call0 _spill_registers # destroys a3, a4, and SAR | ||
1094 | |||
1095 | /* Advance PC, restore registers and SAR, and return from exception. */ | ||
1096 | |||
1097 | l32i a3, a2, PT_AREG5 | ||
1098 | l32i a4, a2, PT_AREG4 | ||
1099 | l32i a0, a2, PT_AREG0 | ||
1100 | wsr a3, sar | ||
1101 | l32i a3, a2, PT_AREG3 | ||
1102 | |||
1103 | /* Restore clobbered registers. */ | ||
1104 | |||
1105 | l32i a7, a2, PT_AREG7 | ||
1106 | l32i a11, a2, PT_AREG11 | ||
1107 | l32i a15, a2, PT_AREG15 | ||
1108 | |||
1109 | movi a2, 0 | ||
1110 | rfe | ||
1111 | |||
1112 | ENDPROC(fast_syscall_spill_registers) | ||
1113 | |||
1114 | /* Fixup handler. | ||
1115 | * | ||
1116 | * We get here if the spill routine causes an exception, e.g. tlb miss. | ||
1117 | * We basically restore WINDOWBASE and WINDOWSTART to the condition when | ||
1118 | * we entered the spill routine and jump to the user exception handler. | ||
1119 | * | ||
1120 | * a0: value of depc, original value in depc | ||
1121 | * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE | ||
1122 | * a3: exctable, original value in excsave1 | ||
1123 | */ | ||
1124 | |||
1125 | ENTRY(fast_syscall_spill_registers_fixup) | ||
1126 | |||
1127 | rsr a2, windowbase # get current windowbase (a2 is saved) | ||
1128 | xsr a0, depc # restore depc and a0 | ||
1129 | ssl a2 # set shift (32 - WB) | ||
1130 | |||
1131 | /* We need to make sure the current registers (a0-a3) are preserved. | ||
1132 | * To do this, we simply set the bit for the current window frame | ||
1133 | * in WS, so that the exception handlers save them to the task stack. | ||
1134 | */ | ||
1135 | |||
1136 | xsr a3, excsave1 # get spill-mask | ||
1137 | slli a3, a3, 1 # shift left by one | ||
1138 | |||
1139 | slli a2, a3, 32-WSBITS | ||
1140 | src a2, a3, a2 # a2 = xxwww1yyxxxwww1yy...... | ||
1141 | wsr a2, windowstart # set corrected windowstart | ||
1142 | |||
1143 | srli a3, a3, 1 | ||
1144 | rsr a2, excsave1 | ||
1145 | l32i a2, a2, EXC_TABLE_DOUBLE_SAVE # restore a2 | ||
1146 | xsr a2, excsave1 | ||
1147 | s32i a3, a2, EXC_TABLE_DOUBLE_SAVE # save a3 | ||
1148 | l32i a3, a2, EXC_TABLE_PARAM # original WB (in user task) | ||
1149 | xsr a2, excsave1 | ||
1150 | |||
1151 | /* Return to the original (user task) WINDOWBASE. | ||
1152 | * We leave the following frame behind: | ||
1153 | * a0, a1, a2 same | ||
1154 | * a3: trashed (saved in EXC_TABLE_DOUBLE_SAVE) | ||
1155 | * depc: depc (we have to return to that address) | ||
1156 | * excsave_1: exctable | ||
1157 | */ | ||
1158 | |||
1159 | wsr a3, windowbase | ||
1160 | rsync | ||
1161 | |||
1162 | /* We are now in the original frame when we entered _spill_registers: | ||
1163 | * a0: return address | ||
1164 | * a1: used, stack pointer | ||
1165 | * a2: kernel stack pointer | ||
1166 | * a3: available | ||
1167 | * depc: exception address | ||
1168 | * excsave: exctable | ||
1169 | * Note: This frame might be the same as above. | ||
1170 | */ | ||
1171 | |||
1172 | /* Setup stack pointer. */ | ||
1173 | |||
1174 | addi a2, a2, -PT_USER_SIZE | ||
1175 | s32i a0, a2, PT_AREG0 | ||
1176 | |||
1177 | /* Make sure we return to this fixup handler. */ | ||
1178 | |||
1179 | movi a3, fast_syscall_spill_registers_fixup_return | ||
1180 | s32i a3, a2, PT_DEPC # setup depc | ||
1181 | |||
1182 | /* Jump to the exception handler. */ | ||
1183 | |||
1184 | rsr a3, excsave1 | ||
1185 | rsr a0, exccause | ||
1186 | addx4 a0, a0, a3 # find entry in table | ||
1187 | l32i a0, a0, EXC_TABLE_FAST_USER # load handler | ||
1188 | l32i a3, a3, EXC_TABLE_DOUBLE_SAVE | ||
1189 | jx a0 | ||
1190 | |||
1191 | ENDPROC(fast_syscall_spill_registers_fixup) | ||
1192 | |||
1193 | ENTRY(fast_syscall_spill_registers_fixup_return) | ||
1194 | |||
1195 | /* When we return here, all registers have been restored (a2: DEPC) */ | ||
1196 | |||
1197 | wsr a2, depc # exception address | ||
1198 | |||
1199 | /* Restore fixup handler. */ | ||
1200 | |||
1201 | rsr a2, excsave1 | ||
1202 | s32i a3, a2, EXC_TABLE_DOUBLE_SAVE | ||
1203 | movi a3, fast_syscall_spill_registers_fixup | ||
1204 | s32i a3, a2, EXC_TABLE_FIXUP | ||
1205 | rsr a3, windowbase | ||
1206 | s32i a3, a2, EXC_TABLE_PARAM | ||
1207 | l32i a2, a2, EXC_TABLE_KSTK | ||
1208 | |||
1209 | /* Load WB at the time the exception occurred. */ | ||
1210 | |||
1211 | rsr a3, sar # WB is still in SAR | ||
1212 | neg a3, a3 | ||
1213 | wsr a3, windowbase | ||
1214 | rsync | ||
1215 | |||
1216 | rsr a3, excsave1 | ||
1217 | l32i a3, a3, EXC_TABLE_DOUBLE_SAVE | ||
1218 | |||
1219 | rfde | ||
1220 | |||
1221 | ENDPROC(fast_syscall_spill_registers_fixup_return) | ||
1222 | |||
1223 | /* | ||
1224 | * spill all registers. | ||
1225 | * | ||
1226 | * This is not a real function. The following conditions must be met: | ||
1227 | * | ||
1228 | * - must be called with call0. | ||
1229 | * - uses a3, a4 and SAR. | ||
1230 | * - the last 'valid' register of each frame are clobbered. | ||
1231 | * - the caller must have registered a fixup handler | ||
1232 | * (or be inside a critical section) | ||
1233 | * - PS_EXCM must be set (PS_WOE cleared?) | ||
1234 | */ | ||
1235 | |||
1236 | ENTRY(_spill_registers) | ||
1237 | |||
1238 | /* | 1095 | /* |
1239 | * Rotate ws so that the current windowbase is at bit 0. | 1096 | * Rotate ws so that the current windowbase is at bit 0. |
1240 | * Assume ws = xxxwww1yy (www1 current window frame). | 1097 | * Assume ws = xxxwww1yy (www1 current window frame). |
1241 | * Rotate ws right so that a4 = yyxxxwww1. | 1098 | * Rotate ws right so that a4 = yyxxxwww1. |
1242 | */ | 1099 | */ |
1243 | 1100 | ||
1244 | rsr a4, windowbase | 1101 | rsr a0, windowbase |
1245 | rsr a3, windowstart # a3 = xxxwww1yy | 1102 | rsr a3, windowstart # a3 = xxxwww1yy |
1246 | ssr a4 # holds WB | 1103 | ssr a0 # holds WB |
1247 | slli a4, a3, WSBITS | 1104 | slli a0, a3, WSBITS |
1248 | or a3, a3, a4 # a3 = xxxwww1yyxxxwww1yy | 1105 | or a3, a3, a0 # a3 = xxxwww1yyxxxwww1yy |
1249 | srl a3, a3 # a3 = 00xxxwww1yyxxxwww1 | 1106 | srl a3, a3 # a3 = 00xxxwww1yyxxxwww1 |
1250 | 1107 | ||
1251 | /* We are done if there are no more than the current register frame. */ | 1108 | /* We are done if there are no more than the current register frame. */ |
1252 | 1109 | ||
1253 | extui a3, a3, 1, WSBITS-1 # a3 = 0yyxxxwww | 1110 | extui a3, a3, 1, WSBITS-1 # a3 = 0yyxxxwww |
1254 | movi a4, (1 << (WSBITS-1)) | 1111 | movi a0, (1 << (WSBITS-1)) |
1255 | _beqz a3, .Lnospill # only one active frame? jump | 1112 | _beqz a3, .Lnospill # only one active frame? jump |
1256 | 1113 | ||
1257 | /* We want 1 at the top, so that we return to the current windowbase */ | 1114 | /* We want 1 at the top, so that we return to the current windowbase */ |
1258 | 1115 | ||
1259 | or a3, a3, a4 # 1yyxxxwww | 1116 | or a3, a3, a0 # 1yyxxxwww |
1260 | 1117 | ||
1261 | /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */ | 1118 | /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */ |
1262 | 1119 | ||
1263 | wsr a3, windowstart # save shifted windowstart | 1120 | wsr a3, windowstart # save shifted windowstart |
1264 | neg a4, a3 | 1121 | neg a0, a3 |
1265 | and a3, a4, a3 # first bit set from right: 000010000 | 1122 | and a3, a0, a3 # first bit set from right: 000010000 |
1266 | 1123 | ||
1267 | ffs_ws a4, a3 # a4: shifts to skip empty frames | 1124 | ffs_ws a0, a3 # a0: shifts to skip empty frames |
1268 | movi a3, WSBITS | 1125 | movi a3, WSBITS |
1269 | sub a4, a3, a4 # WSBITS-a4:number of 0-bits from right | 1126 | sub a0, a3, a0 # WSBITS-a0:number of 0-bits from right |
1270 | ssr a4 # save in SAR for later. | 1127 | ssr a0 # save in SAR for later. |
1271 | 1128 | ||
1272 | rsr a3, windowbase | 1129 | rsr a3, windowbase |
1273 | add a3, a3, a4 | 1130 | add a3, a3, a0 |
1274 | wsr a3, windowbase | 1131 | wsr a3, windowbase |
1275 | rsync | 1132 | rsync |
1276 | 1133 | ||
@@ -1285,22 +1142,6 @@ ENTRY(_spill_registers) | |||
1285 | * we have to save 4,8. or 12 registers. | 1142 | * we have to save 4,8. or 12 registers. |
1286 | */ | 1143 | */ |
1287 | 1144 | ||
1288 | _bbsi.l a3, 1, .Lc4 | ||
1289 | _bbsi.l a3, 2, .Lc8 | ||
1290 | |||
1291 | /* Special case: we have a call12-frame starting at a4. */ | ||
1292 | |||
1293 | _bbci.l a3, 3, .Lc12 # bit 3 shouldn't be zero! (Jump to Lc12 first) | ||
1294 | |||
1295 | s32e a4, a1, -16 # a1 is valid with an empty spill area | ||
1296 | l32e a4, a5, -12 | ||
1297 | s32e a8, a4, -48 | ||
1298 | mov a8, a4 | ||
1299 | l32e a4, a1, -16 | ||
1300 | j .Lc12c | ||
1301 | |||
1302 | .Lnospill: | ||
1303 | ret | ||
1304 | 1145 | ||
1305 | .Lloop: _bbsi.l a3, 1, .Lc4 | 1146 | .Lloop: _bbsi.l a3, 1, .Lc4 |
1306 | _bbci.l a3, 2, .Lc12 | 1147 | _bbci.l a3, 2, .Lc12 |
@@ -1314,20 +1155,10 @@ ENTRY(_spill_registers) | |||
1314 | s32e a9, a4, -28 | 1155 | s32e a9, a4, -28 |
1315 | s32e a10, a4, -24 | 1156 | s32e a10, a4, -24 |
1316 | s32e a11, a4, -20 | 1157 | s32e a11, a4, -20 |
1317 | |||
1318 | srli a11, a3, 2 # shift windowbase by 2 | 1158 | srli a11, a3, 2 # shift windowbase by 2 |
1319 | rotw 2 | 1159 | rotw 2 |
1320 | _bnei a3, 1, .Lloop | 1160 | _bnei a3, 1, .Lloop |
1321 | 1161 | j .Lexit | |
1322 | .Lexit: /* Done. Do the final rotation, set WS, and return. */ | ||
1323 | |||
1324 | rotw 1 | ||
1325 | rsr a3, windowbase | ||
1326 | ssl a3 | ||
1327 | movi a3, 1 | ||
1328 | sll a3, a3 | ||
1329 | wsr a3, windowstart | ||
1330 | ret | ||
1331 | 1162 | ||
1332 | .Lc4: s32e a4, a9, -16 | 1163 | .Lc4: s32e a4, a9, -16 |
1333 | s32e a5, a9, -12 | 1164 | s32e a5, a9, -12 |
@@ -1343,11 +1174,11 @@ ENTRY(_spill_registers) | |||
1343 | 1174 | ||
1344 | /* 12-register frame (call12) */ | 1175 | /* 12-register frame (call12) */ |
1345 | 1176 | ||
1346 | l32e a2, a5, -12 | 1177 | l32e a0, a5, -12 |
1347 | s32e a8, a2, -48 | 1178 | s32e a8, a0, -48 |
1348 | mov a8, a2 | 1179 | mov a8, a0 |
1349 | 1180 | ||
1350 | .Lc12c: s32e a9, a8, -44 | 1181 | s32e a9, a8, -44 |
1351 | s32e a10, a8, -40 | 1182 | s32e a10, a8, -40 |
1352 | s32e a11, a8, -36 | 1183 | s32e a11, a8, -36 |
1353 | s32e a12, a8, -32 | 1184 | s32e a12, a8, -32 |
@@ -1367,30 +1198,54 @@ ENTRY(_spill_registers) | |||
1367 | */ | 1198 | */ |
1368 | 1199 | ||
1369 | rotw 1 | 1200 | rotw 1 |
1370 | mov a5, a13 | 1201 | mov a4, a13 |
1371 | rotw -1 | 1202 | rotw -1 |
1372 | 1203 | ||
1373 | s32e a4, a9, -16 | 1204 | s32e a4, a8, -16 |
1374 | s32e a5, a9, -12 | 1205 | s32e a5, a8, -12 |
1375 | s32e a6, a9, -8 | 1206 | s32e a6, a8, -8 |
1376 | s32e a7, a9, -4 | 1207 | s32e a7, a8, -4 |
1377 | 1208 | ||
1378 | rotw 3 | 1209 | rotw 3 |
1379 | 1210 | ||
1380 | _beqi a3, 1, .Lexit | 1211 | _beqi a3, 1, .Lexit |
1381 | j .Lloop | 1212 | j .Lloop |
1382 | 1213 | ||
1383 | .Linvalid_mask: | 1214 | .Lexit: |
1384 | 1215 | ||
1385 | /* We get here because of an unrecoverable error in the window | 1216 | /* Done. Do the final rotation and set WS */ |
1386 | * registers. If we are in user space, we kill the application, | 1217 | |
1387 | * however, this condition is unrecoverable in kernel space. | 1218 | rotw 1 |
1388 | */ | 1219 | rsr a3, windowbase |
1220 | ssl a3 | ||
1221 | movi a3, 1 | ||
1222 | sll a3, a3 | ||
1223 | wsr a3, windowstart | ||
1224 | .Lnospill: | ||
1225 | |||
1226 | /* Advance PC, restore registers and SAR, and return from exception. */ | ||
1227 | |||
1228 | l32i a3, a2, PT_SAR | ||
1229 | l32i a0, a2, PT_AREG0 | ||
1230 | wsr a3, sar | ||
1231 | l32i a3, a2, PT_AREG3 | ||
1389 | 1232 | ||
1390 | rsr a0, ps | 1233 | /* Restore clobbered registers. */ |
1391 | _bbci.l a0, PS_UM_BIT, 1f | ||
1392 | 1234 | ||
1393 | /* User space: Setup a dummy frame and kill application. | 1235 | l32i a4, a2, PT_AREG4 |
1236 | l32i a7, a2, PT_AREG7 | ||
1237 | l32i a8, a2, PT_AREG8 | ||
1238 | l32i a11, a2, PT_AREG11 | ||
1239 | l32i a12, a2, PT_AREG12 | ||
1240 | l32i a15, a2, PT_AREG15 | ||
1241 | |||
1242 | movi a2, 0 | ||
1243 | rfe | ||
1244 | |||
1245 | .Linvalid_mask: | ||
1246 | |||
1247 | /* We get here because of an unrecoverable error in the window | ||
1248 | * registers, so set up a dummy frame and kill the user application. | ||
1394 | * Note: We assume EXC_TABLE_KSTK contains a valid stack pointer. | 1249 | * Note: We assume EXC_TABLE_KSTK contains a valid stack pointer. |
1395 | */ | 1250 | */ |
1396 | 1251 | ||
@@ -1414,14 +1269,136 @@ ENTRY(_spill_registers) | |||
1414 | movi a4, do_exit | 1269 | movi a4, do_exit |
1415 | callx4 a4 | 1270 | callx4 a4 |
1416 | 1271 | ||
1417 | 1: /* Kernel space: PANIC! */ | 1272 | /* shouldn't return, so panic */ |
1418 | 1273 | ||
1419 | wsr a0, excsave1 | 1274 | wsr a0, excsave1 |
1420 | movi a0, unrecoverable_exception | 1275 | movi a0, unrecoverable_exception |
1421 | callx0 a0 # should not return | 1276 | callx0 a0 # should not return |
1422 | 1: j 1b | 1277 | 1: j 1b |
1423 | 1278 | ||
1424 | ENDPROC(_spill_registers) | 1279 | |
1280 | ENDPROC(fast_syscall_spill_registers) | ||
1281 | |||
1282 | /* Fixup handler. | ||
1283 | * | ||
1284 | * We get here if the spill routine causes an exception, e.g. tlb miss. | ||
1285 | * We basically restore WINDOWBASE and WINDOWSTART to the condition when | ||
1286 | * we entered the spill routine and jump to the user exception handler. | ||
1287 | * | ||
1288 | * Note that we only need to restore the bits in windowstart that have not | ||
1289 | * been spilled yet by the _spill_register routine. Luckily, a3 contains a | ||
1290 | * rotated windowstart with only those bits set for frames that haven't been | ||
1291 | * spilled yet. Because a3 is rotated such that bit 0 represents the register | ||
1292 | * frame for the current windowbase - 1, we need to rotate a3 left by the | ||
1293 | * value of the current windowbase + 1 and move it to windowstart. | ||
1294 | * | ||
1295 | * a0: value of depc, original value in depc | ||
1296 | * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE | ||
1297 | * a3: exctable, original value in excsave1 | ||
1298 | */ | ||
1299 | |||
1300 | ENTRY(fast_syscall_spill_registers_fixup) | ||
1301 | |||
1302 | rsr a2, windowbase # get current windowbase (a2 is saved) | ||
1303 | xsr a0, depc # restore depc and a0 | ||
1304 | ssl a2 # set shift (32 - WB) | ||
1305 | |||
1306 | /* We need to make sure the current registers (a0-a3) are preserved. | ||
1307 | * To do this, we simply set the bit for the current window frame | ||
1308 | * in WS, so that the exception handlers save them to the task stack. | ||
1309 | * | ||
1310 | * Note: we use a3 to set the windowbase, so we take a special care | ||
1311 | * of it, saving it in the original _spill_registers frame across | ||
1312 | * the exception handler call. | ||
1313 | */ | ||
1314 | |||
1315 | xsr a3, excsave1 # get spill-mask | ||
1316 | slli a3, a3, 1 # shift left by one | ||
1317 | addi a3, a3, 1 # set the bit for the current window frame | ||
1318 | |||
1319 | slli a2, a3, 32-WSBITS | ||
1320 | src a2, a3, a2 # a2 = xxwww1yyxxxwww1yy...... | ||
1321 | wsr a2, windowstart # set corrected windowstart | ||
1322 | |||
1323 | srli a3, a3, 1 | ||
1324 | rsr a2, excsave1 | ||
1325 | l32i a2, a2, EXC_TABLE_DOUBLE_SAVE # restore a2 | ||
1326 | xsr a2, excsave1 | ||
1327 | s32i a3, a2, EXC_TABLE_DOUBLE_SAVE # save a3 | ||
1328 | l32i a3, a2, EXC_TABLE_PARAM # original WB (in user task) | ||
1329 | xsr a2, excsave1 | ||
1330 | |||
1331 | /* Return to the original (user task) WINDOWBASE. | ||
1332 | * We leave the following frame behind: | ||
1333 | * a0, a1, a2 same | ||
1334 | * a3: trashed (saved in EXC_TABLE_DOUBLE_SAVE) | ||
1335 | * depc: depc (we have to return to that address) | ||
1336 | * excsave_1: exctable | ||
1337 | */ | ||
1338 | |||
1339 | wsr a3, windowbase | ||
1340 | rsync | ||
1341 | |||
1342 | /* We are now in the original frame when we entered _spill_registers: | ||
1343 | * a0: return address | ||
1344 | * a1: used, stack pointer | ||
1345 | * a2: kernel stack pointer | ||
1346 | * a3: available | ||
1347 | * depc: exception address | ||
1348 | * excsave: exctable | ||
1349 | * Note: This frame might be the same as above. | ||
1350 | */ | ||
1351 | |||
1352 | /* Setup stack pointer. */ | ||
1353 | |||
1354 | addi a2, a2, -PT_USER_SIZE | ||
1355 | s32i a0, a2, PT_AREG0 | ||
1356 | |||
1357 | /* Make sure we return to this fixup handler. */ | ||
1358 | |||
1359 | movi a3, fast_syscall_spill_registers_fixup_return | ||
1360 | s32i a3, a2, PT_DEPC # setup depc | ||
1361 | |||
1362 | /* Jump to the exception handler. */ | ||
1363 | |||
1364 | rsr a3, excsave1 | ||
1365 | rsr a0, exccause | ||
1366 | addx4 a0, a0, a3 # find entry in table | ||
1367 | l32i a0, a0, EXC_TABLE_FAST_USER # load handler | ||
1368 | l32i a3, a3, EXC_TABLE_DOUBLE_SAVE | ||
1369 | jx a0 | ||
1370 | |||
1371 | ENDPROC(fast_syscall_spill_registers_fixup) | ||
1372 | |||
1373 | ENTRY(fast_syscall_spill_registers_fixup_return) | ||
1374 | |||
1375 | /* When we return here, all registers have been restored (a2: DEPC) */ | ||
1376 | |||
1377 | wsr a2, depc # exception address | ||
1378 | |||
1379 | /* Restore fixup handler. */ | ||
1380 | |||
1381 | rsr a2, excsave1 | ||
1382 | s32i a3, a2, EXC_TABLE_DOUBLE_SAVE | ||
1383 | movi a3, fast_syscall_spill_registers_fixup | ||
1384 | s32i a3, a2, EXC_TABLE_FIXUP | ||
1385 | rsr a3, windowbase | ||
1386 | s32i a3, a2, EXC_TABLE_PARAM | ||
1387 | l32i a2, a2, EXC_TABLE_KSTK | ||
1388 | |||
1389 | /* Load WB at the time the exception occurred. */ | ||
1390 | |||
1391 | rsr a3, sar # WB is still in SAR | ||
1392 | neg a3, a3 | ||
1393 | wsr a3, windowbase | ||
1394 | rsync | ||
1395 | |||
1396 | rsr a3, excsave1 | ||
1397 | l32i a3, a3, EXC_TABLE_DOUBLE_SAVE | ||
1398 | |||
1399 | rfde | ||
1400 | |||
1401 | ENDPROC(fast_syscall_spill_registers_fixup_return) | ||
1425 | 1402 | ||
1426 | #ifdef CONFIG_MMU | 1403 | #ifdef CONFIG_MMU |
1427 | /* | 1404 | /* |
@@ -1794,6 +1771,43 @@ ENTRY(system_call) | |||
1794 | 1771 | ||
1795 | ENDPROC(system_call) | 1772 | ENDPROC(system_call) |
1796 | 1773 | ||
1774 | /* | ||
1775 | * Spill live registers on the kernel stack macro. | ||
1776 | * | ||
1777 | * Entry condition: ps.woe is set, ps.excm is cleared | ||
1778 | * Exit condition: windowstart has single bit set | ||
1779 | * May clobber: a12, a13 | ||
1780 | */ | ||
1781 | .macro spill_registers_kernel | ||
1782 | |||
1783 | #if XCHAL_NUM_AREGS > 16 | ||
1784 | call12 1f | ||
1785 | _j 2f | ||
1786 | retw | ||
1787 | .align 4 | ||
1788 | 1: | ||
1789 | _entry a1, 48 | ||
1790 | addi a12, a0, 3 | ||
1791 | #if XCHAL_NUM_AREGS > 32 | ||
1792 | .rept (XCHAL_NUM_AREGS - 32) / 12 | ||
1793 | _entry a1, 48 | ||
1794 | mov a12, a0 | ||
1795 | .endr | ||
1796 | #endif | ||
1797 | _entry a1, 48 | ||
1798 | #if XCHAL_NUM_AREGS % 12 == 0 | ||
1799 | mov a8, a8 | ||
1800 | #elif XCHAL_NUM_AREGS % 12 == 4 | ||
1801 | mov a12, a12 | ||
1802 | #elif XCHAL_NUM_AREGS % 12 == 8 | ||
1803 | mov a4, a4 | ||
1804 | #endif | ||
1805 | retw | ||
1806 | 2: | ||
1807 | #else | ||
1808 | mov a12, a12 | ||
1809 | #endif | ||
1810 | .endm | ||
1797 | 1811 | ||
1798 | /* | 1812 | /* |
1799 | * Task switch. | 1813 | * Task switch. |
@@ -1806,21 +1820,20 @@ ENTRY(_switch_to) | |||
1806 | 1820 | ||
1807 | entry a1, 16 | 1821 | entry a1, 16 |
1808 | 1822 | ||
1809 | mov a12, a2 # preserve 'prev' (a2) | 1823 | mov a10, a2 # preserve 'prev' (a2) |
1810 | mov a13, a3 # and 'next' (a3) | 1824 | mov a11, a3 # and 'next' (a3) |
1811 | 1825 | ||
1812 | l32i a4, a2, TASK_THREAD_INFO | 1826 | l32i a4, a2, TASK_THREAD_INFO |
1813 | l32i a5, a3, TASK_THREAD_INFO | 1827 | l32i a5, a3, TASK_THREAD_INFO |
1814 | 1828 | ||
1815 | save_xtregs_user a4 a6 a8 a9 a10 a11 THREAD_XTREGS_USER | 1829 | save_xtregs_user a4 a6 a8 a9 a12 a13 THREAD_XTREGS_USER |
1816 | 1830 | ||
1817 | s32i a0, a12, THREAD_RA # save return address | 1831 | s32i a0, a10, THREAD_RA # save return address |
1818 | s32i a1, a12, THREAD_SP # save stack pointer | 1832 | s32i a1, a10, THREAD_SP # save stack pointer |
1819 | 1833 | ||
1820 | /* Disable ints while we manipulate the stack pointer. */ | 1834 | /* Disable ints while we manipulate the stack pointer. */ |
1821 | 1835 | ||
1822 | movi a14, (1 << PS_EXCM_BIT) | LOCKLEVEL | 1836 | rsil a14, LOCKLEVEL |
1823 | xsr a14, ps | ||
1824 | rsr a3, excsave1 | 1837 | rsr a3, excsave1 |
1825 | rsync | 1838 | rsync |
1826 | s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */ | 1839 | s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */ |
@@ -1835,7 +1848,7 @@ ENTRY(_switch_to) | |||
1835 | 1848 | ||
1836 | /* Flush register file. */ | 1849 | /* Flush register file. */ |
1837 | 1850 | ||
1838 | call0 _spill_registers # destroys a3, a4, and SAR | 1851 | spill_registers_kernel |
1839 | 1852 | ||
1840 | /* Set kernel stack (and leave critical section) | 1853 | /* Set kernel stack (and leave critical section) |
1841 | * Note: It's save to set it here. The stack will not be overwritten | 1854 | * Note: It's save to set it here. The stack will not be overwritten |
@@ -1851,13 +1864,13 @@ ENTRY(_switch_to) | |||
1851 | 1864 | ||
1852 | /* restore context of the task 'next' */ | 1865 | /* restore context of the task 'next' */ |
1853 | 1866 | ||
1854 | l32i a0, a13, THREAD_RA # restore return address | 1867 | l32i a0, a11, THREAD_RA # restore return address |
1855 | l32i a1, a13, THREAD_SP # restore stack pointer | 1868 | l32i a1, a11, THREAD_SP # restore stack pointer |
1856 | 1869 | ||
1857 | load_xtregs_user a5 a6 a8 a9 a10 a11 THREAD_XTREGS_USER | 1870 | load_xtregs_user a5 a6 a8 a9 a12 a13 THREAD_XTREGS_USER |
1858 | 1871 | ||
1859 | wsr a14, ps | 1872 | wsr a14, ps |
1860 | mov a2, a12 # return 'prev' | 1873 | mov a2, a10 # return 'prev' |
1861 | rsync | 1874 | rsync |
1862 | 1875 | ||
1863 | retw | 1876 | retw |