diff options
Diffstat (limited to 'arch/um/os-Linux')
33 files changed, 59 insertions, 557 deletions
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index b33f4dfe7ae..dd764101e48 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -4,14 +4,14 @@  #  obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ -	registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ -	umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ +	registers.o sigio.o signal.o start_up.o time.o tty.o \ +	umid.o user_syms.o util.o drivers/ skas/  obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o  USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \  	main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ -	tty.o tls.o uaccess.o umid.o util.o +	tty.o umid.o util.o  CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index 57e3d46c989..c5d039e1ff3 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c @@ -11,10 +11,8 @@  #include <asm/unistd.h>  #include "aio.h"  #include "init.h" -#include "kern_constants.h"  #include "kern_util.h"  #include "os.h" -#include "user.h"  struct aio_thread_req {  	enum aio_type type; diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c index cc72cb2c1af..db3d6481375 100644 --- a/arch/um/os-Linux/drivers/ethertap_user.c +++ b/arch/um/os-Linux/drivers/ethertap_user.c @@ -13,11 +13,9 @@  #include <sys/socket.h>  #include <sys/wait.h>  #include "etap.h" -#include "kern_constants.h"  #include "os.h"  #include "net_user.h"  #include "um_malloc.h" -#include "user.h"  #define MAX_PACKET ETH_MAX_PACKET diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c index 2448be03fd7..a2aacffdd90 100644 --- a/arch/um/os-Linux/drivers/tuntap_user.c +++ b/arch/um/os-Linux/drivers/tuntap_user.c @@ -13,11 +13,9 @@  #include <sys/socket.h>  #include <sys/wait.h>  #include <sys/uio.h> -#include "kern_constants.h"  #include "kern_util.h"  #include "os.h"  #include "tuntap.h" -#include "user.h"  static int tuntap_user_init(void *data, void *dev)  { diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index 95332379938..d895271ad6f 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c @@ -12,7 +12,6 @@  #include "init.h"  #include "elf_user.h"  #include "mem_user.h" -#include <kern_constants.h>  typedef Elf32_auxv_t elf_auxv_t; diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 140e587bc0a..b049a63bb74 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c @@ -13,9 +13,7 @@  #include <sys/socket.h>  #include <sys/stat.h>  #include <sys/un.h> -#include "kern_constants.h"  #include "os.h" -#include "user.h"  static void copy_stat(struct uml_stat *dst, const struct stat64 *src)  { diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index feff22d6467..cf26c4a9a43 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c @@ -10,11 +10,9 @@  #include <linux/limits.h>  #include <sys/socket.h>  #include <sys/wait.h> -#include "kern_constants.h"  #include "kern_util.h"  #include "os.h"  #include "um_malloc.h" -#include "user.h"  struct helper_data {  	void (*pre_exec)(void*); diff --git a/arch/um/os-Linux/internal.h b/arch/um/os-Linux/internal.h new file mode 100644 index 00000000000..2c3c3ecd8c0 --- /dev/null +++ b/arch/um/os-Linux/internal.h @@ -0,0 +1 @@ +void alarm_handler(int, mcontext_t *); diff --git a/arch/um/os-Linux/irq.c b/arch/um/os-Linux/irq.c index 0348b975e81..9a49908b576 100644 --- a/arch/um/os-Linux/irq.c +++ b/arch/um/os-Linux/irq.c @@ -9,11 +9,8 @@  #include <signal.h>  #include <string.h>  #include "irq_user.h" -#include "kern_constants.h"  #include "os.h" -#include "process.h"  #include "um_malloc.h" -#include "user.h"  /*   * Locked by irq_lock in arch/um/kernel/irq.c.  Changed by os_create_pollfd diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index 8471b817d94..7a86dd516eb 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c @@ -12,7 +12,6 @@  #include <sys/resource.h>  #include "as-layout.h"  #include "init.h" -#include "kern_constants.h"  #include "kern_util.h"  #include "os.h"  #include "um_malloc.h" diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 62878cf1d33..8e421e1d6d3 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c @@ -14,9 +14,7 @@  #include <sys/mman.h>  #include <sys/param.h>  #include "init.h" -#include "kern_constants.h"  #include "os.h" -#include "user.h"  /* Modified by which_tmpdir, which is called during early boot */  static char *default_tmpdir = "/tmp"; diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 0c45dc8efb0..307f173e7f8 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -13,12 +13,9 @@  #include <sys/wait.h>  #include <asm/unistd.h>  #include "init.h" -#include "kern_constants.h"  #include "longjmp.h"  #include "os.h" -#include "process.h"  #include "skas_ptrace.h" -#include "user.h"  #define ARBITRARY_ADDR -1  #define FAILURE_PID    -1 @@ -237,21 +234,13 @@ out:  void init_new_thread_signals(void)  { -	set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK, -		    SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); -	set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK, -		    SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); -	set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK, -		    SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); -	set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK, -		    SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); -	set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK, -		    SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); +	set_handler(SIGSEGV); +	set_handler(SIGTRAP); +	set_handler(SIGFPE); +	set_handler(SIGILL); +	set_handler(SIGBUS);  	signal(SIGHUP, SIG_IGN); - -	set_handler(SIGIO, (__sighandler_t) sig_handler, -		    SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -		    SIGVTALRM, -1); +	set_handler(SIGIO);  	signal(SIGWINCH, SIG_IGN);  	signal(SIGTERM, SIG_DFL);  } diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index 63d299df152..3c161218c67 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c @@ -11,14 +11,11 @@  #include <sched.h>  #include <signal.h>  #include <string.h> -#include "kern_constants.h"  #include "kern_util.h"  #include "init.h"  #include "os.h" -#include "process.h"  #include "sigio.h"  #include "um_malloc.h" -#include "user.h"  /*   * Protected by sigio_lock(), also used by sigio_cleanup, which is an diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 6ae180703a6..2d22f1fcd8e 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -12,13 +12,7 @@  #include "as-layout.h"  #include "kern_util.h"  #include "os.h" -#include "process.h" -#include "sysdep/barrier.h" -#include "sysdep/sigcontext.h" -#include "user.h" - -/* Copied from linux/compiler-gcc.h since we can't include it directly */ -#define barrier() __asm__ __volatile__("": : :"memory") +#include "sysdep/mcontext.h"  void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {  	[SIGTRAP]	= relay_signal, @@ -30,7 +24,7 @@ void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {  	[SIGIO]		= sigio_handler,  	[SIGVTALRM]	= timer_handler }; -static void sig_handler_common(int sig, struct sigcontext *sc) +static void sig_handler_common(int sig, mcontext_t *mc)  {  	struct uml_pt_regs r;  	int save_errno = errno; @@ -38,8 +32,8 @@ static void sig_handler_common(int sig, struct sigcontext *sc)  	r.is_user = 0;  	if (sig == SIGSEGV) {  		/* For segfaults, we want the data from the sigcontext. */ -		copy_sc(&r, sc); -		GET_FAULTINFO_FROM_SC(r.faultinfo, sc); +		get_regs_from_mc(&r, mc); +		GET_FAULTINFO_FROM_MC(r.faultinfo, mc);  	}  	/* enable signals if sig isn't IRQ signal */ @@ -66,7 +60,7 @@ static void sig_handler_common(int sig, struct sigcontext *sc)  static int signals_enabled;  static unsigned int signals_pending; -void sig_handler(int sig, struct sigcontext *sc) +void sig_handler(int sig, mcontext_t *mc)  {  	int enabled; @@ -78,23 +72,23 @@ void sig_handler(int sig, struct sigcontext *sc)  	block_signals(); -	sig_handler_common(sig, sc); +	sig_handler_common(sig, mc);  	set_signals(enabled);  } -static void real_alarm_handler(struct sigcontext *sc) +static void real_alarm_handler(mcontext_t *mc)  {  	struct uml_pt_regs regs; -	if (sc != NULL) -		copy_sc(®s, sc); +	if (mc != NULL) +		get_regs_from_mc(®s, mc);  	regs.is_user = 0;  	unblock_signals();  	timer_handler(SIGVTALRM, ®s);  } -void alarm_handler(int sig, struct sigcontext *sc) +void alarm_handler(int sig, mcontext_t *mc)  {  	int enabled; @@ -106,14 +100,13 @@ void alarm_handler(int sig, struct sigcontext *sc)  	block_signals(); -	real_alarm_handler(sc); +	real_alarm_handler(mc);  	set_signals(enabled);  }  void timer_init(void)  { -	set_handler(SIGVTALRM, (__sighandler_t) alarm_handler, -		    SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, -1); +	set_handler(SIGVTALRM);  }  void set_sigstack(void *sig_stack, int size) @@ -126,10 +119,23 @@ void set_sigstack(void *sig_stack, int size)  		panic("enabling signal stack failed, errno = %d\n", errno);  } -static void (*handlers[_NSIG])(int sig, struct sigcontext *sc); +static void (*handlers[_NSIG])(int sig, mcontext_t *mc) = { +	[SIGSEGV] = sig_handler, +	[SIGBUS] = sig_handler, +	[SIGILL] = sig_handler, +	[SIGFPE] = sig_handler, +	[SIGTRAP] = sig_handler, + +	[SIGIO] = sig_handler, +	[SIGWINCH] = sig_handler, +	[SIGVTALRM] = alarm_handler +}; + -void handle_signal(int sig, struct sigcontext *sc) +static void hard_handler(int sig, siginfo_t *info, void *p)  { +	struct ucontext *uc = p; +	mcontext_t *mc = &uc->uc_mcontext;  	unsigned long pending = 1UL << sig;  	do { @@ -155,7 +161,7 @@ void handle_signal(int sig, struct sigcontext *sc)  		while ((sig = ffs(pending)) != 0){  			sig--;  			pending &= ~(1 << sig); -			(*handlers[sig])(sig, sc); +			(*handlers[sig])(sig, mc);  		}  		/* @@ -169,28 +175,26 @@ void handle_signal(int sig, struct sigcontext *sc)  	} while (pending);  } -extern void hard_handler(int sig); - -void set_handler(int sig, void (*handler)(int), int flags, ...) +void set_handler(int sig)  {  	struct sigaction action; -	va_list ap; +	int flags = SA_SIGINFO | SA_ONSTACK;  	sigset_t sig_mask; -	int mask; -	handlers[sig] = (void (*)(int, struct sigcontext *)) handler; -	action.sa_handler = hard_handler; +	action.sa_sigaction = hard_handler; +	/* block irq ones */  	sigemptyset(&action.sa_mask); - -	va_start(ap, flags); -	while ((mask = va_arg(ap, int)) != -1) -		sigaddset(&action.sa_mask, mask); -	va_end(ap); +	sigaddset(&action.sa_mask, SIGVTALRM); +	sigaddset(&action.sa_mask, SIGIO); +	sigaddset(&action.sa_mask, SIGWINCH);  	if (sig == SIGSEGV)  		flags |= SA_NODEFER; +	if (sigismember(&action.sa_mask, sig)) +		flags |= SA_RESTART; /* if it's an irq signal */ +  	action.sa_flags = flags;  	action.sa_restorer = NULL;  	if (sigaction(sig, &action, NULL) < 0) diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c index e771398be5f..c0afff7af4b 100644 --- a/arch/um/os-Linux/skas/mem.c +++ b/arch/um/os-Linux/skas/mem.c @@ -9,7 +9,6 @@  #include <string.h>  #include <sys/mman.h>  #include "init.h" -#include "kern_constants.h"  #include "as-layout.h"  #include "mm_id.h"  #include "os.h" @@ -17,7 +16,6 @@  #include "ptrace_user.h"  #include "registers.h"  #include "skas.h" -#include "user.h"  #include "sysdep/ptrace.h"  #include "sysdep/stub.h" diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index dee0e8cf8ad..cd65727854e 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -9,31 +9,23 @@  #include <errno.h>  #include <string.h>  #include <sys/mman.h> -#include <sys/ptrace.h>  #include <sys/wait.h>  #include <asm/unistd.h>  #include "as-layout.h" -#include "chan_user.h" -#include "kern_constants.h" +#include "init.h"  #include "kern_util.h"  #include "mem.h"  #include "os.h" -#include "process.h"  #include "proc_mm.h"  #include "ptrace_user.h"  #include "registers.h"  #include "skas.h"  #include "skas_ptrace.h" -#include "user.h"  #include "sysdep/stub.h"  int is_skas_winch(int pid, int fd, void *data)  { -	if (pid != getpgrp()) -		return 0; - -	register_winch_irq(-1, fd, -1, data, 0); -	return 1; +	return pid == getpgrp();  }  static int ptrace_dump_regs(int pid) @@ -169,7 +161,7 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,  	if (!local_using_sysemu)  	{ -		err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, +		err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,  			     __NR_getpid);  		if (err < 0) {  			printk(UM_KERN_ERR "handle_trap - nullifying syscall " @@ -257,8 +249,8 @@ static int userspace_tramp(void *stack)  		set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE);  		sigemptyset(&sa.sa_mask); -		sa.sa_flags = SA_ONSTACK | SA_NODEFER; -		sa.sa_handler = (void *) v; +		sa.sa_flags = SA_ONSTACK | SA_NODEFER | SA_SIGINFO; +		sa.sa_sigaction = (void *) v;  		sa.sa_restorer = NULL;  		if (sigaction(SIGSEGV, &sa, NULL) < 0) {  			printk(UM_KERN_ERR "userspace_tramp - setting SIGSEGV " @@ -661,8 +653,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)  {  	int n; -	set_handler(SIGWINCH, (__sighandler_t) sig_handler, -		    SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGVTALRM, -1); +	set_handler(SIGWINCH);  	/*  	 * Can't use UML_SETJMP or UML_LONGJMP here because they save diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 02ee9adff54..425162e22af 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c @@ -13,12 +13,10 @@  #include <signal.h>  #include <string.h>  #include <sys/mman.h> -#include <sys/ptrace.h>  #include <sys/stat.h>  #include <sys/wait.h>  #include <asm/unistd.h>  #include "init.h" -#include "kern_constants.h"  #include "os.h"  #include "mem_user.h"  #include "ptrace_user.h" @@ -225,7 +223,7 @@ static void __init check_sysemu(void)  		goto fail;  	} -	n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); +	n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, os_getpid());  	if (n < 0) {  		non_fatal("check_sysemu : failed to modify system call "  			  "return"); @@ -261,7 +259,7 @@ static void __init check_sysemu(void)  					  "doesn't singlestep");  				goto fail;  			} -			n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, +			n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET,  				   os_getpid());  			if (n < 0)  				fatal_perror("check_sysemu : failed to modify " @@ -317,10 +315,10 @@ static void __init check_ptrace(void)  			fatal("check_ptrace : expected (SIGTRAP|0x80), "  			       "got status = %d", status); -		syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, +		syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET,  				 0);  		if (syscall == __NR_getpid) { -			n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, +			n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,  				   __NR_getppid);  			if (n < 0)  				fatal_perror("check_ptrace : failed to modify " diff --git a/arch/um/os-Linux/sys-i386/Makefile b/arch/um/os-Linux/sys-i386/Makefile deleted file mode 100644 index b4bc6ac4f30..00000000000 --- a/arch/um/os-Linux/sys-i386/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# -# Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) -# Licensed under the GPL -# - -obj-y = registers.o signal.o task_size.o tls.o - -USER_OBJS := $(obj-y) - -include arch/um/scripts/Makefile.rules diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c deleted file mode 100644 index 229f7a53d8d..00000000000 --- a/arch/um/os-Linux/sys-i386/registers.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2004 PathScale, Inc - * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#include <errno.h> -#include <sys/ptrace.h> -#include <sys/user.h> -#include "kern_constants.h" -#include "longjmp.h" -#include "user.h" -#include "sysdep/ptrace_user.h" - -int save_fp_registers(int pid, unsigned long *fp_regs) -{ -	if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0) -		return -errno; -	return 0; -} - -int restore_fp_registers(int pid, unsigned long *fp_regs) -{ -	if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0) -		return -errno; -	return 0; -} - -int save_fpx_registers(int pid, unsigned long *fp_regs) -{ -	if (ptrace(PTRACE_GETFPXREGS, pid, 0, fp_regs) < 0) -		return -errno; -	return 0; -} - -int restore_fpx_registers(int pid, unsigned long *fp_regs) -{ -	if (ptrace(PTRACE_SETFPXREGS, pid, 0, fp_regs) < 0) -		return -errno; -	return 0; -} - -unsigned long get_thread_reg(int reg, jmp_buf *buf) -{ -	switch (reg) { -	case EIP: -		return buf[0]->__eip; -	case UESP: -		return buf[0]->__esp; -	case EBP: -		return buf[0]->__ebp; -	default: -		printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n", -		       reg); -		return 0; -	} -} - -int have_fpx_regs = 1; - -int get_fp_registers(int pid, unsigned long *regs) -{ -	if (have_fpx_regs) -		return save_fpx_registers(pid, regs); -	else -		return save_fp_registers(pid, regs); -} - -int put_fp_registers(int pid, unsigned long *regs) -{ -	if (have_fpx_regs) -		return restore_fpx_registers(pid, regs); -	else -		return restore_fp_registers(pid, regs); -} - -void arch_init_registers(int pid) -{ -	struct user_fpxregs_struct fpx_regs; -	int err; - -	err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs); -	if (!err) -		return; - -	if (errno != EIO) -		panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d", -		      errno); - -	have_fpx_regs = 0; -} diff --git a/arch/um/os-Linux/sys-i386/signal.c b/arch/um/os-Linux/sys-i386/signal.c deleted file mode 100644 index f311609f93d..00000000000 --- a/arch/um/os-Linux/sys-i386/signal.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#include <signal.h> - -extern void handle_signal(int sig, struct sigcontext *sc); - -void hard_handler(int sig) -{ -	handle_signal(sig, (struct sigcontext *) (&sig + 1)); -} diff --git a/arch/um/os-Linux/sys-i386/task_size.c b/arch/um/os-Linux/sys-i386/task_size.c deleted file mode 100644 index be04c1e183b..00000000000 --- a/arch/um/os-Linux/sys-i386/task_size.c +++ /dev/null @@ -1,139 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <sys/mman.h> -#include "longjmp.h" -#include "kern_constants.h" - -static jmp_buf buf; - -static void segfault(int sig) -{ -	longjmp(buf, 1); -} - -static int page_ok(unsigned long page) -{ -	unsigned long *address = (unsigned long *) (page << UM_KERN_PAGE_SHIFT); -	unsigned long n = ~0UL; -	void *mapped = NULL; -	int ok = 0; - -	/* -	 * First see if the page is readable.  If it is, it may still -	 * be a VDSO, so we go on to see if it's writable.  If not -	 * then try mapping memory there.  If that fails, then we're -	 * still in the kernel area.  As a sanity check, we'll fail if -	 * the mmap succeeds, but gives us an address different from -	 * what we wanted. -	 */ -	if (setjmp(buf) == 0) -		n = *address; -	else { -		mapped = mmap(address, UM_KERN_PAGE_SIZE, -			      PROT_READ | PROT_WRITE, -			      MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); -		if (mapped == MAP_FAILED) -			return 0; -		if (mapped != address) -			goto out; -	} - -	/* -	 * Now, is it writeable?  If so, then we're in user address -	 * space.  If not, then try mprotecting it and try the write -	 * again. -	 */ -	if (setjmp(buf) == 0) { -		*address = n; -		ok = 1; -		goto out; -	} else if (mprotect(address, UM_KERN_PAGE_SIZE, -			    PROT_READ | PROT_WRITE) != 0) -		goto out; - -	if (setjmp(buf) == 0) { -		*address = n; -		ok = 1; -	} - - out: -	if (mapped != NULL) -		munmap(mapped, UM_KERN_PAGE_SIZE); -	return ok; -} - -unsigned long os_get_top_address(void) -{ -	struct sigaction sa, old; -	unsigned long bottom = 0; -	/* -	 * A 32-bit UML on a 64-bit host gets confused about the VDSO at -	 * 0xffffe000.  It is mapped, is readable, can be reprotected writeable -	 * and written.  However, exec discovers later that it can't be -	 * unmapped.  So, just set the highest address to be checked to just -	 * below it.  This might waste some address space on 4G/4G 32-bit -	 * hosts, but shouldn't hurt otherwise. -	 */ -	unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT; -	unsigned long test, original; - -	printf("Locating the bottom of the address space ... "); -	fflush(stdout); - -	/* -	 * We're going to be longjmping out of the signal handler, so -	 * SA_DEFER needs to be set. -	 */ -	sa.sa_handler = segfault; -	sigemptyset(&sa.sa_mask); -	sa.sa_flags = SA_NODEFER; -	if (sigaction(SIGSEGV, &sa, &old)) { -		perror("os_get_top_address"); -		exit(1); -	} - -	/* Manually scan the address space, bottom-up, until we find -	 * the first valid page (or run out of them). -	 */ -	for (bottom = 0; bottom < top; bottom++) { -		if (page_ok(bottom)) -			break; -	} - -	/* If we've got this far, we ran out of pages. */ -	if (bottom == top) { -		fprintf(stderr, "Unable to determine bottom of address " -			"space.\n"); -		exit(1); -	} - -	printf("0x%x\n", bottom << UM_KERN_PAGE_SHIFT); -	printf("Locating the top of the address space ... "); -	fflush(stdout); - -	original = bottom; - -	/* This could happen with a 4G/4G split */ -	if (page_ok(top)) -		goto out; - -	do { -		test = bottom + (top - bottom) / 2; -		if (page_ok(test)) -			bottom = test; -		else -			top = test; -	} while (top - bottom > 1); - -out: -	/* Restore the old SIGSEGV handling */ -	if (sigaction(SIGSEGV, &old, NULL)) { -		perror("os_get_top_address"); -		exit(1); -	} -	top <<= UM_KERN_PAGE_SHIFT; -	printf("0x%x\n", top); - -	return top; -} diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c deleted file mode 100644 index 32ed41ec1a3..00000000000 --- a/arch/um/os-Linux/sys-i386/tls.c +++ /dev/null @@ -1,36 +0,0 @@ -#include <errno.h> -#include <linux/unistd.h> - -#include <sys/syscall.h> -#include <unistd.h> - -#include "sysdep/tls.h" -#include "user.h" - -/* Checks whether host supports TLS, and sets *tls_min according to the value - * valid on the host. - * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */ -void check_host_supports_tls(int *supports_tls, int *tls_min) { -	/* Values for x86 and x86_64.*/ -	int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64}; -	int i; - -	for (i = 0; i < ARRAY_SIZE(val); i++) { -		user_desc_t info; -		info.entry_number = val[i]; - -		if (syscall(__NR_get_thread_area, &info) == 0) { -			*tls_min = val[i]; -			*supports_tls = 1; -			return; -		} else { -			if (errno == EINVAL) -				continue; -			else if (errno == ENOSYS) -				*supports_tls = 0; -				return; -		} -	} - -	*supports_tls = 0; -} diff --git a/arch/um/os-Linux/sys-x86_64/Makefile b/arch/um/os-Linux/sys-x86_64/Makefile deleted file mode 100644 index a44a47f8f57..00000000000 --- a/arch/um/os-Linux/sys-x86_64/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# -# Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) -# Licensed under the GPL -# - -obj-y = registers.o prctl.o signal.o task_size.o - -USER_OBJS := $(obj-y) - -include arch/um/scripts/Makefile.rules diff --git a/arch/um/os-Linux/sys-x86_64/prctl.c b/arch/um/os-Linux/sys-x86_64/prctl.c deleted file mode 100644 index 9d34eddb517..00000000000 --- a/arch/um/os-Linux/sys-x86_64/prctl.c +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2007 Jeff Dike (jdike@{addtoit.com,linux.intel.com}) - * Licensed under the GPL - */ - -#include <sys/ptrace.h> -#include <linux/ptrace.h> - -int os_arch_prctl(int pid, int code, unsigned long *addr) -{ -        return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, code); -} diff --git a/arch/um/os-Linux/sys-x86_64/registers.c b/arch/um/os-Linux/sys-x86_64/registers.c deleted file mode 100644 index 594d97ad02b..00000000000 --- a/arch/um/os-Linux/sys-x86_64/registers.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2006 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#include <errno.h> -#include <sys/ptrace.h> -#define __FRAME_OFFSETS -#include <asm/ptrace.h> -#include "kern_constants.h" -#include "longjmp.h" -#include "user.h" - -int save_fp_registers(int pid, unsigned long *fp_regs) -{ -	if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0) -		return -errno; -	return 0; -} - -int restore_fp_registers(int pid, unsigned long *fp_regs) -{ -	if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0) -		return -errno; -	return 0; -} - -unsigned long get_thread_reg(int reg, jmp_buf *buf) -{ -	switch (reg) { -	case RIP: -		return buf[0]->__rip; -	case RSP: -		return buf[0]->__rsp; -	case RBP: -		return buf[0]->__rbp; -	default: -		printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n", -		       reg); -		return 0; -	} -} - -int get_fp_registers(int pid, unsigned long *regs) -{ -	return save_fp_registers(pid, regs); -} - -int put_fp_registers(int pid, unsigned long *regs) -{ -	return restore_fp_registers(pid, regs); -} diff --git a/arch/um/os-Linux/sys-x86_64/signal.c b/arch/um/os-Linux/sys-x86_64/signal.c deleted file mode 100644 index 82a388822cd..00000000000 --- a/arch/um/os-Linux/sys-x86_64/signal.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#include <signal.h> - -extern void handle_signal(int sig, struct sigcontext *sc); - -void hard_handler(int sig) -{ -	struct ucontext *uc; -	asm("movq %%rdx, %0" : "=r" (uc)); - -	handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext); -} diff --git a/arch/um/os-Linux/sys-x86_64/task_size.c b/arch/um/os-Linux/sys-x86_64/task_size.c deleted file mode 100644 index 26a0dd1f349..00000000000 --- a/arch/um/os-Linux/sys-x86_64/task_size.c +++ /dev/null @@ -1,5 +0,0 @@ -unsigned long os_get_top_address(unsigned long shift) -{ -	/* The old value of CONFIG_TOP_ADDR */ -	return 0x7fc0000000; -} diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index 6e3359d6a83..910499d76a6 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c @@ -8,11 +8,9 @@  #include <signal.h>  #include <time.h>  #include <sys/time.h> -#include "kern_constants.h"  #include "kern_util.h"  #include "os.h" -#include "process.h" -#include "user.h" +#include "internal.h"  int set_interval(void)  { diff --git a/arch/um/os-Linux/tls.c b/arch/um/os-Linux/tls.c deleted file mode 100644 index 73277801ef1..00000000000 --- a/arch/um/os-Linux/tls.c +++ /dev/null @@ -1,35 +0,0 @@ -#include <errno.h> -#include <sys/ptrace.h> -#include "sysdep/tls.h" - -/* TLS support - we basically rely on the host's one.*/ - -#ifndef PTRACE_GET_THREAD_AREA -#define PTRACE_GET_THREAD_AREA 25 -#endif - -#ifndef PTRACE_SET_THREAD_AREA -#define PTRACE_SET_THREAD_AREA 26 -#endif - -int os_set_thread_area(user_desc_t *info, int pid) -{ -	int ret; - -	ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number, -		     (unsigned long) info); -	if (ret < 0) -		ret = -errno; -	return ret; -} - -int os_get_thread_area(user_desc_t *info, int pid) -{ -	int ret; - -	ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number, -		     (unsigned long) info); -	if (ret < 0) -		ret = -errno; -	return ret; -} diff --git a/arch/um/os-Linux/tty.c b/arch/um/os-Linux/tty.c index b09ff66a77e..dd12b99dcb5 100644 --- a/arch/um/os-Linux/tty.c +++ b/arch/um/os-Linux/tty.c @@ -7,10 +7,8 @@  #include <unistd.h>  #include <errno.h>  #include <fcntl.h> -#include "kern_constants.h"  #include "kern_util.h"  #include "os.h" -#include "user.h"  struct grantpt_info {  	int fd; diff --git a/arch/um/os-Linux/uaccess.c b/arch/um/os-Linux/uaccess.c deleted file mode 100644 index 087ed74ffca..00000000000 --- a/arch/um/os-Linux/uaccess.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) - * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#include <stddef.h> -#include "longjmp.h" - -unsigned long __do_user_copy(void *to, const void *from, int n, -			     void **fault_addr, jmp_buf **fault_catcher, -			     void (*op)(void *to, const void *from, -					int n), int *faulted_out) -{ -	unsigned long *faddrp = (unsigned long *) fault_addr, ret; - -	jmp_buf jbuf; -	*fault_catcher = &jbuf; -	if (UML_SETJMP(&jbuf) == 0) { -		(*op)(to, from, n); -		ret = 0; -		*faulted_out = 0; -	} -	else { -		ret = *faddrp; -		*faulted_out = 1; -	} -	*fault_addr = NULL; -	*fault_catcher = NULL; -	return ret; -} - diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c index a27defb8188..4832eb519f8 100644 --- a/arch/um/os-Linux/umid.c +++ b/arch/um/os-Linux/umid.c @@ -13,9 +13,7 @@  #include <unistd.h>  #include <sys/stat.h>  #include "init.h" -#include "kern_constants.h"  #include "os.h" -#include "user.h"  #define UML_DIR "~/.uml/" diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c index 5803b188767..9e3b43bb84c 100644 --- a/arch/um/os-Linux/util.c +++ b/arch/um/os-Linux/util.c @@ -13,9 +13,7 @@  #include <wait.h>  #include <sys/mman.h>  #include <sys/utsname.h> -#include "kern_constants.h"  #include "os.h" -#include "user.h"  void stack_protections(unsigned long address)  {  |