Commit 3b66a1ed authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] m68k: convert thread flags to use bit fields

Remove task_work structure, use the standard thread flags functions and use
shifts in entry.S to test the thread flags.  Add a few local labels to entry.S
to allow gas to generate short jumps.

Finally it changes a number of inline functions in thread_info.h to macros to
delay the current_thread_info() usage, which requires on m68k a structure
(task_struct) not yet defined at this point.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Cc: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent abd03753
...@@ -381,10 +381,8 @@ fpsp_done: ...@@ -381,10 +381,8 @@ fpsp_done:
.Lnotkern: .Lnotkern:
SAVE_ALL_INT SAVE_ALL_INT
GET_CURRENT(%d0) GET_CURRENT(%d0)
tstb %curptr@(TASK_NEEDRESCHED) | deliver signals, reschedule etc..
jne ret_from_exception | deliver signals, jra ret_from_exception
| reschedule etc..
RESTORE_ALL
| |
| mem_write --- write to user or supervisor address space | mem_write --- write to user or supervisor address space
......
...@@ -75,10 +75,8 @@ _060_isp_done: ...@@ -75,10 +75,8 @@ _060_isp_done:
.Lnotkern: .Lnotkern:
SAVE_ALL_INT SAVE_ALL_INT
GET_CURRENT(%d0) GET_CURRENT(%d0)
tstb %curptr@(TASK_NEEDRESCHED) | deliver signals, reschedule etc..
jne ret_from_exception | deliver signals, jra ret_from_exception
| reschedule etc..
RESTORE_ALL
| |
| _060_real_chk(): | _060_real_chk():
......
...@@ -25,11 +25,6 @@ int main(void) ...@@ -25,11 +25,6 @@ int main(void)
DEFINE(TASK_STATE, offsetof(struct task_struct, state)); DEFINE(TASK_STATE, offsetof(struct task_struct, state));
DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags)); DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace)); DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
DEFINE(TASK_WORK, offsetof(struct task_struct, thread.work));
DEFINE(TASK_NEEDRESCHED, offsetof(struct task_struct, thread.work.need_resched));
DEFINE(TASK_SYSCALL_TRACE, offsetof(struct task_struct, thread.work.syscall_trace));
DEFINE(TASK_SIGPENDING, offsetof(struct task_struct, thread.work.sigpending));
DEFINE(TASK_NOTIFY_RESUME, offsetof(struct task_struct, thread.work.notify_resume));
DEFINE(TASK_THREAD, offsetof(struct task_struct, thread)); DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info)); DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info));
DEFINE(TASK_MM, offsetof(struct task_struct, mm)); DEFINE(TASK_MM, offsetof(struct task_struct, mm));
......
...@@ -44,9 +44,7 @@ ...@@ -44,9 +44,7 @@
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
.globl system_call, buserr, trap .globl system_call, buserr, trap, resume
.globl resume, ret_from_exception
.globl ret_from_signal
.globl inthandler, sys_call_table .globl inthandler, sys_call_table
.globl sys_fork, sys_clone, sys_vfork .globl sys_fork, sys_clone, sys_vfork
.globl ret_from_interrupt, bad_interrupt .globl ret_from_interrupt, bad_interrupt
...@@ -58,7 +56,7 @@ ENTRY(buserr) ...@@ -58,7 +56,7 @@ ENTRY(buserr)
movel %sp,%sp@- | stack frame pointer argument movel %sp,%sp@- | stack frame pointer argument
bsrl buserr_c bsrl buserr_c
addql #4,%sp addql #4,%sp
jra ret_from_exception jra .Lret_from_exception
ENTRY(trap) ENTRY(trap)
SAVE_ALL_INT SAVE_ALL_INT
...@@ -66,7 +64,7 @@ ENTRY(trap) ...@@ -66,7 +64,7 @@ ENTRY(trap)
movel %sp,%sp@- | stack frame pointer argument movel %sp,%sp@- | stack frame pointer argument
bsrl trap_c bsrl trap_c
addql #4,%sp addql #4,%sp
jra ret_from_exception jra .Lret_from_exception
| After a fork we jump here directly from resume, | After a fork we jump here directly from resume,
| so that %d1 contains the previous task | so that %d1 contains the previous task
...@@ -75,30 +73,31 @@ ENTRY(ret_from_fork) ...@@ -75,30 +73,31 @@ ENTRY(ret_from_fork)
movel %d1,%sp@- movel %d1,%sp@-
jsr schedule_tail jsr schedule_tail
addql #4,%sp addql #4,%sp
jra ret_from_exception jra .Lret_from_exception
badsys: do_trace_entry:
movel #-ENOSYS,%sp@(PT_D0)
jra ret_from_exception
do_trace:
movel #-ENOSYS,%sp@(PT_D0) | needed for strace movel #-ENOSYS,%sp@(PT_D0) | needed for strace
subql #4,%sp subql #4,%sp
SAVE_SWITCH_STACK SAVE_SWITCH_STACK
jbsr syscall_trace jbsr syscall_trace
RESTORE_SWITCH_STACK RESTORE_SWITCH_STACK
addql #4,%sp addql #4,%sp
movel %sp@(PT_ORIG_D0),%d1 movel %sp@(PT_ORIG_D0),%d0
movel #-ENOSYS,%d0 cmpl #NR_syscalls,%d0
cmpl #NR_syscalls,%d1 jcs syscall
jcc 1f badsys:
jbsr @(sys_call_table,%d1:l:4)@(0) movel #-ENOSYS,%sp@(PT_D0)
1: movel %d0,%sp@(PT_D0) | save the return value jra ret_from_syscall
subql #4,%sp | dummy return address
do_trace_exit:
subql #4,%sp
SAVE_SWITCH_STACK SAVE_SWITCH_STACK
jbsr syscall_trace jbsr syscall_trace
RESTORE_SWITCH_STACK
addql #4,%sp
jra .Lret_from_exception
ret_from_signal: ENTRY(ret_from_signal)
RESTORE_SWITCH_STACK RESTORE_SWITCH_STACK
addql #4,%sp addql #4,%sp
/* on 68040 complete pending writebacks if any */ /* on 68040 complete pending writebacks if any */
...@@ -111,7 +110,7 @@ ret_from_signal: ...@@ -111,7 +110,7 @@ ret_from_signal:
addql #4,%sp addql #4,%sp
1: 1:
#endif #endif
jra ret_from_exception jra .Lret_from_exception
ENTRY(system_call) ENTRY(system_call)
SAVE_ALL_SYS SAVE_ALL_SYS
...@@ -120,30 +119,34 @@ ENTRY(system_call) ...@@ -120,30 +119,34 @@ ENTRY(system_call)
| save top of frame | save top of frame
movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0) movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
tstb %curptr@(TASK_SYSCALL_TRACE) | syscall trace?
jne do_trace tstb %curptr@(TASK_INFO+TINFO_FLAGS+2)
jmi do_trace_entry
cmpl #NR_syscalls,%d0 cmpl #NR_syscalls,%d0
jcc badsys jcc badsys
syscall:
jbsr @(sys_call_table,%d0:l:4)@(0) jbsr @(sys_call_table,%d0:l:4)@(0)
movel %d0,%sp@(PT_D0) | save the return value movel %d0,%sp@(PT_D0) | save the return value
ret_from_syscall:
|oriw #0x0700,%sr |oriw #0x0700,%sr
movel %curptr@(TASK_WORK),%d0 movew %curptr@(TASK_INFO+TINFO_FLAGS+2),%d0
jne syscall_exit_work jne syscall_exit_work
1: RESTORE_ALL 1: RESTORE_ALL
syscall_exit_work: syscall_exit_work:
btst #5,%sp@(PT_SR) | check if returning to kernel btst #5,%sp@(PT_SR) | check if returning to kernel
bnes 1b | if so, skip resched, signals bnes 1b | if so, skip resched, signals
tstw %d0 lslw #1,%d0
jeq do_signal_return jcs do_trace_exit
tstb %d0 jmi do_delayed_trace
jne do_delayed_trace lslw #8,%d0
jmi do_signal_return
pea resume_userspace pea resume_userspace
jmp schedule jra schedule
ret_from_exception: ENTRY(ret_from_exception)
.Lret_from_exception:
btst #5,%sp@(PT_SR) | check if returning to kernel btst #5,%sp@(PT_SR) | check if returning to kernel
bnes 1f | if so, skip resched, signals bnes 1f | if so, skip resched, signals
| only allow interrupts when we are really the last one on the | only allow interrupts when we are really the last one on the
...@@ -152,19 +155,18 @@ ret_from_exception: ...@@ -152,19 +155,18 @@ ret_from_exception:
andw #ALLOWINT,%sr andw #ALLOWINT,%sr
resume_userspace: resume_userspace:
movel %curptr@(TASK_WORK),%d0 moveb %curptr@(TASK_INFO+TINFO_FLAGS+3),%d0
lsrl #8,%d0
jne exit_work jne exit_work
1: RESTORE_ALL 1: RESTORE_ALL
exit_work: exit_work:
| save top of frame | save top of frame
movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0) movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0)
tstb %d0 lslb #1,%d0
jeq do_signal_return jmi do_signal_return
pea resume_userspace pea resume_userspace
jmp schedule jra schedule
do_signal_return: do_signal_return:
|andw #ALLOWINT,%sr |andw #ALLOWINT,%sr
...@@ -254,7 +256,7 @@ ret_from_interrupt: ...@@ -254,7 +256,7 @@ ret_from_interrupt:
/* check if we need to do software interrupts */ /* check if we need to do software interrupts */
tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING tstl irq_stat+CPUSTAT_SOFTIRQ_PENDING
jeq ret_from_exception jeq .Lret_from_exception
pea ret_from_exception pea ret_from_exception
jra do_softirq jra do_softirq
......
...@@ -109,7 +109,7 @@ static inline void singlestep_disable(struct task_struct *child) ...@@ -109,7 +109,7 @@ static inline void singlestep_disable(struct task_struct *child)
{ {
unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
put_reg(child, PT_SR, tmp); put_reg(child, PT_SR, tmp);
child->thread.work.delayed_trace = 0; clear_tsk_thread_flag(child, TIF_DELAYED_TRACE);
} }
/* /*
...@@ -118,7 +118,7 @@ static inline void singlestep_disable(struct task_struct *child) ...@@ -118,7 +118,7 @@ static inline void singlestep_disable(struct task_struct *child)
void ptrace_disable(struct task_struct *child) void ptrace_disable(struct task_struct *child)
{ {
singlestep_disable(child); singlestep_disable(child);
child->thread.work.syscall_trace = 0; clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
} }
long arch_ptrace(struct task_struct *child, long request, long addr, long data) long arch_ptrace(struct task_struct *child, long request, long addr, long data)
...@@ -198,9 +198,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -198,9 +198,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
goto out_eio; goto out_eio;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
child->thread.work.syscall_trace = ~0; set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
else else
child->thread.work.syscall_trace = 0; clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
child->exit_code = data; child->exit_code = data;
singlestep_disable(child); singlestep_disable(child);
wake_up_process(child); wake_up_process(child);
...@@ -223,10 +223,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -223,10 +223,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
if (!valid_signal(data)) if (!valid_signal(data))
goto out_eio; goto out_eio;
child->thread.work.syscall_trace = 0; clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
put_reg(child, PT_SR, tmp); put_reg(child, PT_SR, tmp);
child->thread.work.delayed_trace = 1; set_tsk_thread_flag(child, TIF_DELAYED_TRACE);
child->exit_code = data; child->exit_code = data;
/* give it a chance to run. */ /* give it a chance to run. */
...@@ -288,9 +288,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -288,9 +288,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
asmlinkage void syscall_trace(void) asmlinkage void syscall_trace(void)
{ {
if (!current->thread.work.delayed_trace &&
!current->thread.work.syscall_trace)
return;
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
? 0x80 : 0)); ? 0x80 : 0));
/* /*
......
...@@ -56,17 +56,6 @@ static inline void wrusp(unsigned long usp) ...@@ -56,17 +56,6 @@ static inline void wrusp(unsigned long usp)
#endif #endif
#define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr) #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
struct task_work {
unsigned char sigpending;
unsigned char notify_resume; /* request for notification on
userspace execution resumption */
char need_resched;
unsigned char delayed_trace; /* single step a syscall */
unsigned char syscall_trace; /* count of syscall interceptors */
unsigned char memdie; /* task was selected to be killed */
unsigned char pad[2];
};
struct thread_struct { struct thread_struct {
unsigned long ksp; /* kernel stack pointer */ unsigned long ksp; /* kernel stack pointer */
unsigned long usp; /* user stack pointer */ unsigned long usp; /* user stack pointer */
...@@ -79,7 +68,6 @@ struct thread_struct { ...@@ -79,7 +68,6 @@ struct thread_struct {
unsigned long fp[8*3]; unsigned long fp[8*3];
unsigned long fpcntl[3]; /* fp control regs */ unsigned long fpcntl[3]; /* fp control regs */
unsigned char fpstate[FPSTATESIZE]; /* floating point state */ unsigned char fpstate[FPSTATESIZE]; /* floating point state */
struct task_work work;
struct thread_info info; struct thread_info info;
}; };
......
...@@ -6,12 +6,11 @@ ...@@ -6,12 +6,11 @@
struct thread_info { struct thread_info {
struct task_struct *task; /* main task structure */ struct task_struct *task; /* main task structure */
unsigned long flags;
struct exec_domain *exec_domain; /* execution domain */ struct exec_domain *exec_domain; /* execution domain */
int preempt_count; /* 0 => preemptable, <0 => BUG */ int preempt_count; /* 0 => preemptable, <0 => BUG */
__u32 cpu; /* should always be 0 on m68k */ __u32 cpu; /* should always be 0 on m68k */
struct restart_block restart_block; struct restart_block restart_block;
__u8 supervisor_stack[0];
}; };
#define PREEMPT_ACTIVE 0x4000000 #define PREEMPT_ACTIVE 0x4000000
...@@ -49,76 +48,14 @@ struct thread_info { ...@@ -49,76 +48,14 @@ struct thread_info {
#define end_of_stack(p) ((unsigned long *)(p)->thread_info + 1) #define end_of_stack(p) ((unsigned long *)(p)->thread_info + 1)
#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ /* entry.S relies on these definitions!
#define TIF_DELAYED_TRACE 1 /* single step a syscall */ * bits 0-7 are tested at every exception exit
#define TIF_NOTIFY_RESUME 2 /* resumption notification requested */ * bits 8-15 are also tested at syscall exit
#define TIF_SIGPENDING 3 /* signal pending */
#define TIF_NEED_RESCHED 4 /* rescheduling necessary */
#define TIF_MEMDIE 5
extern int thread_flag_fixme(void);
/*
* flag set/clear/test wrappers
* - pass TIF_xxxx constants to these functions
*/ */
#define TIF_SIGPENDING 6 /* signal pending */
#define __set_tsk_thread_flag(tsk, flag, val) ({ \ #define TIF_NEED_RESCHED 7 /* rescheduling necessary */
switch (flag) { \ #define TIF_DELAYED_TRACE 14 /* single step a syscall */
case TIF_SIGPENDING: \ #define TIF_SYSCALL_TRACE 15 /* syscall trace active */
tsk->thread.work.sigpending = val; \ #define TIF_MEMDIE 16
break; \
case TIF_NEED_RESCHED: \
tsk->thread.work.need_resched = val; \
break; \
case TIF_SYSCALL_TRACE: \
tsk->thread.work.syscall_trace = val; \
break; \
case TIF_MEMDIE: \
tsk->thread.work.memdie = val; \
break; \
default: \
thread_flag_fixme(); \
} \
})
#define __get_tsk_thread_flag(tsk, flag) ({ \
int ___res; \
switch (flag) { \
case TIF_SIGPENDING: \
___res = tsk->thread.work.sigpending; \
break; \
case TIF_NEED_RESCHED: \
___res = tsk->thread.work.need_resched; \
break; \
case TIF_SYSCALL_TRACE: \
___res = tsk->thread.work.syscall_trace;\
break; \
case TIF_MEMDIE: \
___res = tsk->thread.work.memdie;\
break; \
default: \
___res = thread_flag_fixme(); \
} \
___res; \
})
#define __get_set_tsk_thread_flag(tsk, flag, val) ({ \
int __res = __get_tsk_thread_flag(tsk, flag); \
__set_tsk_thread_flag(tsk, flag, val); \
__res; \
})
#define set_tsk_thread_flag(tsk, flag) __set_tsk_thread_flag(tsk, flag, ~0)
#define clear_tsk_thread_flag(tsk, flag) __set_tsk_thread_flag(tsk, flag, 0)
#define test_and_set_tsk_thread_flag(tsk, flag) __get_set_tsk_thread_flag(tsk, flag, ~0)
#define test_tsk_thread_flag(tsk, flag) __get_tsk_thread_flag(tsk, flag)
#define set_thread_flag(flag) set_tsk_thread_flag(current, flag)
#define clear_thread_flag(flag) clear_tsk_thread_flag(current, flag)
#define test_thread_flag(flag) test_tsk_thread_flag(current, flag)
#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
#endif /* _ASM_M68K_THREAD_INFO_H */ #endif /* _ASM_M68K_THREAD_INFO_H */
...@@ -27,31 +27,6 @@ extern long do_no_restart_syscall(struct restart_block *parm); ...@@ -27,31 +27,6 @@ extern long do_no_restart_syscall(struct restart_block *parm);
* - pass TIF_xxxx constants to these functions * - pass TIF_xxxx constants to these functions
*/ */
static inline void set_thread_flag(int flag)
{
set_bit(flag,&current_thread_info()->flags);
}
static inline void clear_thread_flag(int flag)
{
clear_bit(flag,&current_thread_info()->flags);
}
static inline int test_and_set_thread_flag(int flag)
{
return test_and_set_bit(flag,&current_thread_info()->flags);
}
static inline int test_and_clear_thread_flag(int flag)
{
return test_and_clear_bit(flag,&current_thread_info()->flags);
}
static inline int test_thread_flag(int flag)
{
return test_bit(flag,&current_thread_info()->flags);
}
static inline void set_ti_thread_flag(struct thread_info *ti, int flag) static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
{ {
set_bit(flag,&ti->flags); set_bit(flag,&ti->flags);
...@@ -77,15 +52,19 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag) ...@@ -77,15 +52,19 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
return test_bit(flag,&ti->flags); return test_bit(flag,&ti->flags);
} }
static inline void set_need_resched(void) #define set_thread_flag(flag) \
{ set_ti_thread_flag(current_thread_info(), flag)
set_thread_flag(TIF_NEED_RESCHED); #define clear_thread_flag(flag) \
} clear_ti_thread_flag(current_thread_info(), flag)
#define test_and_set_thread_flag(flag) \
static inline void clear_need_resched(void) test_and_set_ti_thread_flag(current_thread_info(), flag)
{ #define test_and_clear_thread_flag(flag) \
clear_thread_flag(TIF_NEED_RESCHED); test_and_clear_ti_thread_flag(current_thread_info(), flag)
} #define test_thread_flag(flag) \
test_ti_thread_flag(current_thread_info(), flag)
#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment