diff options
Diffstat (limited to 'arch/um/sys-x86_64')
-rw-r--r-- | arch/um/sys-x86_64/Makefile | 11 | ||||
-rw-r--r-- | arch/um/sys-x86_64/bugs.c | 2 | ||||
-rw-r--r-- | arch/um/sys-x86_64/fault.c | 9 | ||||
-rw-r--r-- | arch/um/sys-x86_64/ptrace.c | 154 | ||||
-rw-r--r-- | arch/um/sys-x86_64/sigcontext.c | 39 | ||||
-rw-r--r-- | arch/um/sys-x86_64/signal.c | 297 | ||||
-rw-r--r-- | arch/um/sys-x86_64/stub.S | 9 | ||||
-rw-r--r-- | arch/um/sys-x86_64/stub_segv.c | 3 | ||||
-rw-r--r-- | arch/um/sys-x86_64/syscalls.c | 108 | ||||
-rw-r--r-- | arch/um/sys-x86_64/tls.c | 4 | ||||
-rw-r--r-- | arch/um/sys-x86_64/unmap.c | 25 | ||||
-rw-r--r-- | arch/um/sys-x86_64/user-offsets.c | 9 |
12 files changed, 254 insertions, 416 deletions
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index ea8185d8540..3c22de53208 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile @@ -5,10 +5,9 @@ # obj-y = bug.o bugs.o delay.o fault.o ldt.o mem.o ptrace.o ptrace_user.o \ - setjmp.o sigcontext.o signal.o syscalls.o syscall_table.o sysrq.o \ - ksyms.o tls.o + setjmp.o signal.o stub.o stub_segv.o syscalls.o syscall_table.o \ + sysrq.o ksyms.o tls.o -obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o obj-$(CONFIG_MODULES) += um_module.o subarch-obj-y = lib/bitops_64.o lib/csum-partial_64.o lib/memcpy_64.o lib/thunk_64.o @@ -16,16 +15,12 @@ subarch-obj-$(CONFIG_MODULES) += kernel/module_64.o ldt-y = ../sys-i386/ldt.o -USER_OBJS := ptrace_user.o sigcontext.o +USER_OBJS := ptrace_user.o USER_OBJS += user-offsets.s extra-y += user-offsets.s -extra-$(CONFIG_MODE_TT) += unmap.o - UNPROFILE_OBJS := stub_segv.o CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING) include arch/um/scripts/Makefile.rules - -$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS)) diff --git a/arch/um/sys-x86_64/bugs.c b/arch/um/sys-x86_64/bugs.c index 09547889037..506b6765bbc 100644 --- a/arch/um/sys-x86_64/bugs.c +++ b/arch/um/sys-x86_64/bugs.c @@ -14,7 +14,7 @@ void arch_check_bugs(void) { } -int arch_handle_signal(int sig, union uml_pt_regs *regs) +int arch_handle_signal(int sig, struct uml_pt_regs *regs) { return 0; } diff --git a/arch/um/sys-x86_64/fault.c b/arch/um/sys-x86_64/fault.c index 4636b1465b6..ce85117fc64 100644 --- a/arch/um/sys-x86_64/fault.c +++ b/arch/um/sys-x86_64/fault.c @@ -14,14 +14,15 @@ struct exception_table_entry }; const struct exception_table_entry *search_exception_tables(unsigned long add); -int arch_fixup(unsigned long address, union uml_pt_regs *regs) + +int arch_fixup(unsigned long address, struct uml_pt_regs *regs) { const struct exception_table_entry *fixup; fixup = search_exception_tables(address); - if(fixup != 0){ + if (fixup != 0) { UPT_IP(regs) = fixup->fixup; - return(1); + return 1; } - return(0); + return 0; } diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c index 1970d78aa52..a3cfeed17af 100644 --- a/arch/um/sys-x86_64/ptrace.c +++ b/arch/um/sys-x86_64/ptrace.c @@ -1,5 +1,6 @@ /* * Copyright 2003 PathScale, Inc. + * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * * Licensed under the GPL */ @@ -12,17 +13,10 @@ #include <asm/uaccess.h> #include <asm/elf.h> -/* XXX x86_64 */ -unsigned long not_ss; -unsigned long not_ds; -unsigned long not_es; - -#define SC_SS(r) (not_ss) -#define SC_DS(r) (not_ds) -#define SC_ES(r) (not_es) - -/* determines which flags the user has access to. */ -/* 1 = access 0 = no access */ +/* + * determines which flags the user has access to. + * 1 = access 0 = no access + */ #define FLAG_MASK 0x44dd5UL int putreg(struct task_struct *child, int regno, unsigned long value) @@ -66,20 +60,21 @@ int putreg(struct task_struct *child, int regno, unsigned long value) int poke_user(struct task_struct *child, long addr, long data) { - if ((addr & 3) || addr < 0) - return -EIO; - - if (addr < MAX_REG_OFFSET) - return putreg(child, addr, data); - else if((addr >= offsetof(struct user, u_debugreg[0])) && - (addr <= offsetof(struct user, u_debugreg[7]))){ - addr -= offsetof(struct user, u_debugreg[0]); - addr = addr >> 2; - if((addr == 4) || (addr == 5)) return -EIO; - child->thread.arch.debugregs[addr] = data; - return 0; - } - return -EIO; + if ((addr & 3) || addr < 0) + return -EIO; + + if (addr < MAX_REG_OFFSET) + return putreg(child, addr, data); + else if ((addr >= offsetof(struct user, u_debugreg[0])) && + (addr <= offsetof(struct user, u_debugreg[7]))){ + addr -= offsetof(struct user, u_debugreg[0]); + addr = addr >> 2; + if ((addr == 4) || (addr == 5)) + return -EIO; + child->thread.arch.debugregs[addr] = data; + return 0; + } + return -EIO; } unsigned long getreg(struct task_struct *child, int regno) @@ -107,29 +102,22 @@ unsigned long getreg(struct task_struct *child, int regno) int peek_user(struct task_struct *child, long addr, long data) { /* read the word at location addr in the USER area. */ - unsigned long tmp; - - if ((addr & 3) || addr < 0) - return -EIO; - - tmp = 0; /* Default return condition */ - if(addr < MAX_REG_OFFSET){ - tmp = getreg(child, addr); - } - else if((addr >= offsetof(struct user, u_debugreg[0])) && - (addr <= offsetof(struct user, u_debugreg[7]))){ - addr -= offsetof(struct user, u_debugreg[0]); - addr = addr >> 2; - tmp = child->thread.arch.debugregs[addr]; - } - return put_user(tmp, (unsigned long *) data); -} + unsigned long tmp; -void arch_switch(void) -{ -/* XXX - printk("arch_switch\n"); -*/ + if ((addr & 3) || addr < 0) + return -EIO; + + tmp = 0; /* Default return condition */ + if (addr < MAX_REG_OFFSET){ + tmp = getreg(child, addr); + } + else if ((addr >= offsetof(struct user, u_debugreg[0])) && + (addr <= offsetof(struct user, u_debugreg[7]))){ + addr -= offsetof(struct user, u_debugreg[0]); + addr = addr >> 2; + tmp = child->thread.arch.debugregs[addr]; + } + return put_user(tmp, (unsigned long *) data); } /* XXX Mostly copied from sys-i386 */ @@ -139,54 +127,68 @@ int is_syscall(unsigned long addr) int n; n = copy_from_user(&instr, (void __user *) addr, sizeof(instr)); - if(n){ + if (n){ /* access_process_vm() grants access to vsyscall and stub, * while copy_from_user doesn't. Maybe access_process_vm is * slow, but that doesn't matter, since it will be called only * in case of singlestepping, if copy_from_user failed. */ n = access_process_vm(current, addr, &instr, sizeof(instr), 0); - if(n != sizeof(instr)) { + if (n != sizeof(instr)) { printk("is_syscall : failed to read instruction from " "0x%lx\n", addr); - return(1); + return 1; } } /* sysenter */ - return(instr == 0x050f); + return instr == 0x050f; } -int get_fpregs(unsigned long buf, struct task_struct *child) +int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) { - panic("get_fpregs"); - return(0); -} + int err, n, cpu = ((struct thread_info *) child->stack)->cpu; + long fpregs[HOST_FP_SIZE]; -int set_fpregs(unsigned long buf, struct task_struct *child) -{ - panic("set_fpregs"); - return(0); + BUG_ON(sizeof(*buf) != sizeof(fpregs)); + err = save_fp_registers(userspace_pid[cpu], fpregs); + if (err) + return err; + + n = copy_to_user((void *) buf, fpregs, sizeof(fpregs)); + if(n > 0) + return -EFAULT; + + return n; } -int get_fpxregs(unsigned long buf, struct task_struct *tsk) +int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) { - panic("get_fpxregs"); - return(0); + int n, cpu = ((struct thread_info *) child->stack)->cpu; + long fpregs[HOST_FP_SIZE]; + + BUG_ON(sizeof(*buf) != sizeof(fpregs)); + n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs)); + if (n > 0) + return -EFAULT; + + return restore_fp_registers(userspace_pid[cpu], fpregs); } -int set_fpxregs(unsigned long buf, struct task_struct *tsk) +long subarch_ptrace(struct task_struct *child, long request, long addr, + long data) { - panic("set_fxpregs"); - return(0); -} + int ret = -EIO; -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ + switch (request) { + case PTRACE_GETFPXREGS: /* Get the child FPU state. */ + ret = get_fpregs((struct user_i387_struct __user *) data, + child); + break; + case PTRACE_SETFPXREGS: /* Set the child FPU state. */ + ret = set_fpregs((struct user_i387_struct __user *) data, + child); + break; + } + + return ret; +} diff --git a/arch/um/sys-x86_64/sigcontext.c b/arch/um/sys-x86_64/sigcontext.c deleted file mode 100644 index c88e64def6f..00000000000 --- a/arch/um/sys-x86_64/sigcontext.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2003 PathScale, Inc. - * - * Licensed under the GPL - */ - -#include <stdio.h> -#include <string.h> -#include <signal.h> -#include "user.h" - -void sc_to_sc(void *to_ptr, void *from_ptr) -{ - struct sigcontext *to = to_ptr, *from = from_ptr; - int size = sizeof(*to); /* + sizeof(struct _fpstate); */ - - memcpy(to, from, size); - if(from->fpstate != NULL) - to->fpstate = (struct _fpstate *) (to + 1); - - to->fpstate = NULL; -} - -unsigned long *sc_sigmask(void *sc_ptr) -{ - struct sigcontext *sc = sc_ptr; - - return(&sc->oldmask); -} - -/* Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c index fe8ec04d35b..1778d33808f 100644 --- a/arch/um/sys-x86_64/signal.c +++ b/arch/um/sys-x86_64/signal.c @@ -1,111 +1,121 @@ /* * Copyright (C) 2003 PathScale, Inc. + * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include "linux/stddef.h" -#include "linux/errno.h" #include "linux/personality.h" #include "linux/ptrace.h" -#include "asm/current.h" +#include "asm/unistd.h" #include "asm/uaccess.h" -#include "asm/sigcontext.h" -#include "asm/ptrace.h" -#include "asm/arch/ucontext.h" -#include "choose-mode.h" -#include "sysdep/ptrace.h" +#include "asm/ucontext.h" #include "frame_kern.h" - -#ifdef CONFIG_MODE_SKAS - #include "skas.h" -void copy_sc(union uml_pt_regs *regs, void *from) +void copy_sc(struct uml_pt_regs *regs, void *from) { struct sigcontext *sc = from; -#define GETREG(regs, regno, sc, regname) \ - (regs)->skas.regs[(regno) / sizeof(unsigned long)] = (sc)->regname - - GETREG(regs, R8, sc, r8); - GETREG(regs, R9, sc, r9); - GETREG(regs, R10, sc, r10); - GETREG(regs, R11, sc, r11); - GETREG(regs, R12, sc, r12); - GETREG(regs, R13, sc, r13); - GETREG(regs, R14, sc, r14); - GETREG(regs, R15, sc, r15); - GETREG(regs, RDI, sc, rdi); - GETREG(regs, RSI, sc, rsi); - GETREG(regs, RBP, sc, rbp); - GETREG(regs, RBX, sc, rbx); - GETREG(regs, RDX, sc, rdx); - GETREG(regs, RAX, sc, rax); - GETREG(regs, RCX, sc, rcx); - GETREG(regs, RSP, sc, rsp); - GETREG(regs, RIP, sc, rip); - GETREG(regs, EFLAGS, sc, eflags); - GETREG(regs, CS, sc, cs); +#define GETREG(regs, regno, sc, regname) \ + (regs)->gp[(regno) / sizeof(unsigned long)] = (sc)->regname + + GETREG(regs, R8, sc, r8); + GETREG(regs, R9, sc, r9); + GETREG(regs, R10, sc, r10); + GETREG(regs, R11, sc, r11); + GETREG(regs, R12, sc, r12); + GETREG(regs, R13, sc, r13); + GETREG(regs, R14, sc, r14); + GETREG(regs, R15, sc, r15); + GETREG(regs, RDI, sc, rdi); + GETREG(regs, RSI, sc, rsi); + GETREG(regs, RBP, sc, rbp); + GETREG(regs, RBX, sc, rbx); + GETREG(regs, RDX, sc, rdx); + GETREG(regs, RAX, sc, rax); + GETREG(regs, RCX, sc, rcx); + GETREG(regs, RSP, sc, rsp); + GETREG(regs, RIP, sc, rip); + GETREG(regs, EFLAGS, sc, eflags); + GETREG(regs, CS, sc, cs); #undef GETREG } -static int copy_sc_from_user_skas(struct pt_regs *regs, - struct sigcontext __user *from) +static int copy_sc_from_user(struct pt_regs *regs, + struct sigcontext __user *from, + struct _fpstate __user *fpp) { - int err = 0; - -#define GETREG(regs, regno, sc, regname) \ - __get_user((regs)->regs.skas.regs[(regno) / sizeof(unsigned long)], \ - &(sc)->regname) - - err |= GETREG(regs, R8, from, r8); - err |= GETREG(regs, R9, from, r9); - err |= GETREG(regs, R10, from, r10); - err |= GETREG(regs, R11, from, r11); - err |= GETREG(regs, R12, from, r12); - err |= GETREG(regs, R13, from, r13); - err |= GETREG(regs, R14, from, r14); - err |= GETREG(regs, R15, from, r15); - err |= GETREG(regs, RDI, from, rdi); - err |= GETREG(regs, RSI, from, rsi); - err |= GETREG(regs, RBP, from, rbp); - err |= GETREG(regs, RBX, from, rbx); - err |= GETREG(regs, RDX, from, rdx); - err |= GETREG(regs, RAX, from, rax); - err |= GETREG(regs, RCX, from, rcx); - err |= GETREG(regs, RSP, from, rsp); - err |= GETREG(regs, RIP, from, rip); - err |= GETREG(regs, EFLAGS, from, eflags); - err |= GETREG(regs, CS, from, cs); + struct user_i387_struct fp; + int err = 0; + +#define GETREG(regs, regno, sc, regname) \ + __get_user((regs)->regs.gp[(regno) / sizeof(unsigned long)], \ + &(sc)->regname) + + err |= GETREG(regs, R8, from, r8); + err |= GETREG(regs, R9, from, r9); + err |= GETREG(regs, R10, from, r10); + err |= GETREG(regs, R11, from, r11); + err |= GETREG(regs, R12, from, r12); + err |= GETREG(regs, R13, from, r13); + err |= GETREG(regs, R14, from, r14); + err |= GETREG(regs, R15, from, r15); + err |= GETREG(regs, RDI, from, rdi); + err |= GETREG(regs, RSI, from, rsi); + err |= GETREG(regs, RBP, from, rbp); + err |= GETREG(regs, RBX, from, rbx); + err |= GETREG(regs, RDX, from, rdx); + err |= GETREG(regs, RAX, from, rax); + err |= GETREG(regs, RCX, from, rcx); + err |= GETREG(regs, RSP, from, rsp); + err |= GETREG(regs, RIP, from, rip); + err |= GETREG(regs, EFLAGS, from, eflags); + err |= GETREG(regs, CS, from, cs); + if (err) + return 1; #undef GETREG - return err; + err = copy_from_user(&fp, fpp, sizeof(struct user_i387_struct)); + if (err) + return 1; + + err = restore_fp_registers(userspace_pid[current_thread->cpu], + (unsigned long *) &fp); + if (err < 0) { + printk(KERN_ERR "copy_sc_from_user - " + "restore_fp_registers failed, errno = %d\n", + -err); + return 1; + } + + return 0; } -int copy_sc_to_user_skas(struct sigcontext __user *to, - struct _fpstate __user *to_fp, - struct pt_regs *regs, unsigned long mask, - unsigned long sp) +static int copy_sc_to_user(struct sigcontext __user *to, + struct _fpstate __user *to_fp, struct pt_regs *regs, + unsigned long mask, unsigned long sp) { - struct faultinfo * fi = ¤t->thread.arch.faultinfo; + struct faultinfo * fi = ¤t->thread.arch.faultinfo; + struct user_i387_struct fp; int err = 0; err |= __put_user(0, &to->gs); err |= __put_user(0, &to->fs); -#define PUTREG(regs, regno, sc, regname) \ - __put_user((regs)->regs.skas.regs[(regno) / sizeof(unsigned long)], \ - &(sc)->regname) +#define PUTREG(regs, regno, sc, regname) \ + __put_user((regs)->regs.gp[(regno) / sizeof(unsigned long)], \ + &(sc)->regname) err |= PUTREG(regs, RDI, to, rdi); err |= PUTREG(regs, RSI, to, rsi); err |= PUTREG(regs, RBP, to, rbp); - /* Must use orignal RSP, which is passed in, rather than what's in - * the pt_regs, because that's already been updated to point at the - * signal frame. - */ + /* + * Must use orignal RSP, which is passed in, rather than what's in + * the pt_regs, because that's already been updated to point at the + * signal frame. + */ err |= __put_user(sp, &to->rsp); err |= PUTREG(regs, RBX, to, rbx); err |= PUTREG(regs, RDX, to, rdx); @@ -121,91 +131,38 @@ int copy_sc_to_user_skas(struct sigcontext __user *to, err |= PUTREG(regs, R15, to, r15); err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */ - err |= __put_user(fi->cr2, &to->cr2); - err |= __put_user(fi->error_code, &to->err); - err |= __put_user(fi->trap_no, &to->trapno); + err |= __put_user(fi->cr2, &to->cr2); + err |= __put_user(fi->error_code, &to->err); + err |= __put_user(fi->trap_no, &to->trapno); err |= PUTREG(regs, RIP, to, rip); err |= PUTREG(regs, EFLAGS, to, eflags); #undef PUTREG err |= __put_user(mask, &to->oldmask); - - return(err); -} - -#endif - -#ifdef CONFIG_MODE_TT -int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext __user *from, - int fpsize) -{ - struct _fpstate *to_fp; - struct _fpstate __user *from_fp; - unsigned long sigs; - int err; - - to_fp = to->fpstate; - sigs = to->oldmask; - err = copy_from_user(to, from, sizeof(*to)); - from_fp = to->fpstate; - to->fpstate = to_fp; - to->oldmask = sigs; - if(to_fp != NULL) - err |= copy_from_user(to_fp, from_fp, fpsize); - return(err); -} - -int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp, - struct sigcontext *from, int fpsize, unsigned long sp) -{ - struct _fpstate __user *to_fp; - struct _fpstate *from_fp; - int err; - - to_fp = (fp ? fp : (struct _fpstate __user *) (to + 1)); - from_fp = from->fpstate; - err = copy_to_user(to, from, sizeof(*to)); - /* The SP in the sigcontext is the updated one for the signal - * delivery. The sp passed in is the original, and this needs - * to be restored, so we stick it in separately. - */ - err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp)); - - if(from_fp != NULL){ - err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate)); - err |= copy_to_user(to_fp, from_fp, fpsize); + if (err) + return 1; + + err = save_fp_registers(userspace_pid[current_thread->cpu], + (unsigned long *) &fp); + if (err < 0) { + printk(KERN_ERR "copy_sc_from_user - restore_fp_registers " + "failed, errno = %d\n", -err); + return 1; } - return err; -} -#endif - -static int copy_sc_from_user(struct pt_regs *to, void __user *from) -{ - int ret; - - ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from, - sizeof(struct _fpstate)), - copy_sc_from_user_skas(to, from)); - return(ret); -} + if (copy_to_user(to_fp, &fp, sizeof(struct user_i387_struct))) + return 1; -static int copy_sc_to_user(struct sigcontext __user *to, - struct _fpstate __user *fp, - struct pt_regs *from, unsigned long mask, - unsigned long sp) -{ - return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), - sizeof(*fp), sp), - copy_sc_to_user_skas(to, fp, from, mask, sp))); + return err; } struct rt_sigframe { - char __user *pretcode; - struct ucontext uc; - struct siginfo info; + char __user *pretcode; + struct ucontext uc; + struct siginfo info; + struct _fpstate fpstate; }; #define round_down(m, n) (((m) / (n)) * (n)) @@ -215,7 +172,6 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, siginfo_t *info, sigset_t *set) { struct rt_sigframe __user *frame; - struct _fpstate __user *fp = NULL; unsigned long save_sp = PT_REGS_RSP(regs); int err = 0; struct task_struct *me = current; @@ -223,15 +179,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, frame = (struct rt_sigframe __user *) round_down(stack_top - sizeof(struct rt_sigframe), 16); /* Subtract 128 for a red zone and 8 for proper alignment */ - frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8); - - if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) - goto out; + frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8); -#if 0 /* XXX */ - if (save_i387(fp) < 0) - err |= -1; -#endif if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) goto out; @@ -241,7 +190,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, goto out; } - /* Update SP now because the page fault handler refuses to extend + /* + * Update SP now because the page fault handler refuses to extend * the stack if the faulting address is too far below the current * SP, which frame now certainly is. If there's an error, the original * value is restored on the way out. @@ -258,9 +208,9 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, err |= __put_user(sas_ss_flags(save_sp), &frame->uc.uc_stack.ss_flags); err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size); - err |= copy_sc_to_user(&frame->uc.uc_mcontext, fp, regs, set->sig[0], - save_sp); - err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate); + err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs, + set->sig[0], save_sp); + err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate); if (sizeof(*set) == 16) { __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]); __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]); @@ -269,8 +219,10 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); - /* Set up to return from userspace. If provided, use a stub - already in userspace. */ + /* + * Set up to return from userspace. If provided, use a stub + * already in userspace. + */ /* x86-64 should always use SA_RESTORER. */ if (ka->sa.sa_flags & SA_RESTORER) err |= __put_user(ka->sa.sa_restorer, &frame->pretcode); @@ -292,8 +244,10 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, /* In case the signal handler was declared without prototypes */ PT_REGS_RAX(regs) = 0; - /* This also works for non SA_SIGINFO handlers because they expect the - next argument after the signal number on the stack. */ + /* + * This also works for non SA_SIGINFO handlers because they expect the + * next argument after the signal number on the stack. + */ PT_REGS_RSI(regs) = (unsigned long) &frame->info; PT_REGS_RDX(regs) = (unsigned long) &frame->uc; PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler; @@ -313,7 +267,7 @@ long sys_rt_sigreturn(struct pt_regs *regs) struct ucontext __user *uc = &frame->uc; sigset_t set; - if(copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) + if (copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) goto segfault; sigdelsetmask(&set, ~_BLOCKABLE); @@ -323,24 +277,15 @@ long sys_rt_sigreturn(struct pt_regs *regs) recalc_sigpending(); spin_unlock_irq(¤t->sighand->siglock); - if(copy_sc_from_user(¤t->thread.regs, &uc->uc_mcontext)) + if (copy_sc_from_user(¤t->thread.regs, &uc->uc_mcontext, + &frame->fpstate)) goto segfault; /* Avoid ERESTART handling */ PT_REGS_SYSCALL_NR(¤t->thread.regs) = -1; - return(PT_REGS_SYSCALL_RET(¤t->thread.regs)); + return PT_REGS_SYSCALL_RET(¤t->thread.regs); segfault: force_sig(SIGSEGV, current); return 0; } -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ diff --git a/arch/um/sys-x86_64/stub.S b/arch/um/sys-x86_64/stub.S index 03c27973578..4afe204a6af 100644 --- a/arch/um/sys-x86_64/stub.S +++ b/arch/um/sys-x86_64/stub.S @@ -1,4 +1,5 @@ #include "uml-config.h" +#include "as-layout.h" .globl syscall_stub .section .__syscall_stub, "x" @@ -7,18 +8,18 @@ syscall_stub: /* We don't have 64-bit constants, so this constructs the address * we need. */ - movq $(UML_CONFIG_STUB_DATA >> 32), %rbx + movq $(ASM_STUB_DATA >> 32), %rbx salq $32, %rbx - movq $(UML_CONFIG_STUB_DATA & 0xffffffff), %rcx + movq $(ASM_STUB_DATA & 0xffffffff), %rcx or %rcx, %rbx movq %rax, (%rbx) int3 .globl batch_syscall_stub batch_syscall_stub: - mov $(UML_CONFIG_STUB_DATA >> 32), %rbx + mov $(ASM_STUB_DATA >> 32), %rbx sal $32, %rbx - mov $(UML_CONFIG_STUB_DATA & 0xffffffff), %rax + mov $(ASM_STUB_DATA & 0xffffffff), %rax or %rax, %rbx /* load pointer to first operation */ mov %rbx, %rsp diff --git a/arch/um/sys-x86_64/stub_segv.c b/arch/um/sys-x86_64/stub_segv.c index 652fa34c2cd..3afb590f007 100644 --- a/arch/um/sys-x86_64/stub_segv.c +++ b/arch/um/sys-x86_64/stub_segv.c @@ -6,6 +6,7 @@ #include <stddef.h> #include <signal.h> #include <asm/unistd.h> +#include "as-layout.h" #include "uml-config.h" #include "sysdep/sigcontext.h" #include "sysdep/faultinfo.h" @@ -33,7 +34,7 @@ stub_segv_handler(int sig) int pid; __asm__ __volatile__("movq %%rdx, %0" : "=g" (uc) :); - GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), + GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), &uc->uc_mcontext); pid = stub_syscall0(__NR_getpid); diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c index b3f6350cac4..86f6b18410e 100644 --- a/arch/um/sys-x86_64/syscalls.c +++ b/arch/um/sys-x86_64/syscalls.c @@ -1,70 +1,36 @@ /* + * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Copyright 2003 PathScale, Inc. * * Licensed under the GPL */ #include "linux/linkage.h" -#include "linux/slab.h" -#include "linux/shm.h" -#include "linux/utsname.h" #include "linux/personality.h" -#include "asm/uaccess.h" -#define __FRAME_OFFSETS -#include "asm/ptrace.h" -#include "asm/unistd.h" +#include "linux/utsname.h" #include "asm/prctl.h" /* XXX This should get the constants from libc */ -#include "choose-mode.h" -#include "kern.h" +#include "asm/uaccess.h" #include "os.h" asmlinkage long sys_uname64(struct new_utsname __user * name) { int err; + down_read(&uts_sem); err = copy_to_user(name, utsname(), sizeof (*name)); up_read(&uts_sem); + if (personality(current->personality) == PER_LINUX32) err |= copy_to_user(&name->machine, "i686", 5); - return err ? -EFAULT : 0; -} - -#ifdef CONFIG_MODE_TT -extern long arch_prctl(int code, unsigned long addr); - -static long arch_prctl_tt(int code, unsigned long addr) -{ - unsigned long tmp; - long ret; - - switch(code){ - case ARCH_SET_GS: - case ARCH_SET_FS: - ret = arch_prctl(code, addr); - break; - case ARCH_GET_FS: - case ARCH_GET_GS: - ret = arch_prctl(code, (unsigned long) &tmp); - if(!ret) - ret = put_user(tmp, (long __user *)addr); - break; - default: - ret = -EINVAL; - break; - } - return(ret); + return err ? -EFAULT : 0; } -#endif - -#ifdef CONFIG_MODE_SKAS -long arch_prctl_skas(struct task_struct *task, int code, - unsigned long __user *addr) +long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) { - unsigned long *ptr = addr, tmp; + unsigned long *ptr = addr, tmp; long ret; - int pid = task->mm->context.skas.id.u.pid; + int pid = task->mm->context.id.u.pid; /* * With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to @@ -79,52 +45,50 @@ long arch_prctl_skas(struct task_struct *task, int code, * arch_prctl is run on the host, then the registers are read * back. */ - switch(code){ + switch (code) { case ARCH_SET_FS: case ARCH_SET_GS: - restore_registers(pid, ¤t->thread.regs.regs); - break; - case ARCH_GET_FS: - case ARCH_GET_GS: - /* - * With these two, we read to a local pointer and - * put_user it to the userspace pointer that we were - * given. If addr isn't valid (because it hasn't been - * faulted in or is just bogus), we want put_user to - * fault it in (or return -EFAULT) instead of having - * the host return -EFAULT. - */ - ptr = &tmp; - } + restore_registers(pid, ¤t->thread.regs.regs); + break; + case ARCH_GET_FS: + case ARCH_GET_GS: + /* + * With these two, we read to a local pointer and + * put_user it to the userspace pointer that we were + * given. If addr isn't valid (because it hasn't been + * faulted in or is just bogus), we want put_user to + * fault it in (or return -EFAULT) instead of having + * the host return -EFAULT. + */ + ptr = &tmp; + } - ret = os_arch_prctl(pid, code, ptr); - if(ret) - return ret; + ret = os_arch_prctl(pid, code, ptr); + if (ret) + return ret; - switch(code){ + switch (code) { case ARCH_SET_FS: current->thread.arch.fs = (unsigned long) ptr; save_registers(pid, ¤t->thread.regs.regs); break; case ARCH_SET_GS: - save_registers(pid, ¤t->thread.regs.regs); + save_registers(pid, ¤t->thread.regs.regs); break; case ARCH_GET_FS: ret = put_user(tmp, addr); - break; + break; case ARCH_GET_GS: ret = put_user(tmp, addr); - break; + break; } return ret; } -#endif long sys_arch_prctl(int code, unsigned long addr) { - return CHOOSE_MODE_PROC(arch_prctl_tt, arch_prctl_skas, current, code, - (unsigned long __user *) addr); + return arch_prctl(current, code, (unsigned long __user *) addr); } long sys_clone(unsigned long clone_flags, unsigned long newsp, @@ -141,10 +105,10 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp, return ret; } -void arch_switch_to_skas(struct task_struct *from, struct task_struct *to) +void arch_switch_to(struct task_struct *from, struct task_struct *to) { - if((to->thread.arch.fs == 0) || (to->mm == NULL)) - return; + if ((to->thread.arch.fs == 0) || (to->mm == NULL)) + return; - arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs); + arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs); } diff --git a/arch/um/sys-x86_64/tls.c b/arch/um/sys-x86_64/tls.c index febbc94be25..f7ba46200ec 100644 --- a/arch/um/sys-x86_64/tls.c +++ b/arch/um/sys-x86_64/tls.c @@ -11,7 +11,7 @@ int arch_copy_tls(struct task_struct *t) * (which is argument 5, child_tid, of clone) so it can be set * during context switches. */ - t->thread.arch.fs = t->thread.regs.regs.skas.regs[R8 / sizeof(long)]; + t->thread.arch.fs = t->thread.regs.regs.gp[R8 / sizeof(long)]; - return 0; + return 0; } diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c deleted file mode 100644 index f4a4bffd8a1..00000000000 --- a/arch/um/sys-x86_64/unmap.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#include <linux/mman.h> -#include <asm/unistd.h> - -static int errno; - -static inline _syscall2(int,munmap,void *,start,size_t,len) -static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset) -int switcheroo(int fd, int prot, void *from, void *to, int size) -{ - if(munmap(to, size) < 0){ - return(-1); - } - if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){ - return(-1); - } - if(munmap(from, size) < 0){ - return(-1); - } - return(0); -} diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c index 0d5fd764c21..f1ef2a8dfbc 100644 --- a/arch/um/sys-x86_64/user-offsets.c +++ b/arch/um/sys-x86_64/user-offsets.c @@ -3,17 +3,10 @@ #include <signal.h> #include <sys/poll.h> #include <sys/mman.h> +#include <sys/user.h> #define __FRAME_OFFSETS #include <asm/ptrace.h> #include <asm/types.h> -/* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I - * refuse to include here, even though they're used throughout the headers. - * These are used in asm/user.h, and that include can't be avoided because of - * the sizeof(struct user_regs_struct) below. - */ -typedef __u64 u64; -typedef __u32 u32; -#include <asm/user.h> #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |