]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - arch/m32r/kernel/sys_m32r.c
[PATCH] provide kernel_execve on all architectures
[mirror_ubuntu-zesty-kernel.git] / arch / m32r / kernel / sys_m32r.c
index 7c29396cc6708f689d6a015aa04da4a55b9e9636..b567351f3c5236d41e0b108a2ba516a86fc170fd 100644 (file)
@@ -25,6 +25,8 @@
 #include <asm/cachectl.h>
 #include <asm/cacheflush.h>
 #include <asm/ipc.h>
+#include <asm/syscall.h>
+#include <asm/unistd.h>
 
 /*
  * sys_tas() - test-and-set
@@ -223,3 +225,21 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
        return -ENOSYS;
 }
 
+/*
+ * 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, char *const argv[], char *const envp[])
+{
+       register long __scno __asm__ ("r7") = __NR_execve;
+       register long __arg3 __asm__ ("r2") = (long)(envp);
+       register long __arg2 __asm__ ("r1") = (long)(argv);
+       register long __res __asm__ ("r0") = (long)(filename);
+       __asm__ __volatile__ (
+               "trap #" SYSCALL_VECTOR "|| nop"
+               : "=r" (__res)
+               : "r" (__scno), "0" (__res), "r" (__arg2),
+                       "r" (__arg3)
+               : "memory");
+       return __res;
+}