Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 340255
b: refs/heads/master
c: 43cc05a
h: refs/heads/master
i:
  340253: 762fb75
  340251: cb7fb4a
  340247: 5408c09
  340239: f3dc099
  340223: 1248f06
v: v3
  • Loading branch information
Al Viro committed Oct 17, 2012
1 parent 04b2260 commit ccadabc
Show file tree
Hide file tree
Showing 35 changed files with 198 additions and 509 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: fea8221049a5f726857ead9c2d90dfd22d5cdc82
refs/heads/master: 43cc05a6008034e51cd5c3654c9bae7212aaf5f7
1 change: 1 addition & 0 deletions trunk/arch/c6x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ config C6X
select OF_EARLY_FLATTREE
select GENERIC_CLOCKEVENTS
select GENERIC_KERNEL_THREAD
select GENERIC_KERNEL_EXECVE
select MODULES_USE_ELF_RELA

config MMU
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/c6x/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* more details.
*/

#define __ARCH_WANT_KERNEL_EXECVE
#define __ARCH_WANT_SYS_EXECVE

/* Use the standard ABI for syscalls. */
Expand Down
12 changes: 1 addition & 11 deletions trunk/arch/c6x/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,9 @@ ENTRY(ret_from_kernel_thread)
0:
B .S2 B10 /* call fn */
LDW .D2T1 *+SP(REGS_A1+8),A4 /* get arg */
MVKL .S2 sys_exit,B11
MVKH .S2 sys_exit,B11
ADDKPC .S2 0f,B3,1
0:
BNOP .S2 B11,5 /* jump to sys_exit */
ADDKPC .S2 ret_from_fork_2,B3,3
ENDPROC(ret_from_kernel_thread)

ENTRY(ret_from_kernel_execve)
GET_THREAD_INFO A12
BNOP .S2 syscall_exit,4
ADD .D2X A4,-8,SP
ENDPROC(ret_from_kernel_execve)

;;
;; These are the interrupt handlers, responsible for calling __do_IRQ()
;; int6 is used for syscalls (see _system_call entry)
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ config MIPS
select HAVE_MOD_ARCH_SPECIFIC
select MODULES_USE_ELF_REL
select MODULES_USE_ELF_RELA if 64BIT
select GENERIC_KERNEL_THREAD
select GENERIC_KERNEL_EXECVE

menu "Machine selection"

Expand Down
2 changes: 0 additions & 2 deletions trunk/arch/mips/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ struct task_struct;
/* Free all resources held by a thread. */
#define release_thread(thread) do { } while(0)

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

extern unsigned long thread_saved_pc(struct task_struct *tsk);

/*
Expand Down
6 changes: 6 additions & 0 deletions trunk/arch/mips/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs)
die(str, regs);
}

#define current_pt_regs() \
({ \
unsigned long sp = (unsigned long)__builtin_frame_address(0); \
(struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \
})

#endif /* _ASM_PTRACE_H */
1 change: 1 addition & 0 deletions trunk/arch/mips/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
#define __ARCH_WANT_OLD_READDIR
#define __ARCH_WANT_SYS_ALARM
#define __ARCH_WANT_SYS_EXECVE
#define __ARCH_WANT_SYS_GETHOSTNAME
#define __ARCH_WANT_SYS_IPC
#define __ARCH_WANT_SYS_PAUSE
Expand Down
6 changes: 6 additions & 0 deletions trunk/arch/mips/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ need_resched:
b need_resched
#endif

FEXPORT(ret_from_kernel_thread)
jal schedule_tail # a0 = struct task_struct *prev
move a0, s1
jal s0
j syscall_exit

FEXPORT(ret_from_fork)
jal schedule_tail # a0 = struct task_struct *prev

Expand Down
21 changes: 0 additions & 21 deletions trunk/arch/mips/kernel/linux32.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* Copyright (C) 2000 Silicon Graphics, Inc.
* Written by Ulf Carlsson (ulfc@engr.sgi.com)
* sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com)
*/
#include <linux/compiler.h>
#include <linux/mm.h>
Expand Down Expand Up @@ -77,26 +76,6 @@ SYSCALL_DEFINE6(32_mmap2, unsigned long, addr, unsigned long, len,
return error;
}

/*
* sys_execve() executes a new program.
*/
asmlinkage int sys32_execve(nabi_no_regargs struct pt_regs regs)
{
int error;
struct filename *filename;

filename = getname(compat_ptr(regs.regs[4]));
error = PTR_ERR(filename);
if (IS_ERR(filename))
goto out;
error = compat_do_execve(filename->name, compat_ptr(regs.regs[5]),
compat_ptr(regs.regs[6]), &regs);
putname(filename);

out:
return error;
}

#define RLIM_INFINITY32 0x7fffffff
#define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x)

Expand Down
2 changes: 0 additions & 2 deletions trunk/arch/mips/kernel/mips_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memmove);

EXPORT_SYMBOL(kernel_thread);

/*
* Functions that operate on entire pages. Mostly used by memory management.
*/
Expand Down
62 changes: 22 additions & 40 deletions trunk/arch/mips/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void __noreturn cpu_idle(void)
}

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

