Re: [PATCH 1/2] unicore32: switch to generic kernel_thread()/kernel_execve()

2012-10-19 Thread guanxuetao
> On Fri, Oct 19, 2012 at 04:43:09PM +0800, Guan Xuetao wrote:
>> From: Al Viro 
>>
>> Signed-off-by: Al Viro 
>> Acked-and-Tested-by: Guan Xuetao 
>
> You mean, it worked modulo obvious missing ')'?  Wow... OK, merged
> into signal.git#for-next, obviously in no-rebase mode (as the matter
> of fact, I'm dropping the local branch completely).
>
I've added')' in the patch. Then it works.
In addition, I pushed these two patches into my tree.

Thanks & regards,
Guan Xuetao
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] unicore32: switch to generic kernel_thread()/kernel_execve()

2012-10-19 Thread Al Viro
On Fri, Oct 19, 2012 at 04:43:09PM +0800, Guan Xuetao wrote:
> From: Al Viro 
> 
> Signed-off-by: Al Viro 
> Acked-and-Tested-by: Guan Xuetao 

You mean, it worked modulo obvious missing ')'?  Wow... OK, merged
into signal.git#for-next, obviously in no-rebase mode (as the matter
of fact, I'm dropping the local branch completely).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] unicore32: switch to generic kernel_thread()/kernel_execve()

2012-10-19 Thread Guan Xuetao
From: Al Viro 

Signed-off-by: Al Viro 
Acked-and-Tested-by: Guan Xuetao 
---
 arch/unicore32/Kconfig |2 +
 arch/unicore32/include/asm/processor.h |5 ---
 arch/unicore32/kernel/entry.S  |   15 
 arch/unicore32/kernel/process.c|   58 
 arch/unicore32/kernel/sys.c|   42 ---
 5 files changed, 23 insertions(+), 99 deletions(-)

diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 5b95ba4..fda37c9 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -16,6 +16,8 @@ config UNICORE32
select ARCH_WANT_FRAME_POINTERS
select GENERIC_IOMAP
select MODULES_USE_ELF_REL
+   select GENERIC_KERNEL_THREAD
+   select GENERIC_KERNEL_EXECVE
help
  UniCore-32 is 32-bit Instruction Set Architecture,
  including a series of low-power-consumption RISC chip
diff --git a/arch/unicore32/include/asm/processor.h 
b/arch/unicore32/include/asm/processor.h
index 14382cb..4eaa421 100644
--- a/arch/unicore32/include/asm/processor.h
+++ b/arch/unicore32/include/asm/processor.h
@@ -72,11 +72,6 @@ unsigned long get_wchan(struct task_struct *p);
 
 #define cpu_relax()barrier()
 
-/*
- * Create a new kernel thread
- */
-extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
-
 #define task_pt_regs(p) \
