Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 340313
b: refs/heads/master
c: 138d1ce
h: refs/heads/master
i:
  340311: 8bfdb4b
v: v3
  • Loading branch information
Al Viro committed Oct 14, 2012
1 parent 87f154c commit c09ed40
Show file tree
Hide file tree
Showing 19 changed files with 235 additions and 95 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 80b249b71e2e7caf6110a0d50c9634cebb223c0e
refs/heads/master: 138d1ce80ed96eff6638f454f0a1500a4aefd17b
1 change: 1 addition & 0 deletions trunk/arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ config PPC
select GENERIC_KERNEL_THREAD
select HAVE_MOD_ARCH_SPECIFIC
select MODULES_USE_ELF_RELA
select GENERIC_KERNEL_EXECVE

config EARLY_PRINTK
bool
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/powerpc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#define __ARCH_WANT_COMPAT_SYS_SENDFILE
#endif
#define __ARCH_WANT_SYS_EXECVE
#define __ARCH_WANT_KERNEL_EXECVE

/*
* "Conditional" syscalls
Expand Down
5 changes: 0 additions & 5 deletions trunk/arch/powerpc/kernel/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,6 @@ ret_from_kernel_thread:
PPC440EP_ERR42
blrl
li r3,0
b do_exit # no return

.globl __ret_from_kernel_execve
__ret_from_kernel_execve:
addi r1,r3,-STACK_FRAME_OVERHEAD
b ret_from_syscall

/* Traced system call support */
Expand Down
6 changes: 0 additions & 6 deletions trunk/arch/powerpc/kernel/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,6 @@ _GLOBAL(ret_from_kernel_thread)
mr r3,r15
blrl
li r3,0
b .do_exit # no return

_GLOBAL(__ret_from_kernel_execve)
addi r1,r3,-STACK_FRAME_OVERHEAD
li r10,1
std r10,SOFTE(r1)
b syscall_exit

.section ".toc","aw"
Expand Down
13 changes: 3 additions & 10 deletions trunk/arch/powerpc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,19 +746,21 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
sp -= sizeof(struct pt_regs);
childregs = (struct pt_regs *) sp;
if (!regs) {
/* for kernel thread, set `current' and stackptr in new task */
struct thread_info *ti = (void *)task_stack_page(p);
memset(childregs, 0, sizeof(struct pt_regs));
childregs->gpr[1] = sp + sizeof(struct pt_regs);
#ifdef CONFIG_PPC64
childregs->gpr[14] = *(unsigned long *)usp;
childregs->gpr[2] = ((unsigned long *)usp)[1],
clear_tsk_thread_flag(p, TIF_32BIT);
childregs->softe = 1;
#else
childregs->gpr[14] = usp; /* function */
childregs->gpr[2] = (unsigned long) p;
#endif
childregs->gpr[15] = arg;
p->thread.regs = NULL; /* no user register state */
ti->flags |= _TIF_RESTOREALL;
f = ret_from_kernel_thread;
} else {
CHECK_FULL_REGS(regs);
Expand Down Expand Up @@ -1063,15 +1065,6 @@ int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3,
regs, 0, NULL, NULL);
}

void __ret_from_kernel_execve(struct pt_regs *normal)
__noreturn;

void ret_from_kernel_execve(struct pt_regs *normal)
{
set_thread_flag(TIF_RESTOREALL);
__ret_from_kernel_execve(normal);
}

static inline int valid_irq_stack(unsigned long sp, struct task_struct *p,
unsigned long nbytes)
{
Expand Down
2 changes: 0 additions & 2 deletions trunk/arch/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ config SUPERH
select GENERIC_STRNLEN_USER
select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER
select MODULES_USE_ELF_RELA
select GENERIC_KERNEL_THREAD
select GENERIC_KERNEL_EXECVE
help
The SuperH is a RISC processor targeted for use in embedded systems
and consumer electronics; it was also used in the Sega Dreamcast
Expand Down
5 changes: 5 additions & 0 deletions trunk/arch/sh/include/asm/processor_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_pc, unsigned lo
/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);

/*
* create a kernel thread without removing it from tasklists
*/
extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);

/* Copy and release all segment info associated with a VM */
#define copy_segments(p, mm) do { } while(0)
#define release_segments(mm) do { } while(0)
Expand Down
5 changes: 5 additions & 0 deletions trunk/arch/sh/include/asm/processor_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ struct mm_struct;

/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);
/*
* create a kernel thread without removing it from tasklists
*/
extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);


/* Copy and release all segment info associated with a VM */
#define copy_segments(p, mm) do { } while (0)
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/sh/include/asm/syscalls_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7,
struct pt_regs __regs);
asmlinkage int sys_execve(const char __user *ufilename,
const char __user *const __user *uargv,
const char __user *const __user *uenvp,
unsigned long r7, struct pt_regs __regs);
asmlinkage int sys_sigsuspend(old_sigset_t mask);
asmlinkage int sys_sigaction(int sig, const struct old_sigaction __user *act,
struct old_sigaction __user *oact);
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/sh/include/asm/syscalls_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7,
struct pt_regs *pregs);
asmlinkage int sys_execve(const char *ufilename, char **uargv,
char **uenvp, unsigned long r5,
unsigned long r6, unsigned long r7,
struct pt_regs *pregs);

/* Misc syscall related bits */
asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs);
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/sh/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# define __ARCH_WANT_SYS_SIGPENDING
# define __ARCH_WANT_SYS_SIGPROCMASK
# define __ARCH_WANT_SYS_RT_SIGACTION
# define __ARCH_WANT_SYS_EXECVE