void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
{
Expand Down Expand Up @@ -113,7 +114,7 @@ void flush_thread(void)
}

int copy_thread(unsigned long clone_flags, unsigned long usp,
unsigned long unused, struct task_struct *p, struct pt_regs *regs)
unsigned long arg, struct task_struct *p, struct pt_regs *regs)
{
struct thread_info *ti = task_thread_info(p);
struct pt_regs *childregs;
Expand All @@ -136,27 +137,37 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
childregs = (struct pt_regs *) childksp - 1;
/* Put the stack after the struct pt_regs. */
childksp = (unsigned long) childregs;
p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
if (unlikely(p->flags & PF_KTHREAD)) {
unsigned long status = p->thread.cp0_status;
memset(childregs, 0, sizeof(struct pt_regs));
ti->addr_limit = KERNEL_DS;
p->thread.reg16 = usp; /* fn */
p->thread.reg17 = arg;
p->thread.reg29 = childksp;
p->thread.reg31 = (unsigned long) ret_from_kernel_thread;
#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
status = (status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) |
((status & (ST0_KUC | ST0_IEC)) << 2);
#else
status |= ST0_EXL;
#endif
childregs->cp0_status = status;
return 0;
}
*childregs = *regs;
childregs->regs[7] = 0; /* Clear error flag */

childregs->regs[2] = 0; /* Child gets zero as return value */
childregs->regs[29] = usp;
ti->addr_limit = USER_DS;

if (childregs->cp0_status & ST0_CU0) {
childregs->regs[28] = (unsigned long) ti;
childregs->regs[29] = childksp;
ti->addr_limit = KERNEL_DS;
} else {
childregs->regs[29] = usp;
ti->addr_limit = USER_DS;
}
p->thread.reg29 = (unsigned long) childregs;
p->thread.reg31 = (unsigned long) ret_from_fork;

/*
* New tasks lose permission to use the fpu. This accelerates context
* switching for most programs since they don't use the fpu.
*/
p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);

#ifdef CONFIG_MIPS_MT_SMTC
Expand Down Expand Up @@ -221,35 +232,6 @@ int dump_task_fpu(struct task_struct *t, elf_fpregset_t *fpr)
return 1;
}

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

long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
{
struct pt_regs regs;

memset(&regs, 0, sizeof(regs));

regs.regs[4] = (unsigned long) arg;
regs.regs[5] = (unsigned long) fn;
regs.cp0_epc = (unsigned long) kernel_thread_helper;
regs.cp0_status = read_c0_status();
#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
regs.cp0_status = (regs.cp0_status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) |
((regs.cp0_status & (ST0_KUC | ST0_IEC)) << 2);
#else
regs.cp0_status |= ST0_EXL;
#endif

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

/*
*
*/
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/mips/kernel/scall64-n32.S
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ EXPORT(sysn32_call_table)
PTR sys_getsockopt
PTR sys_clone /* 6055 */
PTR sys_fork
PTR sys32_execve
PTR compat_sys_execve
PTR sys_exit
PTR compat_sys_wait4
PTR sys_kill /* 6060 */
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/mips/kernel/scall64-o32.S
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ sys_call_table:
PTR sys_creat
PTR sys_link
PTR sys_unlink /* 4010 */
PTR sys32_execve
PTR compat_sys_execve
PTR sys_chdir
PTR compat_sys_time
PTR sys_mknod
Expand Down
53 changes: 0 additions & 53 deletions trunk/arch/mips/kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,6 @@ _sys_clone(nabi_no_regargs struct pt_regs regs)
parent_tidptr, child_tidptr);
}

/*
* sys_execve() executes a new program.
*/
asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs)
{
int error;
struct filename *filename;

filename = getname((const char __user *) (long)regs.regs[4]);
error = PTR_ERR(filename);
if (IS_ERR(filename))
goto out;
error = do_execve(filename->name,
(const char __user *const __user *) (long)regs.regs[5],
(const char __user *const __user *) (long)regs.regs[6],
&regs);
putname(filename);

out:
return error;
}

SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
{
struct thread_info *ti = task_thread_info(current);
Expand Down Expand Up @@ -313,34 +291,3 @@ asmlinkage void bad_stack(void)
{
do_exit(SIGSEGV);
}

/*
* Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs.
*/
int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{
register unsigned long __a0 asm("$4") = (unsigned long) filename;
register unsigned long __a1 asm("$5") = (unsigned long) argv;
register unsigned long __a2 asm("$6") = (unsigned long) envp;
register unsigned long __a3 asm("$7");
unsigned long __v0;

__asm__ volatile (" \n"
" .set noreorder \n"
" li $2, %5 # __NR_execve \n"
" syscall \n"
" move %0, $2 \n"
" .set reorder \n"
: "=&r" (__v0), "=r" (__a3)
: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve)
: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24",
"memory");

if (__a3 == 0)
return __v0;

return -__v0;
}
2 changes: 2 additions & 0 deletions trunk/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 trunk/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 trunk/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
Loading

0 comments on commit ccadabc

Please sign in to comment.