1 #ifndef ASM_SANITY_CHECK_H
2 #define ASM_SANITY_CHECK_H
4 #include "globalconfig.h"
8 #define kdb_ke_asm(msg) \
14 //.macro REGS this_ptr, dst
15 // leal (THREAD_BLOCK_SIZE - OFS__ENTRY_FRAME__MAX)(\this_ptr), \dst
18 #ifdef CONFIG_BEFORE_IRET_SANITY
20 // some sanity checks before return to user
21 // touches ecx and the thread-stack
22 .macro CHECK_SANITY csseg
25 // don't check if we return to kernelmode
35 // are we holding locks?
36 cmpl $0, OFS__THREAD__LOCK_CNT(%ebx)
39 1: kdb_ke_asm("Before IRET: Thread holds a lock")
44 // check for the right thread state
45 // (cancel and fpu_owner might also be set)
46 movl OFS__THREAD__STATE(%ebx), %edx
47 andl $~(Thread_cancel | Thread_fpu_owner | Thread_alien_or_vcpu_user | Thread_dis_alien), %edx
48 cmpl $(Thread_ready), %edx
51 1: kdb_ke_asm("Before IRET: Wrong thread state")
62 #else // ! DO_SANITY_CHECKS_BEFORE_IRET
64 .macro CHECK_SANITY csseg
67 #endif // DO_SANITY_CHECKS_BEFORE_IRET
69 #endif // ASM_SANITY_CHECK_H