((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
 
diff --git a/arch/unicore32/kernel/entry.S b/arch/unicore32/kernel/entry.S
index dcb87ab..32648c9 100644
--- a/arch/unicore32/kernel/entry.S
+++ b/arch/unicore32/kernel/entry.S
@@ -573,17 +573,16 @@ ENDPROC(ret_to_user)
  */
 ENTRY(ret_from_fork)
b.l schedule_tail
-   get_thread_info tsk
-   ldw r1, [tsk+], #TI_FLAGS   @ check for syscall tracing
-   mov why, #1
-   cand.a  r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
-   beq ret_slow_syscall
-   mov r1, sp
-   mov r0, #1  @ trace exit [IP = 1]
-   b.l syscall_trace
b   ret_slow_syscall
 ENDPROC(ret_from_fork)
 
+ENTRY(ret_from_kernel_thread)
+   b.l schedule_tail
+   mov r0, r5
+   adr lr, ret_slow_syscall
+   mov pc, r4
+ENDPROC(ret_from_kernel_thread)
+
 /*=
  * SWI handler
  *-
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index b008586..a8fe265 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -258,6 +258,7 @@ void release_thread(struct task_struct *dead_task)
 }
 
 asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
+asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
 
 int
 copy_thread(unsigned long clone_flags, unsigned long stack_start,
@@ -266,17 +267,22 @@ copy_thread(unsigned long clone_flags, unsigned long 
stack_start,
struct thread_info *thread = task_thread_info(p);
struct pt_regs *childregs = task_pt_regs(p);
 
-   *childregs = *regs;
-   childregs->UCreg_00 = 0;
-   childregs->UCreg_sp = stack_start;
-
memset(>cpu_context, 0, sizeof(struct cpu_context_save));
thread->cpu_context.sp = (unsigned long)childregs;
-   thread->cpu_context.pc = (unsigned long)ret_from_fork;
-
-   if (clone_flags & CLONE_SETTLS)
-   childregs->UCreg_16 = regs->UCreg_03;
+   if (unlikely(!regs)) {
+   thread->cpu_context.pc = (unsigned long)ret_from_kernel_thread;
+   thread->cpu_context.r4 = stack_start;
+   thread->cpu_context.r5 = stk_sz;
+   memset(childregs, 0, sizeof(struct pt_regs));
+   } else {
+   thread->cpu_context.pc = (unsigned long)ret_from_fork;
+   *childregs = *regs;
+   childregs->UCreg_00 = 0;
+   childregs->UCreg_sp = stack_start;
 
+   if (clone_flags & CLONE_SETTLS)
+   childregs->UCreg_16 = regs->UCreg_03;
+   }
return 0;
 }
 
@@ -305,42 +311,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fp)
 }
 EXPORT_SYMBOL(dump_fpu);
 
-/*
- * Shuffle the argument into the correct register before calling the
- * thread function.  r1 is the thread argument, r2 is the pointer to
- * the thread function, and r3 points to the exit function.
- */
-asm(".pushsection .text\n"
-"  .align\n"
-"  .type   kernel_thread_helper, #function\n"
-"kernel_thread_helper:\n"
-"  mov.a   asr, r7\n"
-"  mov r0, r4\n"
-"  mov lr, r6\n"
-"  mov pc, r5\n"
-"  .size   kernel_thread_helper, . - kernel_thread_helper\n"
-"  .popsection");
-
-/*
- * Create a kernel thread.
- */
-pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)

[PATCH 1/2] unicore32: switch to generic kernel_thread()/kernel_execve()

2012-10-19 Thread Guan Xuetao
From: Al Viro v...@zeniv.linux.org.uk

Signed-off-by: Al Viro v...@zeniv.linux.org.uk
Acked-and-Tested-by: Guan Xuetao g...@mprc.pku.edu.cn
---
 arch/unicore32/Kconfig |2 +
 arch/unicore32/include/asm/processor.h |5 ---
 arch/unicore32/kernel/entry.S  |   15 
 arch/unicore32/kernel/process.c|   58 
 arch/unicore32/kernel/sys.c|   42 ---
 5 files changed, 23 insertions(+), 99 deletions(-)

diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 5b95ba4..fda37c9 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -16,6 +16,8 @@ config UNICORE32
select ARCH_WANT_FRAME_POINTERS
select GENERIC_IOMAP
select MODULES_USE_ELF_REL
+   select GENERIC_KERNEL_THREAD
+   select GENERIC_KERNEL_EXECVE
help
  UniCore-32 is 32-bit Instruction Set Architecture,
  including a series of low-power-consumption RISC chip
diff --git a/arch/unicore32/include/asm/processor.h 
b/arch/unicore32/include/asm/processor.h
index 14382cb..4eaa421 100644
--- a/arch/unicore32/include/asm/processor.h
+++ b/arch/unicore32/include/asm/processor.h
@@ -72,11 +72,6 @@ unsigned long get_wchan(struct task_struct *p);
 
 #define cpu_relax()barrier()
 
-/*
- * Create a new kernel thread
- */
-extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
-
 #define task_pt_regs(p) \
((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
 
diff --git a/arch/unicore32/kernel/entry.S b/arch/unicore32/kernel/entry.S
index dcb87ab..32648c9 100644
--- a/arch/unicore32/kernel/entry.S
+++ b/arch/unicore32/kernel/entry.S
@@ -573,17 +573,16 @@ ENDPROC(ret_to_user)
  */
 ENTRY(ret_from_fork)
b.l schedule_tail
-   get_thread_info tsk
-   ldw r1, [tsk+], #TI_FLAGS   @ check for syscall tracing
-   mov why, #1
-   cand.a  r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
-   beq ret_slow_syscall
-   mov r1, sp
-   mov r0, #1  @ trace exit [IP = 1]
-   b.l syscall_trace
b   ret_slow_syscall
 ENDPROC(ret_from_fork)
 
+ENTRY(ret_from_kernel_thread)
+   b.l schedule_tail
+   mov r0, r5
+   adr lr, ret_slow_syscall
+   mov pc, r4
+ENDPROC(ret_from_kernel_thread)
+
 /*=
  * SWI handler
  *-
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index b008586..a8fe265 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -258,6 +258,7 @@ void release_thread(struct task_struct *dead_task)
 }
 
 asmlinkage void ret_from_fork(void) __asm__(ret_from_fork);
+asmlinkage void ret_from_kernel_thread(void) __asm__(ret_from_kernel_thread);
 
 int
 copy_thread(unsigned long clone_flags, unsigned long stack_start,
@@ -266,17 +267,22 @@ copy_thread(unsigned long clone_flags, unsigned long 
stack_start,
struct thread_info *thread = task_thread_info(p);
struct pt_regs *childregs = task_pt_regs(p);
 
-   *childregs = *regs;
-   childregs-UCreg_00 = 0;
-   childregs-UCreg_sp = stack_start;
-
memset(thread-cpu_context, 0, sizeof(struct cpu_context_save));
thread-cpu_context.sp = (unsigned long)childregs;
-   thread-cpu_context.pc = (unsigned long)ret_from_fork;
-
-   if (clone_flags  CLONE_SETTLS)
-   childregs-UCreg_16 = regs-UCreg_03;
+   if (unlikely(!regs)) {
+   thread-cpu_context.pc = (unsigned long)ret_from_kernel_thread;
+   thread-cpu_context.r4 = stack_start;
+   thread-cpu_context.r5 = stk_sz;
+   memset(childregs, 0, sizeof(struct pt_regs));
+   } else {
+   thread-cpu_context.pc = (unsigned long)ret_from_fork;
+   *childregs = *regs;
+   childregs-UCreg_00 = 0;
+   childregs-UCreg_sp = stack_start;
 
+   if (clone_flags  CLONE_SETTLS)
+   childregs-UCreg_16 = regs-UCreg_03;
+   }
return 0;
 }
 
@@ -305,42 +311,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fp)
 }
 EXPORT_SYMBOL(dump_fpu);
 
-/*
- * Shuffle the argument into the correct register before calling the
- * thread function.  r1 is the thread argument, r2 is the pointer to
- * the thread function, and r3 points to the exit function.
- */
-asm(.pushsection .text\n
-  .align\n
-  .type   kernel_thread_helper, #function\n
-kernel_thread_helper:\n
-  mov.a   asr, r7\n
-  mov r0, r4\n
-  mov lr, r6\n
-  mov pc, r5\n
-  .size   kernel_thread_helper, . - kernel_thread_helper\n
-  .popsection);
-
-/*
- * Create a kernel thread.
- */
-pid_t kernel_thread(int (*fn)(void *), 

Re: [PATCH 1/2] unicore32: switch to generic kernel_thread()/kernel_execve()

2012-10-19 Thread Al Viro
On Fri, Oct 19, 2012 at 04:43:09PM +0800, Guan Xuetao wrote:
 From: Al Viro v...@zeniv.linux.org.uk
 
 Signed-off-by: Al Viro v...@zeniv.linux.org.uk
 Acked-and-Tested-by: Guan Xuetao g...@mprc.pku.edu.cn

You mean, it worked modulo obvious missing ')'?  Wow... OK, merged
into signal.git#for-next, obviously in no-rebase mode (as the matter
of fact, I'm dropping the local branch completely).
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] unicore32: switch to generic kernel_thread()/kernel_execve()

2012-10-19 Thread guanxuetao
 On Fri, Oct 19, 2012 at 04:43:09PM +0800, Guan Xuetao wrote:
 From: Al Viro v...@zeniv.linux.org.uk

 Signed-off-by: Al Viro v...@zeniv.linux.org.uk
 Acked-and-Tested-by: Guan Xuetao g...@mprc.pku.edu.cn

 You mean, it worked modulo obvious missing ')'?  Wow... OK, merged
 into signal.git#for-next, obviously in no-rebase mode (as the matter
 of fact, I'm dropping the local branch completely).

I've added')' in the patch. Then it works.
In addition, I pushed these two patches into my tree.

Thanks  regards,
Guan Xuetao
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/