Commit 41754b1f authored by Russell King's avatar Russell King

[ARM] Eliminate tsk->used_math

Remove usage of tsk->used_math on ARM, moving the status to an array
of co-processor usage.  (ARM can have up to 15 co-processors
providing various extra facilities such as SIMD, VFP or FP.)
parent a28efa63
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
int main(void) int main(void)
{ {
DEFINE(TSK_USED_MATH, offsetof(struct task_struct, used_math));
DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm)); DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
BLANK(); BLANK();
DEFINE(VMA_VM_MM, offsetof(struct vm_area_struct, vm_mm)); DEFINE(VMA_VM_MM, offsetof(struct vm_area_struct, vm_mm));
......
...@@ -963,23 +963,46 @@ __und_usr: sub sp, sp, #S_FRAME_SIZE @ Allocate frame size in one go ...@@ -963,23 +963,46 @@ __und_usr: sub sp, sp, #S_FRAME_SIZE @ Allocate frame size in one go
* co-processor instructions. However, we have to watch out * co-processor instructions. However, we have to watch out
* for the ARM6/ARM7 SWI bug. * for the ARM6/ARM7 SWI bug.
* *
* Emulators may wish to make use of the instruction value we * Emulators may wish to make use of the following registers:
* prepared for them in r0. * r0 - instruction opcode.
* r10 - this threads thread_info structure.
*/ */
call_fpe: enable_irq r10 @ Enable interrupts call_fpe: enable_irq r10 @ Enable interrupts
tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27 tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27
#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710) #if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
and r10, r0, #0x0f000000 @ mask out op-code bits and r8, r0, #0x0f000000 @ mask out op-code bits
teqne r10, #0x0f000000 @ SWI (ARM6/7 bug)? teqne r8, #0x0f000000 @ SWI (ARM6/7 bug)?
#endif #endif
moveq pc, lr moveq pc, lr
do_fpe: get_thread_info r10 @ get current thread get_thread_info r10 @ get current thread
ldr r4, [r10, #TI_TASK] @ get current task and r8, r0, #0x00000f00 @ mask out CP number
mov r8, #1 mov r7, #1
strb r8, [r4, #TSK_USED_MATH] @ set current->used_math add r6, r10, #TI_USED_CP
ldr r4, .LCfp strb r7, [r6, r8, lsr #8] @ set appropriate used_cp[]
add pc, pc, r8, lsr #6
mov r0, r0
mov pc, lr @ CP#0
b do_fpe @ CP#1 (FPE)
b do_fpe @ CP#2 (FPE)
mov pc, lr @ CP#3
mov pc, lr @ CP#4
mov pc, lr @ CP#5
mov pc, lr @ CP#6
mov pc, lr @ CP#7
mov pc, lr @ CP#8
mov pc, lr @ CP#9
mov pc, lr @ CP#10 (VFP)
mov pc, lr @ CP#11 (VFP)
mov pc, lr @ CP#12
mov pc, lr @ CP#13
mov pc, lr @ CP#14 (Debug)
mov pc, lr @ CP#15 (Control)
do_fpe: ldr r4, .LCfp
add r10, r10, #TI_FPSTATE @ r10 = workspace add r10, r10, #TI_FPSTATE @ r10 = workspace
ldr pc, [r4] @ Call FP module USR entry point ldr pc, [r4] @ Call FP module USR entry point
/* /*
* The FP module is called with these registers set: * The FP module is called with these registers set:
* r0 = instruction * r0 = instruction
...@@ -989,6 +1012,11 @@ do_fpe: get_thread_info r10 @ get current thread ...@@ -989,6 +1012,11 @@ do_fpe: get_thread_info r10 @ get current thread
* lr = unrecognised FP instruction return address * lr = unrecognised FP instruction return address
*/ */
.data
ENTRY(fp_enter)
.word fpe_not_present
.text
fpundefinstr: mov r0, sp fpundefinstr: mov r0, sp
adrsvc al, lr, ret_from_exception adrsvc al, lr, ret_from_exception
b do_undefinstr b do_undefinstr
...@@ -1016,10 +1044,6 @@ ENTRY(ret_from_exception) ...@@ -1016,10 +1044,6 @@ ENTRY(ret_from_exception)
mov why, #0 mov why, #0
b ret_to_user b ret_to_user
.data
ENTRY(fp_enter)
.word fpe_not_present
.text
/* /*
* Register switch for ARMv3 and ARMv4 processors * Register switch for ARMv3 and ARMv4 processors
* r0 = previous thread_info, r1 = next thread_info * r0 = previous thread_info, r1 = next thread_info
......
...@@ -307,8 +307,7 @@ void flush_thread(void) ...@@ -307,8 +307,7 @@ void flush_thread(void)
struct thread_info *thread = current_thread_info(); struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current; struct task_struct *tsk = current;
tsk->used_math = 0; memset(thread->used_cp, 0, sizeof(thread->used_cp));
memset(&tsk->thread.debug, 0, sizeof(struct debug_info)); memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
fp_init(&thread->fpstate); fp_init(&thread->fpstate);
} }
...@@ -344,12 +343,12 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, ...@@ -344,12 +343,12 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
int dump_fpu (struct pt_regs *regs, struct user_fp *fp) int dump_fpu (struct pt_regs *regs, struct user_fp *fp)
{ {
struct thread_info *thread = current_thread_info(); struct thread_info *thread = current_thread_info();
int used_math = current->used_math; int used_math = thread->used_cp[1] | thread->used_cp[2];
if (used_math) if (used_math)
memcpy(fp, &thread->fpstate.soft, sizeof (*fp)); memcpy(fp, &thread->fpstate.soft, sizeof (*fp));
return used_math; return used_math != 0;
} }
/* /*
......
...@@ -602,8 +602,9 @@ static int ptrace_getfpregs(struct task_struct *tsk, void *ufp) ...@@ -602,8 +602,9 @@ static int ptrace_getfpregs(struct task_struct *tsk, void *ufp)
*/ */
static int ptrace_setfpregs(struct task_struct *tsk, void *ufp) static int ptrace_setfpregs(struct task_struct *tsk, void *ufp)
{ {
tsk->used_math = 1; struct thread_info *thread = tsk->thread_info;
return copy_from_user(&tsk->thread_info->fpstate, ufp, thread->used_cp[1] = thread->used_cp[2] = 1;
return copy_from_user(&thread->fpstate, ufp,
sizeof(struct user_fp)) ? -EFAULT : 0; sizeof(struct user_fp)) ? -EFAULT : 0;
} }
......
...@@ -51,8 +51,9 @@ struct thread_info { ...@@ -51,8 +51,9 @@ struct thread_info {
__u32 cpu; /* cpu */ __u32 cpu; /* cpu */
__u32 cpu_domain; /* cpu domain */ __u32 cpu_domain; /* cpu domain */
struct cpu_context_save cpu_context; /* cpu context */ struct cpu_context_save cpu_context; /* cpu context */
struct restart_block restart_block; __u8 used_cp[16]; /* thread used copro */
union fp_state fpstate; union fp_state fpstate;
struct restart_block restart_block;
}; };
#define INIT_THREAD_INFO(tsk) \ #define INIT_THREAD_INFO(tsk) \
...@@ -107,7 +108,8 @@ extern void free_thread_info(struct thread_info *); ...@@ -107,7 +108,8 @@ extern void free_thread_info(struct thread_info *);
#define TI_CPU 20 #define TI_CPU 20
#define TI_CPU_DOMAIN 24 #define TI_CPU_DOMAIN 24
#define TI_CPU_SAVE 28 #define TI_CPU_SAVE 28
#define TI_FPSTATE 76 #define TI_USED_MATH 76
#define TI_FPSTATE (TI_USED_MATH+16)
#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