[PATCH v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

2013-01-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
Cc: Arnd Bergmann 
---
 arch/arc/include/asm/ptrace.h   |5 ++
 arch/arc/include/asm/syscall.h  |   72 +++
 arch/arc/include/asm/syscalls.h |   30 ++
 arch/arc/include/asm/unistd.h   |   29 ++
 arch/arc/kernel/entry.S |   49 
 arch/arc/kernel/process.c   |  119 +++
 arch/arc/kernel/sys.c   |   19 ++
 7 files changed, 323 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/syscall.h
 create mode 100644 arch/arc/include/asm/syscalls.h
 create mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/kernel/process.c
 create mode 100644 arch/arc/kernel/sys.c

diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index 561c7eb..9abbb7c 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -125,6 +125,11 @@ struct user_regs_struct {
sp = -1;\
sp; \
 })
+
+/* return 1 if in syscall, 0 if Intr or Exception */
+#define in_syscall(regs) (((regs->orig_r8) >= 0 && \
+  (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
new file mode 100644
index 000..33ab304
--- /dev/null
+++ b/arch/arc/include/asm/syscall.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SYSCALL_H
+#define _ASM_ARC_SYSCALL_H  1
+
+#include 
+#include 
+#include 
+#include /* in_syscall() */
+
+static inline long
+syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
+{
+   if (user_mode(regs) && in_syscall(regs))
+   return regs->orig_r8;
+   else
+   return -1;
+}
+
+static inline void
+syscall_rollback(struct task_struct *task, struct pt_regs *regs)
+{
+   /* XXX: I can't fathom how pt_regs->r8 will be clobbered ? */
+   regs->r8 = regs->orig_r8;
+}
+
+static inline long
+syscall_get_error(struct task_struct *task, struct pt_regs *regs)
+{
+   /* 0 if syscall succeeded, otherwise -Errorcode */
+   return IS_ERR_VALUE(regs->r0) ? regs->r0 : 0;
+}
+
+static inline long
+syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
+{
+   return regs->r0;
+}
+
+static inline void
+syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
+int error, long val)
+{
+   regs->r0 = (long) error ?: val;
+}
+
+/*
+ * @i:  argument index [0,5]
+ * @n:  number of arguments; n+i must be [1,6].
+ */
+static inline void
+syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
+ unsigned int i, unsigned int n, unsigned long *args)
+{
+   unsigned long *inside_ptregs = &(regs->r0);
+   inside_ptregs -= i;
+
+   BUG_ON((i + n) > 6);
+
+   while (n--) {
+   args[i++] = (*inside_ptregs);
+   inside_ptregs--;
+   }
+}
+
+#endif
diff --git a/arch/arc/include/asm/syscalls.h b/arch/arc/include/asm/syscalls.h
new file mode 100644
index 000..cf5d2f5
--- /dev/null
+++ b/arch/arc/include/asm/syscalls.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SYSCALLS_H
+#define _ASM_ARC_SYSCALLS_H  1
+
+#ifdef __KERNEL__
+
+#include 
+#include 
+#include 
+
+int sys_execve_wrapper(int, int, int);
+int sys_clone_wrapper(int, int, int, int, int);
+int sys_fork_wrapper(void);
+int sys_vfork_wrapper(void);
+int sys_cacheflush(uint32_t, uint32_t uint32_t);
+int sys_arc_settls(void *);
+int sys_arc_gettls(void);
+
+#include 
+
+#endif /* __KERNEL__ */
+
+#endif
diff --git a/arch/arc/include/asm/unistd.h b/arch/arc/include/asm/unistd.h
new file mode 100644
index 000..6a2d101
--- /dev/null
+++ b/arch/arc/include/asm/unistd.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/ no-legacy-syscalls-ABI ***/
+
+#define sys_mmap2 sys_mmap_pgoff
+
+#include 
+
+#define NR_syscalls__NR_syscalls
+
+/* ARC specific syscall */
+#define __NR_cacheflush(__NR_arch_specific_syscall + 0)
+#define __NR_arc_settls(__NR_arch_specific_syscall +

Re: [PATCH v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

2013-01-18 Thread Arnd Bergmann
On Friday 18 January 2013, Vineet Gupta wrote:
> Signed-off-by: Vineet Gupta 
> Cc: Arnd Bergmann 

Acked-by: Arnd Bergmann 
--
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 v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

2013-01-18 Thread Al Viro
Please, collapse your #36--#40 into that one (and I'd probably fold #17
here as well, to simplify that reordering).  Sure, it's not a bisection
hazard, but...
--
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 v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

2013-01-19 Thread Vineet Gupta
On Saturday 19 January 2013 08:39 AM, Al Viro wrote:
> Please, collapse your #36--#40 into that one (and I'd probably fold #17
> here as well, to simplify that reordering).  Sure, it's not a bisection
> hazard, but...

Thanks again for the review Al.

Sure, I can do that - however because those patches have bits in 
arch/arc/Kconfig,
I'll have to move the Build system patch towards start of series, or simply chop
off Kconfig bits out of those and add them later - what do you prefer ?

My only reason for chunking those up was to capture the intermediate development
of how execve and friends were generalized (and have limited revision history 
even
in initial upstream version). While I was used to the old code, specially
copy_thread() between 1st and last change seemed to be almost rewritten.  Having
said that, I don't have strong opinion either ways.

Thx,
-Vineet
--
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 v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

2013-01-20 Thread Vineet Gupta
On Saturday 19 January 2013 08:39 AM, Al Viro wrote:
> Please, collapse your #36--#40 into that one (and I'd probably fold #17
> here as well, to simplify that reordering).  Sure, it's not a bisection
> hazard, but...
> 

I kept #16 and #17 distinct and

  * squashed switch-to-generic-kernel-thread #36 into process creation patch #17
  * split generic kernel_execve and sys_execve #37 into two
* squashed sys_execve bits into syscall patch #16
* squashed kernel_execve patch into #17
  * squashed switch-to-saner-execve patches #38 and #39 into #17
  * squashed generic clone patch #40 into #16

--
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/