@@ -160,20 +160,19 @@ END(EV_Extension)
160160; syscall Tracing
161161; ---------------------------------------------
162162tracesys:
163- ; save EFA in case tracer wants the PC of traced task
164- ; using ERET won't work since next-PC has already committed
163+ ; safekeep EFA (r12) if syscall tracer wanted PC
164+ ; for traps, ERET is pre-commit so points to next-PC
165165 GET_CURR_TASK_FIELD_PTR TASK_THREAD , r11
166166 st r12 , [ r11 , THREAD_FAULT_ADDR ] ; thread.fault_address
167167
168- ; PRE Sys Call Ptrace hook
169- mov r0 , sp ; pt_regs needed
170- bl @syscall_trace_entry
168+ ; PRE syscall trace hook
169+ mov r0 , sp ; pt_regs
170+ bl @syscall_trace_enter
171171
172172 ; Tracing code now returns the syscall num (orig or modif)
173173 mov r8 , r0
174174
175175 ; Do the Sys Call as we normally would.
176- ; Validate the Sys Call number
177176 cmp r8 , NR_syscalls - 1
178177 mov .hi r0 , - ENOSYS
179178 bhi tracesys_exit
@@ -190,36 +189,36 @@ tracesys:
190189 ld r6 , [ sp , PT_r6 ]
191190 ld r7 , [ sp , PT_r7 ]
192191 ld.as r9 , [ sys_call_table , r8 ]
193- jl [ r9 ] ; Entry into Sys Call Handler
192+ jl [ r9 ]
194193
195194tracesys_exit:
196- st r0 , [ sp , PT_r0 ] ; sys call return value in pt_regs
195+ st r0 , [ sp , PT_r0 ]
197196
198- ;POST Sys Call Ptrace Hook
197+ ; POST syscall trace hook
199198 mov r0 , sp ; pt_regs needed
200199 bl @syscall_trace_exit
201- b ret_from_exception ; NOT ret_from_system_call at is saves r0 which
202- ; we'd done before calling post hook above
200+
201+ ; don't call ret_from_system_call as it saves r0, already done above
202+ b ret_from_exception
203203
204204; ---------------------------------------------
205205; Breakpoint TRAP
206206; ---------------------------------------------
207207trap_with_param:
208208 mov r0 , r12 ; EFA in case ptracer/gdb wants stop_pc
209- mov r1 , sp
209+ mov r1 , sp ; pt_regs
210210
211- ; Save callee regs in case gdb wants to have a look
212- ; SP will grow up by size of CALLEE Reg-File
211+ ; save callee regs in case tracer/gdb wants to peek
213212 SAVE_CALLEE_SAVED_USER
214213
215- ; save location of saved Callee Regs @ thread_struct->pc
214+ ; safekeep ref to callee regs
216215 GET_CURR_TASK_FIELD_PTR TASK_THREAD , r10
217216 st sp , [ r10 , THREAD_CALLEE_REG ]
218217
219- ; Call the trap handler
218+ ; call the non syscall trap handler
220219 bl do_non_swi_trap
221220
222- ; unwind stack to discard Callee saved Regs
221+ ; unwind stack to discard callee regs
223222 DISCARD_CALLEE_SAVED_USER
224223
225224 b ret_from_exception
@@ -237,31 +236,27 @@ ENTRY(EV_Trap)
237236
238237 FAKE_RET_FROM_EXCPN
239238
240- ;============ TRAP 1 :breakpoints
241- ; Check ECR for trap with arg (PROLOGUE ensures r10 has ECR)
239+ ;============ TRAP N : breakpoints, kprobes etc
242240 bmsk.f 0 , r10 , 7
243241 bnz trap_with_param
244242
245- ;============ TRAP (no param): syscall top level
243+ ;============ TRAP 0 (no param): syscall
246244
247- ; If syscall tracing ongoing, invoke pre-post-hooks
245+ ; syscall tracing ongoing, invoke pre-post-hooks around syscall
248246 GET_CURR_THR_INFO_FLAGS r10
249247 and .f 0 , r10 , _TIF_SYSCALL_WORK
250248 bnz tracesys ; this never comes back
251249
252250 ;============ Normal syscall case
253251
254- ; syscall num shd not exceed the total system calls avail
255252 cmp r8 , NR_syscalls - 1
256253 mov .hi r0 , - ENOSYS
257254 bhi .Lret_from_system_call
258255
259- ; Offset into the syscall_table and call handler
260256 ld.as r9 ,[ sys_call_table , r8 ]
261- jl [ r9 ] ; Entry into Sys Call Handler
257+ jl [ r9 ]
262258
263259.Lret_from_system_call:
264-
265260 st r0 , [ sp , PT_r0 ] ; sys call return value in pt_regs
266261
267262 ; fall through to ret_from_exception
0 commit comments