Skip to content

Commit

Permalink
Merge branch 'arch-sparc' into no-rebases
Browse files Browse the repository at this point in the history
  • Loading branch information
Al Viro committed Oct 17, 2012
2 parents fefec52 + f7200d4 commit 87d2fed
Show file tree
Hide file tree
Showing 20 changed files with 156 additions and 376 deletions.
2 changes: 2 additions & 0 deletions arch/sparc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ config SPARC
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
select MODULES_USE_ELF_RELA
select GENERIC_KERNEL_THREAD
select GENERIC_KERNEL_EXECVE

config SPARC32
def_bool !64BIT
Expand Down
1 change: 0 additions & 1 deletion arch/sparc/include/asm/processor_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,

/* Free all resources held by a thread. */
#define release_thread(tsk) do { } while(0)
extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);

extern unsigned long get_wchan(struct task_struct *);

Expand Down
11 changes: 9 additions & 2 deletions arch/sparc/include/asm/processor_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct thread_struct {
#ifndef __ASSEMBLY__

#include <linux/types.h>
#include <asm/fpumacro.h>

/* Return saved PC of a blocked thread. */
struct task_struct;
Expand Down Expand Up @@ -143,6 +144,10 @@ do { \
: \
: "r" (regs), "r" (sp - sizeof(struct reg_window) - STACK_BIAS), \
"i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
fprs_write(0); \
current_thread_info()->xfsr[0] = 0; \
current_thread_info()->fpsaved[0] = 0; \
regs->tstate &= ~TSTATE_PEF; \
} while (0)

#define start_thread32(regs, pc, sp) \
Expand Down Expand Up @@ -183,13 +188,15 @@ do { \
: \
: "r" (regs), "r" (sp - sizeof(struct reg_window32)), \
"i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
fprs_write(0); \
current_thread_info()->xfsr[0] = 0; \
current_thread_info()->fpsaved[0] = 0; \
regs->tstate &= ~TSTATE_PEF; \
} while (0)

/* Free all resources held by a thread. */
#define release_thread(tsk) do { } while (0)

extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);

extern unsigned long get_wchan(struct task_struct *task);

#define task_pt_regs(tsk) (task_thread_info(tsk)->kregs)
Expand Down
10 changes: 7 additions & 3 deletions arch/sparc/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
#define arch_ptrace_stop(exit_code, info) \
synchronize_user_stack()

