Skip to content

Commit ecd3d4b

Browse files
jkkmKyle McMartin
authored andcommitted
parisc: stop using task->ptrace for {single,block}step flags
task->ptrace flags belong to generic code, so instead thief some TIF_ bits to use. Somewhat risky conversion of code to test TASK_FLAGS instead of TASK_PTRACE in assembly, but it looks alright in the end. Signed-off-by: Kyle McMartin <[email protected]>
1 parent 2798af1 commit ecd3d4b

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

arch/parisc/include/asm/thread_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ struct thread_info {
6060
#define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */
6161
#define TIF_FREEZE 7 /* is freezing for suspend */
6262
#define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
63+
#define TIF_SINGLESTEP 9 /* single stepping? */
64+
#define TIF_BLOCKSTEP 10 /* branch stepping? */
6365

6466
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
6567
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
@@ -69,6 +71,8 @@ struct thread_info {
6971
#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
7072
#define _TIF_FREEZE (1 << TIF_FREEZE)
7173
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
74+
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
75+
#define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)
7276

7377
#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \
7478
_TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)

arch/parisc/kernel/asm-offsets.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ int main(void)
270270
DEFINE(DTLB_OFF_COUNT, offsetof(struct pdc_cache_info, dt_off_count));
271271
DEFINE(DTLB_LOOP, offsetof(struct pdc_cache_info, dt_loop));
272272
BLANK();
273-
DEFINE(PA_BLOCKSTEP_BIT, 31-PT_BLOCKSTEP_BIT);
274-
DEFINE(PA_SINGLESTEP_BIT, 31-PT_SINGLESTEP_BIT);
273+
DEFINE(TIF_BLOCKSTEP_PA_BIT, 31-TIF_BLOCKSTEP);
274+
DEFINE(TIF_SINGLESTEP_PA_BIT, 31-TIF_SINGLESTEP);
275275
BLANK();
276276
DEFINE(ASM_PMD_SHIFT, PMD_SHIFT);
277277
DEFINE(ASM_PGDIR_SHIFT, PGDIR_SHIFT);

arch/parisc/kernel/entry.S

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,12 +2047,13 @@ syscall_do_signal:
20472047
b,n syscall_check_sig
20482048

20492049
syscall_restore:
2050-
/* Are we being ptraced? */
20512050
LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
20522051

2053-
ldw TASK_PTRACE(%r1), %r19
2054-
bb,< %r19,31,syscall_restore_rfi
2055-
nop
2052+
/* Are we being ptraced? */
2053+
ldw TASK_FLAGS(%r1),%r19
2054+
ldi (_TIF_SINGLESTEP|_TIF_BLOCKSTEP),%r2
2055+
and,COND(=) %r19,%r2,%r0
2056+
b,n syscall_restore_rfi
20562057

20572058
ldo TASK_PT_FR31(%r1),%r19 /* reload fpregs */
20582059
rest_fp %r19
@@ -2113,16 +2114,16 @@ syscall_restore_rfi:
21132114
ldi 0x0b,%r20 /* Create new PSW */
21142115
depi -1,13,1,%r20 /* C, Q, D, and I bits */
21152116

2116-
/* The values of PA_SINGLESTEP_BIT and PA_BLOCKSTEP_BIT are
2117-
* set in include/linux/ptrace.h and converted to PA bitmap
2117+
/* The values of SINGLESTEP_BIT and BLOCKSTEP_BIT are
2118+
* set in thread_info.h and converted to PA bitmap
21182119
* numbers in asm-offsets.c */
21192120

2120-
/* if ((%r19.PA_SINGLESTEP_BIT)) { %r20.27=1} */
2121-
extru,= %r19,PA_SINGLESTEP_BIT,1,%r0
2121+
/* if ((%r19.SINGLESTEP_BIT)) { %r20.27=1} */
2122+
extru,= %r19,TIF_SINGLESTEP_PA_BIT,1,%r0
21222123
depi -1,27,1,%r20 /* R bit */
21232124

2124-
/* if ((%r19.PA_BLOCKSTEP_BIT)) { %r20.7=1} */
2125-
extru,= %r19,PA_BLOCKSTEP_BIT,1,%r0
2125+
/* if ((%r19.BLOCKSTEP_BIT)) { %r20.7=1} */
2126+
extru,= %r19,TIF_BLOCKSTEP_PA_BIT,1,%r0
21262127
depi -1,7,1,%r20 /* T bit */
21272128

21282129
STREG %r20,TASK_PT_PSW(%r1)

arch/parisc/kernel/ptrace.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
*/
3737
void ptrace_disable(struct task_struct *task)
3838
{
39-
task->ptrace &= ~(PT_SINGLESTEP|PT_BLOCKSTEP);
39+
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
40+
clear_tsk_thread_flag(task, TIF_BLOCKSTEP);
4041

4142
/* make sure the trap bits are not set */
4243
pa_psw(task)->r = 0;
@@ -56,8 +57,8 @@ void user_disable_single_step(struct task_struct *task)
5657

5758
void user_enable_single_step(struct task_struct *task)
5859
{
59-
task->ptrace &= ~PT_BLOCKSTEP;
60-
task->ptrace |= PT_SINGLESTEP;
60+
clear_tsk_thread_flag(task, TIF_BLOCKSTEP);
61+
set_tsk_thread_flag(task, TIF_SINGLESTEP);
6162

6263
if (pa_psw(task)->n) {
6364
struct siginfo si;
@@ -99,8 +100,8 @@ void user_enable_single_step(struct task_struct *task)
99100

100101
void user_enable_block_step(struct task_struct *task)
101102
{
102-
task->ptrace &= ~PT_SINGLESTEP;
103-
task->ptrace |= PT_BLOCKSTEP;
103+
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
104+
set_tsk_thread_flag(task, TIF_BLOCKSTEP);
104105

105106
/* Enable taken branch trap. */
106107
pa_psw(task)->r = 0;
@@ -275,7 +276,8 @@ long do_syscall_trace_enter(struct pt_regs *regs)
275276

276277
void do_syscall_trace_exit(struct pt_regs *regs)
277278
{
278-
int stepping = !!(current->ptrace & (PT_SINGLESTEP|PT_BLOCKSTEP));
279+
int stepping = test_thread_flag(TIF_SINGLESTEP) ||
280+
test_thread_flag(TIF_BLOCKSTEP);
279281

280282
if (stepping || test_thread_flag(TIF_SYSCALL_TRACE))
281283
tracehook_report_syscall_exit(regs, stepping);

0 commit comments

Comments
 (0)