I am trying to implement a system call counter, and as a result, I have included the int value in task_struct and a function that increments it in a separate file. This function is supposed to be called from system_call just before it actually calls the required sys_call (I have reasons to call it before, not after). However, if I placed it in front of sys_call, then after compilation and loading there was a kernel panic ("trying to kill init_idle"), and if I placed it right after sys_call, it will work. What is the difference and how can I overcome it?
Here is the corresponding code
ENTRY(system_call)
pushl %eax # save orig_eax
SAVE_ALL
GET_CURRENT(%ebx)
testb $0x02,tsk_ptrace(%ebx) # PT_TRACESYS
jne tracesys
cmpl $(NR_syscalls),%eax
jae badsys
call update_counter /*This causes a kernel panic*/
call *SYMBOL_NAME(sys_call_table)(,%eax,4)
movl %eax,EAX(%esp) # save the return value
source
share