#define current_pt_regs() \
((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)

struct global_reg_snapshot {
unsigned long tstate;
unsigned long tpc;
Expand All @@ -44,9 +47,7 @@ struct global_reg_snapshot {
};
extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];

#define force_successful_syscall_return() \
do { current_thread_info()->syscall_noerror = 1; \
} while (0)
#define force_successful_syscall_return() set_thread_noerror(1)
#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
#define instruction_pointer(regs) ((regs)->tpc)
#define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
Expand Down Expand Up @@ -89,6 +90,9 @@ static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
#define arch_ptrace_stop(exit_code, info) \
synchronize_user_stack()

#define current_pt_regs() \
((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)

#define user_mode(regs) (!((regs)->psr & PSR_PS))
#define instruction_pointer(regs) ((regs)->pc)
#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/include/asm/switch_to_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ do { flush_tlb_pending(); \
/* If you are tempted to conditionalize the following */ \
/* so that ASI is only written if it changes, think again. */ \
__asm__ __volatile__("wr %%g0, %0, %%asi" \
: : "r" (__thread_flag_byte_ptr(task_thread_info(next))[TI_FLAG_BYTE_CURRENT_DS]));\
: : "r" (task_thread_info(next)->current_ds));\
trap_block[current_thread_info()->cpu].thread = \
task_thread_info(next); \
__asm__ __volatile__( \
Expand Down
2 changes: 0 additions & 2 deletions arch/sparc/include/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ extern asmlinkage long sparc_do_fork(unsigned long clone_flags,
struct pt_regs *regs,
unsigned long stack_size);

extern asmlinkage int sparc_execve(struct pt_regs *regs);

#endif /* _SPARC64_SYSCALLS_H */
25 changes: 12 additions & 13 deletions arch/sparc/include/asm/thread_info_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#define TI_FLAG_FAULT_CODE_SHIFT 56
#define TI_FLAG_BYTE_WSTATE 1
#define TI_FLAG_WSTATE_SHIFT 48
#define TI_FLAG_BYTE_CWP 2
#define TI_FLAG_CWP_SHIFT 40
#define TI_FLAG_BYTE_CURRENT_DS 3
#define TI_FLAG_CURRENT_DS_SHIFT 32
#define TI_FLAG_BYTE_FPDEPTH 4
#define TI_FLAG_FPDEPTH_SHIFT 24
#define TI_FLAG_BYTE_NOERROR 2
#define TI_FLAG_BYTE_NOERROR_SHIFT 40
#define TI_FLAG_BYTE_FPDEPTH 3
#define TI_FLAG_FPDEPTH_SHIFT 32
#define TI_FLAG_BYTE_CWP 4
#define TI_FLAG_CWP_SHIFT 24
#define TI_FLAG_BYTE_WSAVED 5
#define TI_FLAG_WSAVED_SHIFT 16

Expand Down Expand Up @@ -47,7 +47,7 @@ struct thread_info {
struct exec_domain *exec_domain;
int preempt_count; /* 0 => preemptable, <0 => BUG */
__u8 new_child;
__u8 syscall_noerror;
__u8 current_ds;
__u16 cpu;

unsigned long *utraps;
Expand All @@ -74,17 +74,17 @@ struct thread_info {
#define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE)
#define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE)
#define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP)
#define TI_CURRENT_DS (TI_FLAGS + TI_FLAG_BYTE_CURRENT_DS)
#define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH)
#define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED)
#define TI_SYS_NOERROR (TI_FLAGS + TI_FLAG_BYTE_NOERROR)
#define TI_FPSAVED 0x00000010
#define TI_KSP 0x00000018
#define TI_FAULT_ADDR 0x00000020
#define TI_KREGS 0x00000028
#define TI_EXEC_DOMAIN 0x00000030
#define TI_PRE_COUNT 0x00000038
#define TI_NEW_CHILD 0x0000003c
#define TI_SYS_NOERROR 0x0000003d
#define TI_CURRENT_DS 0x0000003d
#define TI_CPU 0x0000003e
#define TI_UTRAPS 0x00000040
#define TI_REG_WINDOW 0x00000048
Expand Down Expand Up @@ -121,7 +121,7 @@ struct thread_info {
#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \
.flags = ((unsigned long)ASI_P) << TI_FLAG_CURRENT_DS_SHIFT, \
.current_ds = ASI_P, \
.exec_domain = &default_exec_domain, \
.preempt_count = INIT_PREEMPT_COUNT, \
.restart_block = { \
Expand Down Expand Up @@ -153,13 +153,12 @@ register struct thread_info *current_thread_info_reg asm("g6");
#define set_thread_wstate(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE] = (val))
#define get_thread_cwp() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP])
#define set_thread_cwp(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP] = (val))
#define get_thread_current_ds() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS])
#define set_thread_current_ds(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS] = (val))
#define get_thread_noerror() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_NOERROR])
#define set_thread_noerror(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_NOERROR] = (val))
#define get_thread_fpdepth() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH])
#define set_thread_fpdepth(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH] = (val))
#define get_thread_wsaved() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED])
#define set_thread_wsaved(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED] = (val))

#endif /* !(__ASSEMBLY__) */

/*
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/include/asm/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
#define VERIFY_READ 0
#define VERIFY_WRITE 1

#define get_fs() ((mm_segment_t) { get_thread_current_ds() })
#define get_fs() ((mm_segment_t){(current_thread_info()->current_ds)})
#define get_ds() (KERNEL_DS)

#define segment_eq(a,b) ((a).seg == (b).seg)

#define set_fs(val) \
do { \
set_thread_current_ds((val).seg); \
current_thread_info()->current_ds =(val).seg; \
__asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \
} while(0)

Expand Down
1 change: 1 addition & 0 deletions arch/sparc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
#define __ARCH_WANT_COMPAT_SYS_SENDFILE
#endif
#define __ARCH_WANT_SYS_EXECVE

/*
* "Conditional" syscalls
Expand Down
51 changes: 22 additions & 29 deletions arch/sparc/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -806,23 +806,10 @@ sys_nis_syscall:
call c_sys_nis_syscall
mov %l5, %o7

.align 4
.globl sys_execve
sys_execve:
mov %o7, %l5
add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
call sparc_execve
mov %l5, %o7

.globl sunos_execv
sunos_execv:
st %g0, [%sp + STACKFRAME_SZ + PT_I2]

call sparc_execve
add %sp, STACKFRAME_SZ, %o0

b ret_sys_call
ld [%sp + STACKFRAME_SZ + PT_I0], %o0
.globl sunos_execv
b sys_execve
clr %i2

.align 4
.globl sys_sparc_pipe
Expand Down Expand Up @@ -959,17 +946,9 @@ flush_patch_four:
.align 4
linux_sparc_ni_syscall:
sethi %hi(sys_ni_syscall), %l7
b syscall_is_too_hard
b do_syscall
or %l7, %lo(sys_ni_syscall), %l7

linux_fast_syscall:
andn %l7, 3, %l7
mov %i0, %o0
mov %i1, %o1
mov %i2, %o2
jmpl %l7 + %g0, %g0
mov %i3, %o3

linux_syscall_trace:
add %sp, STACKFRAME_SZ, %o0
call syscall_trace
Expand All @@ -991,6 +970,23 @@ ret_from_fork:
b ret_sys_call
ld [%sp + STACKFRAME_SZ + PT_I0], %o0

.globl ret_from_kernel_thread
ret_from_kernel_thread:
call schedule_tail
ld [%g3 + TI_TASK], %o0
ld [%sp + STACKFRAME_SZ + PT_G1], %l0
call %l0
ld [%sp + STACKFRAME_SZ + PT_G2], %o0
rd %psr, %l1
ld [%sp + STACKFRAME_SZ + PT_PSR], %l0
andn %l0, PSR_CWP, %l0
nop
and %l1, PSR_CWP, %l1
or %l0, %l1, %l0
st %l0, [%sp + STACKFRAME_SZ + PT_PSR]
b ret_sys_call
mov 0, %o0

/* Linux native system calls enter here... */
.align 4
.globl linux_sparc_syscall
Expand All @@ -1002,11 +998,8 @@ linux_sparc_syscall:
bgeu linux_sparc_ni_syscall
sll %g1, 2, %l4
ld [%l7 + %l4], %l7
andcc %l7, 1, %g0
bne linux_fast_syscall
/* Just do first insn from SAVE_ALL in the delay slot */

syscall_is_too_hard:
do_syscall:
SAVE_ALL_HEAD
rd %wim, %l3

Expand Down
8 changes: 6 additions & 2 deletions arch/sparc/kernel/etrap_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ etrap_save: save %g2, -STACK_BIAS, %sp
rdpr %wstate, %g2
wrpr %g0, 0, %canrestore
sll %g2, 3, %g2

/* Set TI_SYS_FPDEPTH to 1 and clear TI_SYS_NOERROR. */
mov 1, %l5
stb %l5, [%l6 + TI_FPDEPTH]
sth %l5, [%l6 + TI_SYS_NOERROR]

wrpr %g3, 0, %otherwin
wrpr %g2, 0, %wstate
Expand Down Expand Up @@ -152,7 +154,9 @@ etrap_save: save %g2, -STACK_BIAS, %sp
add %l6, TI_FPSAVED + 1, %l4
srl %l5, 1, %l3
add %l5, 2, %l5
stb %l5, [%l6 + TI_FPDEPTH]

/* Set TI_SYS_FPDEPTH to %l5 and clear TI_SYS_NOERROR. */
sth %l5, [%l6 + TI_SYS_NOERROR]
ba,pt %xcc, 2b
stb %g0, [%l4 + %l3]
nop
Expand Down
Loading

0 comments on commit 87d2fed

Please sign in to comment.