aboutsummaryrefslogtreecommitdiff
path: root/arch/um
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/Kconfig2
-rw-r--r--arch/um/Makefile2
-rw-r--r--arch/um/Makefile-x86_644
-rw-r--r--arch/um/include/sysdep-i386/stub.h38
-rw-r--r--arch/um/include/sysdep-x86_64/stub.h42
-rw-r--r--arch/um/include/um_uaccess.h2
-rw-r--r--arch/um/kernel/skas/clone.c28
-rw-r--r--arch/um/kernel/skas/include/uaccess-skas.h1
-rw-r--r--arch/um/os-Linux/start_up.c22
-rw-r--r--arch/um/os-Linux/user_syms.c5
-rw-r--r--arch/um/scripts/Makefile.rules5
-rw-r--r--arch/um/sys-i386/Makefile10
-rw-r--r--arch/um/sys-i386/ldt.c35
-rw-r--r--arch/um/sys-i386/stub_segv.c11
-rw-r--r--arch/um/sys-x86_64/Makefile7
-rw-r--r--arch/um/sys-x86_64/stub_segv.c20
16 files changed, 144 insertions, 90 deletions
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 563301fe5df..1eb21de9d1b 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -289,6 +289,8 @@ source "arch/um/Kconfig.net"
source "drivers/net/Kconfig"
+source "drivers/connector/Kconfig"
+
source "fs/Kconfig"
source "security/Kconfig"
diff --git a/arch/um/Makefile b/arch/um/Makefile
index e55d32e903b..1b12feeba36 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -17,7 +17,7 @@ core-y += $(ARCH_DIR)/kernel/ \
# Have to precede the include because the included Makefiles reference them.
SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \
- module.h vm-flags.h elf.h
+ module.h vm-flags.h elf.h ldt.h
SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
# XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 4f118d5cc2e..38df311e75d 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -12,3 +12,7 @@ CHECKFLAGS += -m64
ELF_ARCH := i386:x86-64
ELF_FORMAT := elf64-x86-64
+
+# Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
+
+LINK-$(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 a49ceb199ee..b492b12b4a1 100644
--- a/arch/um/include/sysdep-i386/stub.h
+++ b/arch/um/include/sysdep-i386/stub.h
@@ -6,8 +6,12 @@
#ifndef __SYSDEP_STUB_H
#define __SYSDEP_STUB_H
+#include <sys/mman.h>
#include <asm/ptrace.h>
#include <asm/unistd.h>
+#include "stub-data.h"
+#include "kern_constants.h"
+#include "uml-config.h"
extern void stub_segv_handler(int sig);
extern void stub_clone_handler(void);
@@ -16,6 +20,15 @@ extern void stub_clone_handler(void);
#define STUB_MMAP_NR __NR_mmap2
#define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT)
+static inline long stub_syscall0(long syscall)
+{
+ long ret;
+
+ __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
+
+ return ret;
+}
+
static inline long stub_syscall1(long syscall, long arg1)
{
long ret;
@@ -67,23 +80,22 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
return ret;
}
-static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
- long arg4, long arg5, long arg6)
+static inline void trap_myself(void)
{
- long ret;
-
- __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; "
- "int $0x80 ; pop %%ebp"
- : "=a" (ret)
- : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3),
- "S" (arg4), "D" (arg5), "0" (arg6));
-
- return ret;
+ __asm("int3");
}
-static inline void trap_myself(void)
+static inline void remap_stack(int fd, unsigned long offset)
{
- __asm("int3");
+ __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
+ "movl %7, %%ebx ; movl %%eax, (%%ebx)"
+ : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA),
+ "c" (UM_KERN_PAGE_SIZE),
+ "d" (PROT_READ | PROT_WRITE),
+ "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
+ "a" (offset),
+ "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
+ : "memory");
}
#endif
diff --git a/arch/um/include/sysdep-x86_64/stub.h b/arch/um/include/sysdep-x86_64/stub.h
index 2bd6e7a9728..92e989f8176 100644
--- a/arch/um/include/sysdep-x86_64/stub.h
+++ b/arch/um/include/sysdep-x86_64/stub.h
@@ -6,9 +6,12 @@
#ifndef __SYSDEP_STUB_H
#define __SYSDEP_STUB_H
-#include <asm/ptrace.h>
+#include <sys/mman.h>
#include <asm/unistd.h>
#include <sysdep/ptrace_user.h>
+#include "stub-data.h"
+#include "kern_constants.h"
+#include "uml-config.h"
extern void stub_segv_handler(int sig);
extern void stub_clone_handler(void);
@@ -20,6 +23,17 @@ extern void stub_clone_handler(void);
#define __syscall_clobber "r11","rcx","memory"
#define __syscall "syscall"
+static inline long stub_syscall0(long syscall)
+{
+ long ret;
+
+ __asm__ volatile (__syscall
+ : "=a" (ret)
+ : "0" (syscall) : __syscall_clobber );
+
+ return ret;
+}
+
static inline long stub_syscall2(long syscall, long arg1, long arg2)
{
long ret;
@@ -71,23 +85,23 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
return ret;
}
-static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
- long arg4, long arg5, long arg6)
+static inline void trap_myself(void)
{
- long ret;
-
- __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; "
- "movq %7, %%r9; " __syscall : "=a" (ret)
- : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
- "g" (arg4), "g" (arg5), "g" (arg6)
- : __syscall_clobber, "r10", "r8", "r9" );
-
- return ret;
+ __asm("int3");
}
-static inline void trap_myself(void)
+static inline void remap_stack(long fd, unsigned long offset)
{
- __asm("int3");
+ __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
+ "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
+ "movq %%rax, (%%rbx)":
+ : "a" (STUB_MMAP_NR), "D" (UML_CONFIG_STUB_DATA),
+ "S" (UM_KERN_PAGE_SIZE),
+ "d" (PROT_READ | PROT_WRITE),
+ "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
+ "g" (offset),
+ "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
+ : __syscall_clobber, "r10", "r8", "r9" );
}
#endif
diff --git a/arch/um/include/um_uaccess.h b/arch/um/include/um_uaccess.h
index f8760a3f43b..4567f1eeb4a 100644
--- a/arch/um/include/um_uaccess.h
+++ b/arch/um/include/um_uaccess.h
@@ -17,6 +17,8 @@
#include "uaccess-skas.h"
#endif
+#include "asm/fixmap.h"
+
#define __under_task_size(addr, size) \
(((unsigned long) (addr) < TASK_SIZE) && \
(((unsigned long) (addr) + (size)) < TASK_SIZE))
diff --git a/arch/um/kernel/skas/clone.c b/arch/um/kernel/skas/clone.c
index 4dc55f10cd1..47b812b3bca 100644
--- a/arch/um/kernel/skas/clone.c
+++ b/arch/um/kernel/skas/clone.c
@@ -9,18 +9,23 @@
#include "stub-data.h"
#include "uml-config.h"
#include "sysdep/stub.h"
+#include "kern_constants.h"
/* This is in a separate file because it needs to be compiled with any
* extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
+ *
+ * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
+ * on some systems.
*/
+
void __attribute__ ((__section__ (".__syscall_stub")))
stub_clone_handler(void)
{
+ struct stub_data *data = (struct stub_data *) UML_CONFIG_STUB_DATA;
long err;
- struct stub_data *from = (struct stub_data *) UML_CONFIG_STUB_DATA;
err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
- UML_CONFIG_STUB_DATA + PAGE_SIZE / 2 -
+ UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE / 2 -
sizeof(void *));
if(err != 0)
goto out;
@@ -29,16 +34,21 @@ stub_clone_handler(void)
if(err)
goto out;
- err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
- (long) &from->timer, 0);
+ err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
+ (long) &data->timer, 0);
if(err)
goto out;
- err = stub_syscall6(STUB_MMAP_NR, UML_CONFIG_STUB_DATA, PAGE_SIZE,
- PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED,
- from->fd, from->offset);
+ remap_stack(data->fd, data->offset);
+ goto done;
+
out:
- /* save current result. Parent: pid; child: retcode of mmap */
- from->err = err;
+ /* save current result.
+ * Parent: pid;
+ * child: retcode of mmap already saved and it jumps around this
+ * assignment
+ */
+ data->err = err;
+ done:
trap_myself();
}
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h
index f611f83ad4f..64516c556cd 100644
--- a/arch/um/kernel/skas/include/uaccess-skas.h
+++ b/arch/um/kernel/skas/include/uaccess-skas.h
@@ -7,7 +7,6 @@
#define __SKAS_UACCESS_H
#include "asm/errno.h"
-#include "asm/fixmap.h"
/* No SKAS-specific checking. */
#define access_ok_skas(type, addr, size) 0
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 37517d49c4a..29a9e3f4376 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -116,16 +116,16 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode,
if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
int exit_with = WEXITSTATUS(status);
if (exit_with == 2)
- printk("check_ptrace : child exited with status 2. "
+ printf("check_ptrace : child exited with status 2. "
"Serious trouble happening! Try updating your "
"host skas patch!\nDisabling SYSEMU support.");
- printk("check_ptrace : child exited with exitcode %d, while "
+ printf("check_ptrace : child exited with exitcode %d, while "
"expecting %d; status 0x%x", exit_with,
exitcode, status);
if (mustpanic)
panic("\n");
else
- printk("\n");
+ printf("\n");
ret = -1;
}
@@ -183,7 +183,7 @@ static void __init check_sysemu(void)
void *stack;
int pid, n, status, count=0;
- printk("Checking syscall emulation patch for ptrace...");
+ printf("Checking syscall emulation patch for ptrace...");
sysemu_supported = 0;
pid = start_ptraced_child(&stack);
@@ -207,10 +207,10 @@ static void __init check_sysemu(void)
goto fail_stopped;
sysemu_supported = 1;
- printk("OK\n");
+ printf("OK\n");
set_using_sysemu(!force_sysemu_disabled);
- printk("Checking advanced syscall emulation patch for ptrace...");
+ printf("Checking advanced syscall emulation patch for ptrace...");
pid = start_ptraced_child(&stack);
if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
@@ -246,7 +246,7 @@ static void __init check_sysemu(void)
goto fail_stopped;
sysemu_supported = 2;
- printk("OK\n");
+ printf("OK\n");
if ( !force_sysemu_disabled )
set_using_sysemu(sysemu_supported);
@@ -255,7 +255,7 @@ static void __init check_sysemu(void)
fail:
stop_ptraced_child(pid, stack, 1, 0);
fail_stopped:
- printk("missing\n");
+ printf("missing\n");
}
static void __init check_ptrace(void)
@@ -263,7 +263,7 @@ static void __init check_ptrace(void)
void *stack;
int pid, syscall, n, status;
- printk("Checking that ptrace can change system call numbers...");
+ printf("Checking that ptrace can change system call numbers...");
pid = start_ptraced_child(&stack);
if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
@@ -292,7 +292,7 @@ static void __init check_ptrace(void)
}
}
stop_ptraced_child(pid, stack, 0, 1);
- printk("OK\n");
+ printf("OK\n");
check_sysemu();
}
@@ -472,6 +472,8 @@ int can_do_skas(void)
int have_devanon = 0;
+/* Runs on boot kernel stack - already safe to use printk. */
+
void check_devanon(void)
{
int fd;
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index 56d3f870926..8da6ab31152 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -34,6 +34,11 @@ EXPORT_SYMBOL(strstr);
int sym(void); \
EXPORT_SYMBOL(sym);
+extern void readdir64(void) __attribute__((weak));
+EXPORT_SYMBOL(readdir64);
+extern void truncate64(void) __attribute__((weak));
+EXPORT_SYMBOL(truncate64);
+
#ifdef SUBARCH_i386
EXPORT_SYMBOL(vsyscall_ehdr);
EXPORT_SYMBOL(vsyscall_end);
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index b3fbf125709..2e41cabd3d9 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -21,11 +21,6 @@ define unprofile
endef
-# The stubs and unmap.o can't try to call mcount or update basic block data
-define unprofile
- $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1)))
-endef
-
# cmd_make_link checks to see if the $(foo-dir) variable starts with a /. If
# so, it's considered to be a path relative to $(srcdir) rather than
# $(srcdir)/arch/$(SUBARCH). This is because x86_64 wants to get ldt.c from
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 6dfeb70f695..f5fd5b0156d 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -1,11 +1,13 @@
-obj-y = bitops.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
- ptrace_user.o semaphore.o signal.o sigcontext.o stub.o stub_segv.o \
- syscalls.o sysrq.o sys_call_table.o
+obj-y := bitops.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
+ ptrace_user.o semaphore.o signal.o sigcontext.o syscalls.o sysrq.o \
+ sys_call_table.o
+
+obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
obj-$(CONFIG_HIGHMEM) += highmem.o
obj-$(CONFIG_MODULES) += module.o
-USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
+USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o stub_segv.o
SYMLINKS = bitops.c semaphore.c highmem.c module.c
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 6360f1c958d..17746b4c08f 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -228,7 +228,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES;
if(size > bytecount)
size = bytecount;
- if(copy_to_user(ptr, ldt->entries, size))
+ if(copy_to_user(ptr, ldt->u.entries, size))
err = -EFAULT;
bytecount -= size;
ptr += size;
@@ -239,7 +239,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
size = PAGE_SIZE;
if(size > bytecount)
size = bytecount;
- if(copy_to_user(ptr, ldt->pages[i], size)){
+ if(copy_to_user(ptr, ldt->u.pages[i], size)){
err = -EFAULT;
break;
}
@@ -321,10 +321,11 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number;
i++){
if(i == 0)
- memcpy(&entry0, ldt->entries, sizeof(entry0));
- ldt->pages[i] = (struct ldt_entry *)
- __get_free_page(GFP_KERNEL|__GFP_ZERO);
- if(!ldt->pages[i]){
+ memcpy(&entry0, ldt->u.entries,
+ sizeof(entry0));
+ ldt->u.pages[i] = (struct ldt_entry *)
+ __get_free_page(GFP_KERNEL|__GFP_ZERO);
+ if(!ldt->u.pages[i]){
err = -ENOMEM;
/* Undo the change in host */
memset(&ldt_info, 0, sizeof(ldt_info));
@@ -332,8 +333,9 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
goto out_unlock;
}
if(i == 0) {
- memcpy(ldt->pages[0], &entry0, sizeof(entry0));
- memcpy(ldt->pages[0]+1, ldt->entries+1,
+ memcpy(ldt->u.pages[0], &entry0,
+ sizeof(entry0));
+ memcpy(ldt->u.pages[0]+1, ldt->u.entries+1,
sizeof(entry0)*(LDT_DIRECT_ENTRIES-1));
}
ldt->entry_count = (i + 1) * LDT_ENTRIES_PER_PAGE;
@@ -343,9 +345,9 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
ldt->entry_count = ldt_info.entry_number + 1;
if(ldt->entry_count <= LDT_DIRECT_ENTRIES)
- ldt_p = ldt->entries + ldt_info.entry_number;
+ ldt_p = ldt->u.entries + ldt_info.entry_number;
else
- ldt_p = ldt->pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] +
+ ldt_p = ldt->u.pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] +
ldt_info.entry_number%LDT_ENTRIES_PER_PAGE;
if(ldt_info.base_addr == 0 && ldt_info.limit == 0 &&
@@ -501,8 +503,8 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
*/
down(&from_mm->ldt.semaphore);
if(from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES){
- memcpy(new_mm->ldt.entries, from_mm->ldt.entries,
- sizeof(new_mm->ldt.entries));
+ memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries,
+ sizeof(new_mm->ldt.u.entries));
}
else{
i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE;
@@ -512,9 +514,10 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
err = -ENOMEM;
break;
}
- new_mm->ldt.pages[i] = (struct ldt_entry*)page;
- memcpy(new_mm->ldt.pages[i],
- from_mm->ldt.pages[i], PAGE_SIZE);
+ new_mm->ldt.u.pages[i] =
+ (struct ldt_entry *) page;
+ memcpy(new_mm->ldt.u.pages[i],
+ from_mm->ldt.u.pages[i], PAGE_SIZE);
}
}
new_mm->ldt.entry_count = from_mm->ldt.entry_count;
@@ -532,7 +535,7 @@ void free_ldt(struct mmu_context_skas * mm)
if(!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES){
i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE;
while(i-- > 0){
- free_page((long )mm->ldt.pages[i]);
+ free_page((long )mm->ldt.u.pages[i]);
}
}
mm->ldt.entry_count = 0;
diff --git a/arch/um/sys-i386/stub_segv.c b/arch/um/sys-i386/stub_segv.c
index 1e88b275eda..a37f672ec96 100644
--- a/arch/um/sys-i386/stub_segv.c
+++ b/arch/um/sys-i386/stub_segv.c
@@ -3,9 +3,11 @@
* Licensed under the GPL
*/
-#include <asm/signal.h>
+#include <signal.h>
+#include <sys/select.h> /* The only way I can see to get sigset_t */
#include <asm/unistd.h>
#include "uml-config.h"
+#include "sysdep/stub.h"
#include "sysdep/sigcontext.h"
#include "sysdep/faultinfo.h"
@@ -13,13 +15,14 @@ void __attribute__ ((__section__ (".__syscall_stub")))
stub_segv_handler(int sig)
{
struct sigcontext *sc = (struct sigcontext *) (&sig + 1);
+ int pid;
GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
sc);
- __asm__("movl %0, %%eax ; int $0x80": : "g" (__NR_getpid));
- __asm__("movl %%eax, %%ebx ; movl %0, %%eax ; movl %1, %%ecx ;"
- "int $0x80": : "g" (__NR_kill), "g" (SIGUSR1));
+ pid = stub_syscall0(__NR_getpid);
+ stub_syscall2(__NR_kill, pid, SIGUSR1);
+
/* Load pointer to sigcontext into esp, since we need to leave
* the stack in its original form when we do the sigreturn here, by
* hand.
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
index ea977df395a..a351091fbd9 100644
--- a/arch/um/sys-x86_64/Makefile
+++ b/arch/um/sys-x86_64/Makefile
@@ -6,13 +6,14 @@
#XXX: why into lib-y?
lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o ldt.o mem.o memcpy.o \
- ptrace.o ptrace_user.o sigcontext.o signal.o stub.o \
- stub_segv.o syscalls.o syscall_table.o sysrq.o thunk.o
+ ptrace.o ptrace_user.o sigcontext.o signal.o syscalls.o \
+ syscall_table.o sysrq.o thunk.o
+lib-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
obj-y := ksyms.o
obj-$(CONFIG_MODULES) += module.o um_module.o
-USER_OBJS := ptrace_user.o sigcontext.o
+USER_OBJS := ptrace_user.o sigcontext.o stub_segv.o
SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c ldt.c memcpy.S \
thunk.S module.c
diff --git a/arch/um/sys-x86_64/stub_segv.c b/arch/um/sys-x86_64/stub_segv.c
index d1e53bdf2e8..a2709953319 100644
--- a/arch/um/sys-x86_64/stub_segv.c
+++ b/arch/um/sys-x86_64/stub_segv.c
@@ -3,14 +3,14 @@
* Licensed under the GPL
*/
-#include <asm/signal.h>
+#include <stddef.h>
+#include <signal.h>
#include <linux/compiler.h>
#include <asm/unistd.h>
-#include <asm/ucontext.h>
#include "uml-config.h"
#include "sysdep/sigcontext.h"
#include "sysdep/faultinfo.h"
-#include <stddef.h>
+#include "sysdep/stub.h"
/* Copied from sys-x86_64/signal.c - Can't find an equivalent definition
* in the libc headers anywhere.
@@ -31,21 +31,21 @@ void __attribute__ ((__section__ (".__syscall_stub")))
stub_segv_handler(int sig)
{
struct ucontext *uc;
+ int pid;
__asm__("movq %%rdx, %0" : "=g" (uc) :);
GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
&uc->uc_mcontext);
- __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
- __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;"
- "syscall": : "g" (__NR_kill), "g" (SIGUSR1) :
- "%rdi", "%rax", "%rsi");
+ pid = stub_syscall0(__NR_getpid);
+ stub_syscall2(__NR_kill, pid, SIGUSR1);
+
/* sys_sigreturn expects that the stack pointer will be 8 bytes into
* the signal frame. So, we use the ucontext pointer, which we know
* already, to get the signal frame pointer, and add 8 to that.
*/
- __asm__("movq %0, %%rsp": :
+ __asm__("movq %0, %%rsp; movq %1, %%rax ; syscall": :
"g" ((unsigned long) container_of(uc, struct rt_sigframe,
- uc) + 8));
- __asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn));
+ uc) + 8),
+ "g" (__NR_rt_sigreturn));
}