diff options
| author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2007-10-11 16:11:12 -0400 |
|---|---|---|
| committer | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2007-10-11 16:11:12 -0400 |
| commit | 10cd706d180b62a61aace5b440247c8785026ac1 (patch) | |
| tree | 4bc544761719fd10ecfa977e6f4bfd8f1249d8b9 | |
| parent | c7e872e7da5514d014707a407ea562d197cc0136 (diff) | |
lockdep: x86_64: connect the sysexit hook
Run the lockdep_sys_exit hook after all other C code on the syscall
return path.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | arch/x86/kernel/entry_64.S | 23 | ||||
| -rw-r--r-- | arch/x86/lib/thunk_64.S | 4 | ||||
| -rw-r--r-- | include/asm-x86/irqflags_64.h | 14 |
3 files changed, 29 insertions, 12 deletions
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 1d232e5f5658..f1cacd4897f7 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
| @@ -244,6 +244,7 @@ ret_from_sys_call: | |||
| 244 | movl $_TIF_ALLWORK_MASK,%edi | 244 | movl $_TIF_ALLWORK_MASK,%edi |
| 245 | /* edi: flagmask */ | 245 | /* edi: flagmask */ |
| 246 | sysret_check: | 246 | sysret_check: |
| 247 | LOCKDEP_SYS_EXIT | ||
| 247 | GET_THREAD_INFO(%rcx) | 248 | GET_THREAD_INFO(%rcx) |
| 248 | cli | 249 | cli |
| 249 | TRACE_IRQS_OFF | 250 | TRACE_IRQS_OFF |
| @@ -333,6 +334,7 @@ int_ret_from_sys_call: | |||
| 333 | movl $_TIF_ALLWORK_MASK,%edi | 334 | movl $_TIF_ALLWORK_MASK,%edi |
| 334 | /* edi: mask to check */ | 335 | /* edi: mask to check */ |
| 335 | int_with_check: | 336 | int_with_check: |
| 337 | LOCKDEP_SYS_EXIT_IRQ | ||
| 336 | GET_THREAD_INFO(%rcx) | 338 | GET_THREAD_INFO(%rcx) |
| 337 | movl threadinfo_flags(%rcx),%edx | 339 | movl threadinfo_flags(%rcx),%edx |
| 338 | andl %edi,%edx | 340 | andl %edi,%edx |
| @@ -544,11 +546,13 @@ exit_intr: | |||
| 544 | retint_with_reschedule: | 546 | retint_with_reschedule: |
| 545 | movl $_TIF_WORK_MASK,%edi | 547 | movl $_TIF_WORK_MASK,%edi |
| 546 | retint_check: | 548 | retint_check: |
| 549 | LOCKDEP_SYS_EXIT_IRQ | ||
| 547 | movl threadinfo_flags(%rcx),%edx | 550 | movl threadinfo_flags(%rcx),%edx |
| 548 | andl %edi,%edx | 551 | andl %edi,%edx |
| 549 | CFI_REMEMBER_STATE | 552 | CFI_REMEMBER_STATE |
| 550 | jnz retint_careful | 553 | jnz retint_careful |
| 551 | retint_swapgs: | 554 | |
| 555 | retint_swapgs: /* return to user-space */ | ||
| 552 | /* | 556 | /* |
| 553 | * The iretq could re-enable interrupts: | 557 | * The iretq could re-enable interrupts: |
| 554 | */ | 558 | */ |
| @@ -557,7 +561,7 @@ retint_swapgs: | |||
| 557 | swapgs | 561 | swapgs |
| 558 | jmp restore_args | 562 | jmp restore_args |
| 559 | 563 | ||
| 560 | retint_restore_args: | 564 | retint_restore_args: /* return to kernel space */ |
| 561 | cli | 565 | cli |
| 562 | /* | 566 | /* |
| 563 | * The iretq could re-enable interrupts: | 567 | * The iretq could re-enable interrupts: |
| @@ -866,26 +870,21 @@ error_sti: | |||
| 866 | movq ORIG_RAX(%rsp),%rsi /* get error code */ | 870 | movq ORIG_RAX(%rsp),%rsi /* get error code */ |
| 867 | movq $-1,ORIG_RAX(%rsp) | 871 | movq $-1,ORIG_RAX(%rsp) |
| 868 | call *%rax | 872 | call *%rax |
| 869 | /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */ | 873 | /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */ |
| 870 | error_exit: | 874 | error_exit: |
| 871 | movl %ebx,%eax | 875 | movl %ebx,%eax |
| 872 | RESTORE_REST | 876 | RESTORE_REST |
| 873 | cli | 877 | cli |
| 874 | TRACE_IRQS_OFF | 878 | TRACE_IRQS_OFF |
| 875 | GET_THREAD_INFO(%rcx) | 879 | GET_THREAD_INFO(%rcx) |
| 876 | testl %eax,%eax | 880 | testl %eax,%eax |
| 877 | jne retint_kernel | 881 | jne retint_kernel |
| 882 | LOCKDEP_SYS_EXIT_IRQ | ||
| 878 | movl threadinfo_flags(%rcx),%edx | 883 | movl threadinfo_flags(%rcx),%edx |
| 879 | movl $_TIF_WORK_MASK,%edi | 884 | movl $_TIF_WORK_MASK,%edi |
| 880 | andl %edi,%edx | 885 | andl %edi,%edx |
| 881 | jnz retint_careful | 886 | jnz retint_careful |
| 882 | /* | 887 | jmp retint_swapgs |
| 883 | * The iret might restore flags: | ||
| 884 | */ | ||
| 885 | TRACE_IRQS_IRETQ | ||
| 886 | swapgs | ||
| 887 | RESTORE_ARGS 0,8,0 | ||
| 888 | jmp iret_label | ||
| 889 | CFI_ENDPROC | 888 | CFI_ENDPROC |
| 890 | 889 | ||
| 891 | error_kernelspace: | 890 | error_kernelspace: |
diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S index 55e586d352d3..6ea73f3de567 100644 --- a/arch/x86/lib/thunk_64.S +++ b/arch/x86/lib/thunk_64.S | |||
| @@ -50,6 +50,10 @@ | |||
| 50 | thunk trace_hardirqs_on_thunk,trace_hardirqs_on | 50 | thunk trace_hardirqs_on_thunk,trace_hardirqs_on |
| 51 | thunk trace_hardirqs_off_thunk,trace_hardirqs_off | 51 | thunk trace_hardirqs_off_thunk,trace_hardirqs_off |
| 52 | #endif | 52 | #endif |
| 53 | |||
| 54 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 55 | thunk lockdep_sys_exit_thunk,lockdep_sys_exit | ||
| 56 | #endif | ||
| 53 | 57 | ||
| 54 | /* SAVE_ARGS below is used only for the .cfi directives it contains. */ | 58 | /* SAVE_ARGS below is used only for the .cfi directives it contains. */ |
| 55 | CFI_STARTPROC | 59 | CFI_STARTPROC |
diff --git a/include/asm-x86/irqflags_64.h b/include/asm-x86/irqflags_64.h index 86e70fe23659..5341ea1f815a 100644 --- a/include/asm-x86/irqflags_64.h +++ b/include/asm-x86/irqflags_64.h | |||
| @@ -137,6 +137,20 @@ static inline void halt(void) | |||
| 137 | # define TRACE_IRQS_ON | 137 | # define TRACE_IRQS_ON |
| 138 | # define TRACE_IRQS_OFF | 138 | # define TRACE_IRQS_OFF |
| 139 | # endif | 139 | # endif |
| 140 | # ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 141 | # define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk | ||
| 142 | # define LOCKDEP_SYS_EXIT_IRQ \ | ||
| 143 | TRACE_IRQS_ON; \ | ||
| 144 | sti; \ | ||
| 145 | SAVE_REST; \ | ||
| 146 | LOCKDEP_SYS_EXIT; \ | ||
| 147 | RESTORE_REST; \ | ||
| 148 | cli; \ | ||
| 149 | TRACE_IRQS_OFF; | ||
| 150 | # else | ||
| 151 | # define LOCKDEP_SYS_EXIT | ||
| 152 | # define LOCKDEP_SYS_EXIT_IRQ | ||
| 153 | # endif | ||
| 140 | #endif | 154 | #endif |
| 141 | 155 | ||
| 142 | #endif | 156 | #endif |
