aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/um/Kconfig2
-rw-r--r--arch/um/Makefile-x86_644
-rw-r--r--arch/um/include/sysdep-i386/stub.h29
-rw-r--r--arch/um/include/sysdep-x86_64/stub.h30
-rw-r--r--arch/um/kernel/skas/clone.c23
-rw-r--r--arch/um/scripts/Makefile.rules5
6 files changed, 52 insertions, 41 deletions
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 563301fe5df8..1eb21de9d1b5 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -289,6 +289,8 @@ source "arch/um/Kconfig.net"
289 289
290source "drivers/net/Kconfig" 290source "drivers/net/Kconfig"
291 291
292source "drivers/connector/Kconfig"
293
292source "fs/Kconfig" 294source "fs/Kconfig"
293 295
294source "security/Kconfig" 296source "security/Kconfig"
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 4f118d5cc2ee..38df311e75dc 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -12,3 +12,7 @@ CHECKFLAGS += -m64
12 12
13ELF_ARCH := i386:x86-64 13ELF_ARCH := i386:x86-64
14ELF_FORMAT := elf64-x86-64 14ELF_FORMAT := elf64-x86-64
15
16# Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
17
18LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h
index 6ba8cbbe0d36..b492b12b4a10 100644
--- a/arch/um/include/sysdep-i386/stub.h
+++ b/arch/um/include/sysdep-i386/stub.h
@@ -6,8 +6,12 @@
6#ifndef __SYSDEP_STUB_H 6#ifndef __SYSDEP_STUB_H
7#define __SYSDEP_STUB_H 7#define __SYSDEP_STUB_H
8 8
9#include <sys/mman.h>
9#include <asm/ptrace.h> 10#include <asm/ptrace.h>
10#include <asm/unistd.h> 11#include <asm/unistd.h>
12#include "stub-data.h"
13#include "kern_constants.h"
14#include "uml-config.h"
11 15
12extern void stub_segv_handler(int sig); 16extern void stub_segv_handler(int sig);
13extern void stub_clone_handler(void); 17extern void stub_clone_handler(void);
@@ -76,23 +80,22 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
76 return ret; 80 return ret;
77} 81}
78 82
79static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, 83static inline void trap_myself(void)
80 long arg4, long arg5, long arg6)
81{ 84{
82 long ret; 85 __asm("int3");
83
84 __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; "
85 "int $0x80 ; pop %%ebp"
86 : "=a" (ret)
87 : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3),
88 "S" (arg4), "D" (arg5), "0" (arg6));
89
90 return ret;
91} 86}
92 87
93static inline void trap_myself(void) 88static inline void remap_stack(int fd, unsigned long offset)
94{ 89{
95 __asm("int3"); 90 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
91 "movl %7, %%ebx ; movl %%eax, (%%ebx)"
92 : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA),
93 "c" (UM_KERN_PAGE_SIZE),
94 "d" (PROT_READ | PROT_WRITE),
95 "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
96 "a" (offset),
97 "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
98 : "memory");
96} 99}
97 100
98#endif 101#endif
diff --git a/arch/um/include/sysdep-x86_64/stub.h b/arch/um/include/sysdep-x86_64/stub.h
index c41689c13dc9..92e989f81761 100644
--- a/arch/um/include/sysdep-x86_64/stub.h
+++ b/arch/um/include/sysdep-x86_64/stub.h
@@ -6,8 +6,12 @@
6#ifndef __SYSDEP_STUB_H 6#ifndef __SYSDEP_STUB_H
7#define __SYSDEP_STUB_H 7#define __SYSDEP_STUB_H
8 8
9#include <sys/mman.h>
9#include <asm/unistd.h> 10#include <asm/unistd.h>
10#include <sysdep/ptrace_user.h> 11#include <sysdep/ptrace_user.h>
12#include "stub-data.h"
13#include "kern_constants.h"
14#include "uml-config.h"
11 15
12extern void stub_segv_handler(int sig); 16extern void stub_segv_handler(int sig);
13extern void stub_clone_handler(void); 17extern void stub_clone_handler(void);
@@ -81,23 +85,23 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
81 return ret; 85 return ret;
82} 86}
83 87
84static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, 88static inline void trap_myself(void)
85 long arg4, long arg5, long arg6)
86{ 89{
87 long ret; 90 __asm("int3");
88
89 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; "
90 "movq %7, %%r9; " __syscall : "=a" (ret)
91 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
92 "g" (arg4), "g" (arg5), "g" (arg6)
93 : __syscall_clobber, "r10", "r8", "r9" );
94
95 return ret;
96} 91}
97 92
98static inline void trap_myself(void) 93static inline void remap_stack(long fd, unsigned long offset)
99{ 94{
100 __asm("int3"); 95 __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
96 "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
97 "movq %%rax, (%%rbx)":
98 : "a" (STUB_MMAP_NR), "D" (UML_CONFIG_STUB_DATA),
99 "S" (UM_KERN_PAGE_SIZE),
100 "d" (PROT_READ | PROT_WRITE),
101 "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
102 "g" (offset),
103 "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
104 : __syscall_clobber, "r10", "r8", "r9" );
101} 105}
102 106
103#endif 107#endif
diff --git a/arch/um/kernel/skas/clone.c b/arch/um/kernel/skas/clone.c
index cb37ce9124a6..47b812b3bca8 100644
--- a/arch/um/kernel/skas/clone.c
+++ b/arch/um/kernel/skas/clone.c
@@ -18,11 +18,10 @@
18 * on some systems. 18 * on some systems.
19 */ 19 */
20 20
21#define STUB_DATA(field) (((struct stub_data *) UML_CONFIG_STUB_DATA)->field)
22
23void __attribute__ ((__section__ (".__syscall_stub"))) 21void __attribute__ ((__section__ (".__syscall_stub")))
24stub_clone_handler(void) 22stub_clone_handler(void)
25{ 23{
24 struct stub_data *data = (struct stub_data *) UML_CONFIG_STUB_DATA;
26 long err; 25 long err;
27 26
28 err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD, 27 err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
@@ -35,17 +34,21 @@ stub_clone_handler(void)
35 if(err) 34 if(err)
36 goto out; 35 goto out;
37 36
38 err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL, 37 err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
39 (long) &STUB_DATA(timer), 0); 38 (long) &data->timer, 0);
40 if(err) 39 if(err)
41 goto out; 40 goto out;
42 41
43 err = stub_syscall6(STUB_MMAP_NR, UML_CONFIG_STUB_DATA, 42 remap_stack(data->fd, data->offset);
44 UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, 43 goto done;
45 MAP_FIXED | MAP_SHARED, STUB_DATA(fd), 44
46 STUB_DATA(offset));
47 out: 45 out:
48 /* save current result. Parent: pid; child: retcode of mmap */ 46 /* save current result.
49 STUB_DATA(err) = err; 47 * Parent: pid;
48 * child: retcode of mmap already saved and it jumps around this
49 * assignment
50 */
51 data->err = err;
52 done:
50 trap_myself(); 53 trap_myself();
51} 54}
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index b3fbf125709b..2e41cabd3d93 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -21,11 +21,6 @@ define unprofile
21endef 21endef
22 22
23 23
24# The stubs and unmap.o can't try to call mcount or update basic block data
25define unprofile
26 $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1)))
27endef
28
29# cmd_make_link checks to see if the $(foo-dir) variable starts with a /. If 24# cmd_make_link checks to see if the $(foo-dir) variable starts with a /. If
30# so, it's considered to be a path relative to $(srcdir) rather than 25# so, it's considered to be a path relative to $(srcdir) rather than
31# $(srcdir)/arch/$(SUBARCH). This is because x86_64 wants to get ldt.c from 26# $(srcdir)/arch/$(SUBARCH). This is because x86_64 wants to get ldt.c from