Skip to content

Commit c505b0d

Browse files
committed
ARC: entry: rework (non-functional)
- comments update - rename syscall_trace_entry - use PT_xxx in entry code Signed-off-by: Vineet Gupta <[email protected]>
1 parent fd47619 commit c505b0d

File tree

6 files changed

+39
-37
lines changed

6 files changed

+39
-37
lines changed

arch/arc/include/asm/entry-arcv2.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@
4848
/*------------------------------------------------------------------------*/
4949
.macro INTERRUPT_PROLOGUE
5050

51-
; (A) Before jumping to Interrupt Vector, hardware micro-ops did following:
51+
; Before jumping to Interrupt Vector, hardware micro-ops did following:
5252
; 1. SP auto-switched to kernel mode stack
5353
; 2. STATUS32.Z flag set if in U mode at time of interrupt (U:1,K:0)
5454
; 3. Auto save: (mandatory) Push PC and STAT32 on stack
5555
; hardware does even if CONFIG_ARC_IRQ_NO_AUTOSAVE
56-
; 4. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI
56+
; 4a. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI
5757
;
58-
; (B) Manually saved some regs: r12,r30, sp,fp,gp, ACCL pair
58+
; Now
59+
; 4b. If Auto-save (optional) not enabled in hw, manually save them
60+
; 5. Manually save: r12,r30, sp,fp,gp, ACCL pair
61+
;
62+
; At the end, SP points to pt_regs
5963

6064
#ifdef CONFIG_ARC_IRQ_NO_AUTOSAVE
6165
; carve pt_regs on stack (case #3), PC/STAT32 already on stack
@@ -73,13 +77,14 @@
7377
/*------------------------------------------------------------------------*/
7478
.macro EXCEPTION_PROLOGUE
7579

76-
; (A) Before jumping to Exception Vector, hardware micro-ops did following:
80+
; Before jumping to Exception Vector, hardware micro-ops did following:
7781
; 1. SP auto-switched to kernel mode stack
7882
; 2. STATUS32.Z flag set if in U mode at time of exception (U:1,K:0)
7983
;
80-
; (B) Manually save the complete reg file below
84+
; Now manually save rest of reg file
85+
; At the end, SP points to pt_regs
8186

82-
sub sp, sp, SZ_PT_REGS ; carve pt_regs
87+
sub sp, sp, SZ_PT_REGS ; carve space for pt_regs
8388

8489
; _HARD saves r10 clobbered by _SOFT as scratch hence comes first
8590

@@ -136,8 +141,8 @@
136141

137142
ST2 gp, fp, PT_r26 ; gp (r26), fp (r27)
138143

139-
st r12, [sp, PT_sp + 4]
140-
st r30, [sp, PT_sp + 8]
144+
st r12, [sp, PT_r12]
145+
st r30, [sp, PT_r30]
141146

142147
; Saving pt_regs->sp correctly requires some extra work due to the way
143148
; Auto stack switch works
@@ -244,7 +249,7 @@
244249

245250
btst r0, STATUS_U_BIT ; Z flag set if K, used in restoring SP
246251

247-
ld r10, [sp, PT_event + 4]
252+
ld r10, [sp, PT_bta]
248253
sr r10, [erbta]
249254

250255
LD2 r10, r11, PT_ret

arch/arc/include/asm/entry-compact.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@
170170
PUSHAX erbta
171171

172172
lr r10, [ecr]
173-
st r10, [sp, PT_event] /* EV_Trap expects r10 to have ECR */
173+
st r10, [sp, PT_event]
174174

175175
#ifdef CONFIG_ARC_CURR_IN_REG
176176
/* gp already saved on stack: now load with "current" */
177177
GET_CURR_TASK_ON_CPU gp
178178
#endif
179+
; OUTPUT: r10 has ECR expected by EV_Trap
179180
.endm
180181

181182
/*--------------------------------------------------------------

arch/arc/include/asm/ptrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct pt_regs {
7575
unsigned long event;
7676
};
7777

78-
unsigned long bta; /* bta_l1, bta_l2, erbta */
78+
unsigned long bta; /* erbta */
7979

8080
unsigned long r26; /* gp */
8181
unsigned long fp;

arch/arc/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int main(void)
4747

4848
DEFINE(PT_status32, offsetof(struct pt_regs, status32));
4949
DEFINE(PT_event, offsetof(struct pt_regs, event));
50+
DEFINE(PT_bta, offsetof(struct pt_regs, bta));
5051
DEFINE(PT_sp, offsetof(struct pt_regs, sp));
5152
DEFINE(PT_r0, offsetof(struct pt_regs, r0));
5253
DEFINE(PT_r1, offsetof(struct pt_regs, r1));

arch/arc/kernel/entry.S

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,19 @@ END(EV_Extension)
160160
; syscall Tracing
161161
; ---------------------------------------------
162162
tracesys:
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

195194
tracesys_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
; ---------------------------------------------
207207
trap_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

arch/arc/kernel/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ long arch_ptrace(struct task_struct *child, long request,
339339
return ret;
340340
}
341341

342-
asmlinkage int syscall_trace_entry(struct pt_regs *regs)
342+
asmlinkage int syscall_trace_enter(struct pt_regs *regs)
343343
{
344344
if (test_thread_flag(TIF_SYSCALL_TRACE))
345345
if (ptrace_report_syscall_entry(regs))

0 commit comments

Comments
 (0)