diff options
| -rw-r--r-- | arch/x86/kernel/entry_64.S | 185 |
1 files changed, 80 insertions, 105 deletions
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 1e96c3628bf2..be846d2468f7 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | * - FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK - Fix up the hardware stack | 36 | * - FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK - Fix up the hardware stack |
| 37 | * frame that is otherwise undefined after a SYSCALL | 37 | * frame that is otherwise undefined after a SYSCALL |
| 38 | * - TRACE_IRQ_* - Trace hard interrupt state for lock debugging. | 38 | * - TRACE_IRQ_* - Trace hard interrupt state for lock debugging. |
| 39 | * - errorentry/paranoidentry/zeroentry - Define exception entry points. | 39 | * - idtentry - Define exception entry points. |
| 40 | */ | 40 | */ |
| 41 | 41 | ||
| 42 | #include <linux/linkage.h> | 42 | #include <linux/linkage.h> |
| @@ -1203,125 +1203,100 @@ apicinterrupt IRQ_WORK_VECTOR \ | |||
| 1203 | /* | 1203 | /* |
| 1204 | * Exception entry points. | 1204 | * Exception entry points. |
| 1205 | */ | 1205 | */ |
| 1206 | .macro zeroentry sym do_sym | 1206 | #define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8) |
| 1207 | ENTRY(\sym) | ||
| 1208 | INTR_FRAME | ||
| 1209 | ASM_CLAC | ||
| 1210 | PARAVIRT_ADJUST_EXCEPTION_FRAME | ||
| 1211 | pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ | ||
| 1212 | subq $ORIG_RAX-R15, %rsp | ||
| 1213 | CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 | ||
| 1214 | call error_entry | ||
| 1215 | DEFAULT_FRAME 0 | ||
| 1216 | movq %rsp,%rdi /* pt_regs pointer */ | ||
| 1217 | xorl %esi,%esi /* no error code */ | ||
| 1218 | call \do_sym | ||
| 1219 | jmp error_exit /* %ebx: no swapgs flag */ | ||
| 1220 | CFI_ENDPROC | ||
| 1221 | END(\sym) | ||
| 1222 | .endm | ||
| 1223 | 1207 | ||
| 1224 | .macro paranoidzeroentry sym do_sym | 1208 | .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1 |
| 1225 | ENTRY(\sym) | 1209 | ENTRY(\sym) |
| 1226 | INTR_FRAME | 1210 | /* Sanity check */ |
| 1227 | ASM_CLAC | 1211 | .if \shift_ist != -1 && \paranoid == 0 |
| 1228 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 1212 | .error "using shift_ist requires paranoid=1" |
| 1229 | pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ | 1213 | .endif |
| 1230 | subq $ORIG_RAX-R15, %rsp | ||
| 1231 | CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 | ||
| 1232 | call save_paranoid | ||
| 1233 | TRACE_IRQS_OFF | ||
| 1234 | movq %rsp,%rdi /* pt_regs pointer */ | ||
| 1235 | xorl %esi,%esi /* no error code */ | ||
| 1236 | call \do_sym | ||
| 1237 | jmp paranoid_exit /* %ebx: no swapgs flag */ | ||
| 1238 | CFI_ENDPROC | ||
| 1239 | END(\sym) | ||
| 1240 | .endm | ||
| 1241 | 1214 | ||
| 1242 | #define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8) | 1215 | .if \has_error_code |
| 1243 | .macro paranoidzeroentry_ist sym do_sym ist | 1216 | XCPT_FRAME |
| 1244 | ENTRY(\sym) | 1217 | .else |
| 1245 | INTR_FRAME | 1218 | INTR_FRAME |
| 1246 | ASM_CLAC | 1219 | .endif |
| 1247 | PARAVIRT_ADJUST_EXCEPTION_FRAME | ||
| 1248 | pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ | ||
| 1249 | subq $ORIG_RAX-R15, %rsp | ||
| 1250 | CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 | ||
| 1251 | call save_paranoid | ||
| 1252 | TRACE_IRQS_OFF_DEBUG | ||
| 1253 | movq %rsp,%rdi /* pt_regs pointer */ | ||
| 1254 | xorl %esi,%esi /* no error code */ | ||
| 1255 | subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist) | ||
| 1256 | call \do_sym | ||
| 1257 | addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist) | ||
| 1258 | jmp paranoid_exit /* %ebx: no swapgs flag */ | ||
| 1259 | CFI_ENDPROC | ||
| 1260 | END(\sym) | ||
| 1261 | .endm | ||
| 1262 | 1220 | ||
| 1263 | .macro errorentry sym do_sym | ||
| 1264 | ENTRY(\sym) | ||
| 1265 | XCPT_FRAME | ||
| 1266 | ASM_CLAC | 1221 | ASM_CLAC |
| 1267 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 1222 | PARAVIRT_ADJUST_EXCEPTION_FRAME |
| 1223 | |||
| 1224 | .ifeq \has_error_code | ||
| 1225 | pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ | ||
| 1226 | .endif | ||
| 1227 | |||
| 1268 | subq $ORIG_RAX-R15, %rsp | 1228 | subq $ORIG_RAX-R15, %rsp |
| 1269 | CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 | 1229 | CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 |
| 1230 | |||
| 1231 | .if \paranoid | ||
| 1232 | call save_paranoid | ||
| 1233 | .else | ||
| 1270 | call error_entry | 1234 | call error_entry |
| 1235 | .endif | ||
| 1236 | |||
| 1271 | DEFAULT_FRAME 0 | 1237 | DEFAULT_FRAME 0 |
| 1238 | |||
| 1239 | .if \paranoid | ||
| 1240 | .if \shift_ist != -1 | ||
| 1241 | TRACE_IRQS_OFF_DEBUG /* reload IDT in case of recursion */ | ||
| 1242 | .else | ||
| 1243 | TRACE_IRQS_OFF | ||
| 1244 | .endif | ||
| 1245 | .endif | ||
| 1246 | |||
| 1272 | movq %rsp,%rdi /* pt_regs pointer */ | 1247 | movq %rsp,%rdi /* pt_regs pointer */ |
| 1248 | |||
| 1249 | .if \has_error_code | ||
| 1273 | movq ORIG_RAX(%rsp),%rsi /* get error code */ | 1250 | movq ORIG_RAX(%rsp),%rsi /* get error code */ |
| 1274 | movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */ | 1251 | movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */ |
| 1252 | .else | ||
| 1253 | xorl %esi,%esi /* no error code */ | ||
| 1254 | .endif | ||
| 1255 | |||
| 1256 | .if \shift_ist != -1 | ||
| 1257 | subq $EXCEPTION_STKSZ, INIT_TSS_IST(\shift_ist) | ||
| 1258 | .endif | ||
| 1259 | |||
| 1275 | call \do_sym | 1260 | call \do_sym |
| 1261 | |||
| 1262 | .if \shift_ist != -1 | ||
| 1263 | addq $EXCEPTION_STKSZ, INIT_TSS_IST(\shift_ist) | ||
| 1264 | .endif | ||
| 1265 | |||
| 1266 | .if \paranoid | ||
| 1267 | jmp paranoid_exit /* %ebx: no swapgs flag */ | ||
| 1268 | .else | ||
| 1276 | jmp error_exit /* %ebx: no swapgs flag */ | 1269 | jmp error_exit /* %ebx: no swapgs flag */ |
| 1270 | .endif | ||
| 1271 | |||
| 1277 | CFI_ENDPROC | 1272 | CFI_ENDPROC |
| 1278 | END(\sym) | 1273 | END(\sym) |
| 1279 | .endm | 1274 | .endm |
| 1280 | 1275 | ||
| 1281 | #ifdef CONFIG_TRACING | 1276 | #ifdef CONFIG_TRACING |
| 1282 | .macro trace_errorentry sym do_sym | 1277 | .macro trace_idtentry sym do_sym has_error_code:req |
| 1283 | errorentry trace(\sym) trace(\do_sym) | 1278 | idtentry trace(\sym) trace(\do_sym) has_error_code=\has_error_code |
| 1284 | errorentry \sym \do_sym | 1279 | idtentry \sym \do_sym has_error_code=\has_error_code |
| 1285 | .endm | 1280 | .endm |
| 1286 | #else | 1281 | #else |
| 1287 | .macro trace_errorentry sym do_sym | 1282 | .macro trace_idtentry sym do_sym has_error_code:req |
| 1288 | errorentry \sym \do_sym | 1283 | idtentry \sym \do_sym has_error_code=\has_error_code |
| 1289 | .endm | 1284 | .endm |
| 1290 | #endif | 1285 | #endif |
| 1291 | 1286 | ||
| 1292 | /* error code is on the stack already */ | 1287 | idtentry divide_error do_divide_error has_error_code=0 |
| 1293 | .macro paranoiderrorentry sym do_sym | 1288 | idtentry overflow do_overflow has_error_code=0 |
| 1294 | ENTRY(\sym) | 1289 | idtentry bounds do_bounds has_error_code=0 |
| 1295 | XCPT_FRAME | 1290 | idtentry invalid_op do_invalid_op has_error_code=0 |
| 1296 | ASM_CLAC | 1291 | idtentry device_not_available do_device_not_available has_error_code=0 |
| 1297 | PARAVIRT_ADJUST_EXCEPTION_FRAME | 1292 | idtentry double_fault do_double_fault has_error_code=1 paranoid=1 |
| 1298 | subq $ORIG_RAX-R15, %rsp | 1293 | idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 |
| 1299 | CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 | 1294 | idtentry invalid_TSS do_invalid_TSS has_error_code=1 |
| 1300 | call save_paranoid | 1295 | idtentry segment_not_present do_segment_not_present has_error_code=1 |
| 1301 | DEFAULT_FRAME 0 | 1296 | idtentry spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 |
| 1302 | TRACE_IRQS_OFF | 1297 | idtentry coprocessor_error do_coprocessor_error has_error_code=0 |
| 1303 | movq %rsp,%rdi /* pt_regs pointer */ | 1298 | idtentry alignment_check do_alignment_check has_error_code=1 |
| 1304 | movq ORIG_RAX(%rsp),%rsi /* get error code */ | 1299 | idtentry simd_coprocessor_error do_simd_coprocessor_error has_error_code=0 |
| 1305 | movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */ | ||
| 1306 | call \do_sym | ||
| 1307 | jmp paranoid_exit /* %ebx: no swapgs flag */ | ||
| 1308 | CFI_ENDPROC | ||
| 1309 | END(\sym) | ||
| 1310 | .endm | ||
| 1311 | |||
| 1312 | zeroentry divide_error do_divide_error | ||
| 1313 | zeroentry overflow do_overflow | ||
| 1314 | zeroentry bounds do_bounds | ||
| 1315 | zeroentry invalid_op do_invalid_op | ||
| 1316 | zeroentry device_not_available do_device_not_available | ||
| 1317 | paranoiderrorentry double_fault do_double_fault | ||
| 1318 | zeroentry coprocessor_segment_overrun do_coprocessor_segment_overrun | ||
| 1319 | errorentry invalid_TSS do_invalid_TSS | ||
| 1320 | errorentry segment_not_present do_segment_not_present | ||
| 1321 | zeroentry spurious_interrupt_bug do_spurious_interrupt_bug | ||
| 1322 | zeroentry coprocessor_error do_coprocessor_error | ||
| 1323 | errorentry alignment_check do_alignment_check | ||
| 1324 | zeroentry simd_coprocessor_error do_simd_coprocessor_error | ||
| 1325 | 1300 | ||
| 1326 | 1301 | ||
| 1327 | /* Reload gs selector with exception handling */ | 1302 | /* Reload gs selector with exception handling */ |
| @@ -1371,7 +1346,7 @@ ENTRY(do_softirq_own_stack) | |||
| 1371 | END(do_softirq_own_stack) | 1346 | END(do_softirq_own_stack) |
| 1372 | 1347 | ||
| 1373 | #ifdef CONFIG_XEN | 1348 | #ifdef CONFIG_XEN |
| 1374 | zeroentry xen_hypervisor_callback xen_do_hypervisor_callback | 1349 | idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0 |
| 1375 | 1350 | ||
| 1376 | /* | 1351 | /* |
| 1377 | * A note on the "critical region" in our callback handler. | 1352 | * A note on the "critical region" in our callback handler. |
| @@ -1482,21 +1457,21 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \ | |||
| 1482 | */ | 1457 | */ |
| 1483 | .pushsection .kprobes.text, "ax" | 1458 | .pushsection .kprobes.text, "ax" |
| 1484 | 1459 | ||
| 1485 | paranoidzeroentry_ist debug do_debug DEBUG_STACK | 1460 | idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK |
| 1486 | paranoidzeroentry_ist int3 do_int3 DEBUG_STACK | 1461 | idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK |
| 1487 | paranoiderrorentry stack_segment do_stack_segment | 1462 | idtentry stack_segment do_stack_segment has_error_code=1 paranoid=1 |
| 1488 | #ifdef CONFIG_XEN | 1463 | #ifdef CONFIG_XEN |
| 1489 | zeroentry xen_debug do_debug | 1464 | idtentry xen_debug do_debug has_error_code=0 |
| 1490 | zeroentry xen_int3 do_int3 | 1465 | idtentry xen_int3 do_int3 has_error_code=0 |
| 1491 | errorentry xen_stack_segment do_stack_segment | 1466 | idtentry xen_stack_segment do_stack_segment has_error_code=1 |
| 1492 | #endif | 1467 | #endif |
| 1493 | errorentry general_protection do_general_protection | 1468 | idtentry general_protection do_general_protection has_error_code=1 |
| 1494 | trace_errorentry page_fault do_page_fault | 1469 | trace_idtentry page_fault do_page_fault has_error_code=1 |
| 1495 | #ifdef CONFIG_KVM_GUEST | 1470 | #ifdef CONFIG_KVM_GUEST |
| 1496 | errorentry async_page_fault do_async_page_fault | 1471 | idtentry async_page_fault do_async_page_fault has_error_code=1 |
| 1497 | #endif | 1472 | #endif |
| 1498 | #ifdef CONFIG_X86_MCE | 1473 | #ifdef CONFIG_X86_MCE |
| 1499 | paranoidzeroentry machine_check *machine_check_vector(%rip) | 1474 | idtentry machine_check has_error_code=0 paranoid=1 do_sym=*machine_check_vector(%rip) |
| 1500 | #endif | 1475 | #endif |
| 1501 | 1476 | ||
| 1502 | /* | 1477 | /* |