/*
* "Conditional" syscalls
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/sh/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ obj-y := debugtraps.o dma-nommu.o dumpstack.o \
machvec.o nmi_debug.o process.o \
process_$(BITS).o ptrace.o ptrace_$(BITS).o \
reboot.o return_address.o \
setup.o signal_$(BITS).o sys_sh.o \
setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \
syscalls_$(BITS).o time.o topology.o traps.o \
traps_$(BITS).o unwinder.o

Expand All @@ -25,7 +25,6 @@ obj-y += iomap.o
obj-$(CONFIG_HAS_IOPORT) += ioport.o
endif

obj-$(CONFIG_SUPERH32) += sys_sh32.o
obj-y += cpu/
obj-$(CONFIG_VSYSCALL) += vsyscall/
obj-$(CONFIG_SMP) += smp.o
Expand Down
19 changes: 0 additions & 19 deletions trunk/arch/sh/kernel/cpu/sh5/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -1228,25 +1228,6 @@ ret_from_fork:
pta ret_from_syscall, tr0
blink tr0, ZERO

.global ret_from_kernel_thread
ret_from_kernel_thread:

movi schedule_tail,r5
ori r5, 1, r5
ptabs r5, tr0
blink tr0, LINK

ld.q SP, FRAME_R(2), r2
ld.q SP, FRAME_R(3), r3
ptabs r3, tr0
blink tr0, LINK

ld.q SP, FRAME_S(FSPC), r2
addi r2, 4, r2 /* Move PC, being pre-execution event */
st.q SP, FRAME_S(FSPC), r2
pta ret_from_syscall, tr0
blink tr0, ZERO

syscall_allowed:
/* Use LINK to deflect the exit point, default is syscall_ret */
pta syscall_ret, tr0
Expand Down
13 changes: 0 additions & 13 deletions trunk/arch/sh/kernel/entry-common.S
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,6 @@ ret_from_fork:
mov r0, r4
bra syscall_exit
nop

.align 2
.globl ret_from_kernel_thread
ret_from_kernel_thread:
mov.l 1f, r8
jsr @r8
mov r0, r4
mov.l @(OFF_R5,r15), r5 ! fn
jsr @r5
mov.l @(OFF_R4,r15), r4 ! arg
bra syscall_exit
nop

.align 2
1: .long schedule_tail

Expand Down
87 changes: 68 additions & 19 deletions trunk/arch/sh/kernel/process_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ void show_regs(struct pt_regs * regs)
show_code(regs);
}

/*
* Create a kernel thread
*/
__noreturn void kernel_thread_helper(void *arg, int (*fn)(void *))
{
do_exit(fn(arg));
}

/* Don't use this in BL=1(cli). Or else, CPU resets! */
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
struct pt_regs regs;
int pid;

memset(&regs, 0, sizeof(regs));
regs.regs[4] = (unsigned long)arg;
regs.regs[5] = (unsigned long)fn;

regs.pc = (unsigned long)kernel_thread_helper;
regs.sr = SR_MD;
#if defined(CONFIG_SH_FPU)
regs.sr |= SR_FD;
#endif

/* Ok, create the new process.. */
pid = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
&regs, 0, NULL, NULL);

return pid;
}
EXPORT_SYMBOL(kernel_thread);

void start_thread(struct pt_regs *regs, unsigned long new_pc,
unsigned long new_sp)
{
Expand Down Expand Up @@ -125,10 +157,9 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
EXPORT_SYMBOL(dump_fpu);

asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);

int copy_thread(unsigned long clone_flags, unsigned long usp,
unsigned long arg,
unsigned long unused,
struct task_struct *p, struct pt_regs *regs)
{
struct thread_info *ti = task_thread_info(p);
Expand All @@ -146,34 +177,29 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
}
#endif

memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));

childregs = task_pt_regs(p);
p->thread.sp = (unsigned long) childregs;
if (unlikely(p->flags & PF_KTHREAD)) {
memset(childregs, 0, sizeof(struct pt_regs));
p->thread.pc = (unsigned long) ret_from_kernel_thread;
childregs->regs[4] = arg;
childregs->regs[5] = usp;
childregs->sr = SR_MD;
#if defined(CONFIG_SH_FPU)
childregs->sr |= SR_FD;
#endif
*childregs = *regs;

if (user_mode(regs)) {
childregs->regs[15] = usp;
ti->addr_limit = USER_DS;
} else {
childregs->regs[15] = (unsigned long)childregs;
ti->addr_limit = KERNEL_DS;
ti->status &= ~TS_USEDFPU;
p->fpu_counter = 0;
return 0;
}
*childregs = *regs;

childregs->regs[15] = usp;
ti->addr_limit = USER_DS;

if (clone_flags & CLONE_SETTLS)
childregs->gbr = childregs->regs[0];

childregs->regs[0] = 0; /* Set return value for child */

p->thread.sp = (unsigned long) childregs;
p->thread.pc = (unsigned long) ret_from_fork;

memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));

return 0;
}

Expand Down Expand Up @@ -262,6 +288,29 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
0, NULL, NULL);
}

/*
* sys_execve() executes a new program.
*/
asmlinkage int sys_execve(const char __user *ufilename,
const char __user *const __user *uargv,
const char __user *const __user *uenvp,
unsigned long r7, struct pt_regs __regs)
{
struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
int error;
struct filename *filename;

filename = getname(ufilename);
error = PTR_ERR(filename);
if (IS_ERR(filename))
goto out;

error = do_execve(filename->name, uargv, uenvp, regs);
putname(filename);
out:
return error;
}

unsigned long get_wchan(struct task_struct *p)
{
unsigned long pc;
Expand Down
Loading

0 comments on commit c09ed40

Please sign in to comment.