diff options
Diffstat (limited to 'arch/um/os-Linux')
| -rw-r--r-- | arch/um/os-Linux/sys-i386/Makefile | 10 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-i386/registers.c | 91 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-i386/signal.c | 13 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-i386/task_size.c | 139 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-i386/tls.c | 36 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-x86_64/Makefile | 10 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-x86_64/prctl.c | 12 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-x86_64/registers.c | 52 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-x86_64/signal.c | 16 | ||||
| -rw-r--r-- | arch/um/os-Linux/sys-x86_64/task_size.c | 5 | ||||
| -rw-r--r-- | arch/um/os-Linux/tls.c | 35 | ||||
| -rw-r--r-- | arch/um/os-Linux/uaccess.c | 32 |
12 files changed, 451 insertions, 0 deletions
diff --git a/arch/um/os-Linux/sys-i386/Makefile b/arch/um/os-Linux/sys-i386/Makefile new file mode 100644 index 00000000000..b4bc6ac4f30 --- /dev/null +++ b/arch/um/os-Linux/sys-i386/Makefile | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | # | ||
| 2 | # Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 3 | # Licensed under the GPL | ||
| 4 | # | ||
| 5 | |||
| 6 | obj-y = registers.o signal.o task_size.o tls.o | ||
| 7 | |||
| 8 | USER_OBJS := $(obj-y) | ||
| 9 | |||
| 10 | 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 new file mode 100644 index 00000000000..229f7a53d8d --- /dev/null +++ b/arch/um/os-Linux/sys-i386/registers.c | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004 PathScale, Inc | ||
| 3 | * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 4 | * Licensed under the GPL | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <errno.h> | ||
| 8 | #include <sys/ptrace.h> | ||
| 9 | #include <sys/user.h> | ||
| 10 | #include "kern_constants.h" | ||
| 11 | #include "longjmp.h" | ||
| 12 | #include "user.h" | ||
| 13 | #include "sysdep/ptrace_user.h" | ||
| 14 | |||
| 15 | int save_fp_registers(int pid, unsigned long *fp_regs) | ||
| 16 | { | ||
| 17 | if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0) | ||
| 18 | return -errno; | ||
| 19 | return 0; | ||
| 20 | } | ||
| 21 | |||
| 22 | int restore_fp_registers(int pid, unsigned long *fp_regs) | ||
| 23 | { | ||
| 24 | if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0) | ||
| 25 | return -errno; | ||
| 26 | return 0; | ||
| 27 | } | ||
| 28 | |||
| 29 | int save_fpx_registers(int pid, unsigned long *fp_regs) | ||
| 30 | { | ||
| 31 | if (ptrace(PTRACE_GETFPXREGS, pid, 0, fp_regs) < 0) | ||
| 32 | return -errno; | ||
| 33 | return 0; | ||
| 34 | } | ||
| 35 | |||
| 36 | int restore_fpx_registers(int pid, unsigned long *fp_regs) | ||
| 37 | { | ||
| 38 | if (ptrace(PTRACE_SETFPXREGS, pid, 0, fp_regs) < 0) | ||
| 39 | return -errno; | ||
| 40 | return 0; | ||
| 41 | } | ||
| 42 | |||
| 43 | unsigned long get_thread_reg(int reg, jmp_buf *buf) | ||
| 44 | { | ||
| 45 | switch (reg) { | ||
| 46 | case EIP: | ||
| 47 | return buf[0]->__eip; | ||
| 48 | case UESP: | ||
| 49 | return buf[0]->__esp; | ||
| 50 | case EBP: | ||
| 51 | return buf[0]->__ebp; | ||
| 52 | default: | ||
| 53 | printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n", | ||
| 54 | reg); | ||
| 55 | return 0; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | int have_fpx_regs = 1; | ||
| 60 | |||
| 61 | int get_fp_registers(int pid, unsigned long *regs) | ||
| 62 | { | ||
| 63 | if (have_fpx_regs) | ||
| 64 | return save_fpx_registers(pid, regs); | ||
| 65 | else | ||
| 66 | return save_fp_registers(pid, regs); | ||
| 67 | } | ||
| 68 | |||
| 69 | int put_fp_registers(int pid, unsigned long *regs) | ||
| 70 | { | ||
| 71 | if (have_fpx_regs) | ||
| 72 | return restore_fpx_registers(pid, regs); | ||
| 73 | else | ||
| 74 | return restore_fp_registers(pid, regs); | ||
| 75 | } | ||
| 76 | |||
| 77 | void arch_init_registers(int pid) | ||
| 78 | { | ||
| 79 | struct user_fpxregs_struct fpx_regs; | ||
| 80 | int err; | ||
| 81 | |||
| 82 | err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs); | ||
| 83 | if (!err) | ||
| 84 | return; | ||
| 85 | |||
| 86 | if (errno != EIO) | ||
| 87 | panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d", | ||
| 88 | errno); | ||
| 89 | |||
| 90 | have_fpx_regs = 0; | ||
| 91 | } | ||
diff --git a/arch/um/os-Linux/sys-i386/signal.c b/arch/um/os-Linux/sys-i386/signal.c new file mode 100644 index 00000000000..f311609f93d --- /dev/null +++ b/arch/um/os-Linux/sys-i386/signal.c | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <signal.h> | ||
| 7 | |||
| 8 | extern void handle_signal(int sig, struct sigcontext *sc); | ||
| 9 | |||
| 10 | void hard_handler(int sig) | ||
| 11 | { | ||
| 12 | handle_signal(sig, (struct sigcontext *) (&sig + 1)); | ||
| 13 | } | ||
diff --git a/arch/um/os-Linux/sys-i386/task_size.c b/arch/um/os-Linux/sys-i386/task_size.c new file mode 100644 index 00000000000..be04c1e183b --- /dev/null +++ b/arch/um/os-Linux/sys-i386/task_size.c | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <signal.h> | ||
| 4 | #include <sys/mman.h> | ||
| 5 | #include "longjmp.h" | ||
| 6 | #include "kern_constants.h" | ||
| 7 | |||
| 8 | static jmp_buf buf; | ||
| 9 | |||
| 10 | static void segfault(int sig) | ||
| 11 | { | ||
| 12 | longjmp(buf, 1); | ||
| 13 | } | ||
| 14 | |||
| 15 | static int page_ok(unsigned long page) | ||
| 16 | { | ||
| 17 | unsigned long *address = (unsigned long *) (page << UM_KERN_PAGE_SHIFT); | ||
| 18 | unsigned long n = ~0UL; | ||
| 19 | void *mapped = NULL; | ||
| 20 | int ok = 0; | ||
| 21 | |||
| 22 | /* | ||
| 23 | * First see if the page is readable. If it is, it may still | ||
| 24 | * be a VDSO, so we go on to see if it's writable. If not | ||
| 25 | * then try mapping memory there. If that fails, then we're | ||
| 26 | * still in the kernel area. As a sanity check, we'll fail if | ||
| 27 | * the mmap succeeds, but gives us an address different from | ||
| 28 | * what we wanted. | ||
| 29 | */ | ||
| 30 | if (setjmp(buf) == 0) | ||
| 31 | n = *address; | ||
| 32 | else { | ||
| 33 | mapped = mmap(address, UM_KERN_PAGE_SIZE, | ||
| 34 | PROT_READ | PROT_WRITE, | ||
| 35 | MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
| 36 | if (mapped == MAP_FAILED) | ||
| 37 | return 0; | ||
| 38 | if (mapped != address) | ||
| 39 | goto out; | ||
| 40 | } | ||
| 41 | |||
| 42 | /* | ||
| 43 | * Now, is it writeable? If so, then we're in user address | ||
| 44 | * space. If not, then try mprotecting it and try the write | ||
| 45 | * again. | ||
| 46 | */ | ||
| 47 | if (setjmp(buf) == 0) { | ||
| 48 | *address = n; | ||
| 49 | ok = 1; | ||
| 50 | goto out; | ||
| 51 | } else if (mprotect(address, UM_KERN_PAGE_SIZE, | ||
| 52 | PROT_READ | PROT_WRITE) != 0) | ||
| 53 | goto out; | ||
| 54 | |||
| 55 | if (setjmp(buf) == 0) { | ||
| 56 | *address = n; | ||
| 57 | ok = 1; | ||
| 58 | } | ||
| 59 | |||
| 60 | out: | ||
| 61 | if (mapped != NULL) | ||
| 62 | munmap(mapped, UM_KERN_PAGE_SIZE); | ||
| 63 | return ok; | ||
| 64 | } | ||
| 65 | |||
| 66 | unsigned long os_get_top_address(void) | ||
| 67 | { | ||
| 68 | struct sigaction sa, old; | ||
| 69 | unsigned long bottom = 0; | ||
| 70 | /* | ||
| 71 | * A 32-bit UML on a 64-bit host gets confused about the VDSO at | ||
| 72 | * 0xffffe000. It is mapped, is readable, can be reprotected writeable | ||
| 73 | * and written. However, exec discovers later that it can't be | ||
| 74 | * unmapped. So, just set the highest address to be checked to just | ||
| 75 | * below it. This might waste some address space on 4G/4G 32-bit | ||
| 76 | * hosts, but shouldn't hurt otherwise. | ||
| 77 | */ | ||
| 78 | unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT; | ||
| 79 | unsigned long test, original; | ||
| 80 | |||
| 81 | printf("Locating the bottom of the address space ... "); | ||
| 82 | fflush(stdout); | ||
| 83 | |||
| 84 | /* | ||
| 85 | * We're going to be longjmping out of the signal handler, so | ||
| 86 | * SA_DEFER needs to be set. | ||
| 87 | */ | ||
| 88 | sa.sa_handler = segfault; | ||
| 89 | sigemptyset(&sa.sa_mask); | ||
| 90 | sa.sa_flags = SA_NODEFER; | ||
| 91 | if (sigaction(SIGSEGV, &sa, &old)) { | ||
| 92 | perror("os_get_top_address"); | ||
| 93 | exit(1); | ||
| 94 | } | ||
| 95 | |||
| 96 | /* Manually scan the address space, bottom-up, until we find | ||
| 97 | * the first valid page (or run out of them). | ||
| 98 | */ | ||
| 99 | for (bottom = 0; bottom < top; bottom++) { | ||
| 100 | if (page_ok(bottom)) | ||
| 101 | break; | ||
| 102 | } | ||
| 103 | |||
| 104 | /* If we've got this far, we ran out of pages. */ | ||
| 105 | if (bottom == top) { | ||
| 106 | fprintf(stderr, "Unable to determine bottom of address " | ||
| 107 | "space.\n"); | ||
| 108 | exit(1); | ||
| 109 | } | ||
| 110 | |||
| 111 | printf("0x%x\n", bottom << UM_KERN_PAGE_SHIFT); | ||
| 112 | printf("Locating the top of the address space ... "); | ||
| 113 | fflush(stdout); | ||
| 114 | |||
| 115 | original = bottom; | ||
| 116 | |||
| 117 | /* This could happen with a 4G/4G split */ | ||
| 118 | if (page_ok(top)) | ||
| 119 | goto out; | ||
| 120 | |||
| 121 | do { | ||
| 122 | test = bottom + (top - bottom) / 2; | ||
| 123 | if (page_ok(test)) | ||
| 124 | bottom = test; | ||
| 125 | else | ||
| 126 | top = test; | ||
| 127 | } while (top - bottom > 1); | ||
| 128 | |||
| 129 | out: | ||
| 130 | /* Restore the old SIGSEGV handling */ | ||
| 131 | if (sigaction(SIGSEGV, &old, NULL)) { | ||
| 132 | perror("os_get_top_address"); | ||
| 133 | exit(1); | ||
| 134 | } | ||
| 135 | top <<= UM_KERN_PAGE_SHIFT; | ||
| 136 | printf("0x%x\n", top); | ||
| 137 | |||
| 138 | return top; | ||
| 139 | } | ||
diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c new file mode 100644 index 00000000000..32ed41ec1a3 --- /dev/null +++ b/arch/um/os-Linux/sys-i386/tls.c | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #include <errno.h> | ||
| 2 | #include <linux/unistd.h> | ||
| 3 | |||
| 4 | #include <sys/syscall.h> | ||
| 5 | #include <unistd.h> | ||
| 6 | |||
| 7 | #include "sysdep/tls.h" | ||
| 8 | #include "user.h" | ||
| 9 | |||
| 10 | /* Checks whether host supports TLS, and sets *tls_min according to the value | ||
| 11 | * valid on the host. | ||
| 12 | * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */ | ||
| 13 | void check_host_supports_tls(int *supports_tls, int *tls_min) { | ||
| 14 | /* Values for x86 and x86_64.*/ | ||
| 15 | int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64}; | ||
| 16 | int i; | ||
| 17 | |||
| 18 | for (i = 0; i < ARRAY_SIZE(val); i++) { | ||
| 19 | user_desc_t info; | ||
| 20 | info.entry_number = val[i]; | ||
| 21 | |||
| 22 | if (syscall(__NR_get_thread_area, &info) == 0) { | ||
| 23 | *tls_min = val[i]; | ||
| 24 | *supports_tls = 1; | ||
| 25 | return; | ||
| 26 | } else { | ||
| 27 | if (errno == EINVAL) | ||
| 28 | continue; | ||
| 29 | else if (errno == ENOSYS) | ||
| 30 | *supports_tls = 0; | ||
| 31 | return; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | *supports_tls = 0; | ||
| 36 | } | ||
diff --git a/arch/um/os-Linux/sys-x86_64/Makefile b/arch/um/os-Linux/sys-x86_64/Makefile new file mode 100644 index 00000000000..a44a47f8f57 --- /dev/null +++ b/arch/um/os-Linux/sys-x86_64/Makefile | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | # | ||
| 2 | # Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 3 | # Licensed under the GPL | ||
| 4 | # | ||
| 5 | |||
| 6 | obj-y = registers.o prctl.o signal.o task_size.o | ||
| 7 | |||
| 8 | USER_OBJS := $(obj-y) | ||
| 9 | |||
| 10 | 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 new file mode 100644 index 00000000000..9d34eddb517 --- /dev/null +++ b/arch/um/os-Linux/sys-x86_64/prctl.c | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007 Jeff Dike (jdike@{addtoit.com,linux.intel.com}) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <sys/ptrace.h> | ||
| 7 | #include <linux/ptrace.h> | ||
| 8 | |||
| 9 | int os_arch_prctl(int pid, int code, unsigned long *addr) | ||
| 10 | { | ||
| 11 | return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, code); | ||
| 12 | } | ||
diff --git a/arch/um/os-Linux/sys-x86_64/registers.c b/arch/um/os-Linux/sys-x86_64/registers.c new file mode 100644 index 00000000000..594d97ad02b --- /dev/null +++ b/arch/um/os-Linux/sys-x86_64/registers.c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2006 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <errno.h> | ||
| 7 | #include <sys/ptrace.h> | ||
| 8 | #define __FRAME_OFFSETS | ||
| 9 | #include <asm/ptrace.h> | ||
| 10 | #include "kern_constants.h" | ||
| 11 | #include "longjmp.h" | ||
| 12 | #include "user.h" | ||
| 13 | |||
| 14 | int save_fp_registers(int pid, unsigned long *fp_regs) | ||
| 15 | { | ||
| 16 | if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0) | ||
| 17 | return -errno; | ||
| 18 | return 0; | ||
| 19 | } | ||
| 20 | |||
| 21 | int restore_fp_registers(int pid, unsigned long *fp_regs) | ||
| 22 | { | ||
| 23 | if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0) | ||
| 24 | return -errno; | ||
| 25 | return 0; | ||
| 26 | } | ||
| 27 | |||
| 28 | unsigned long get_thread_reg(int reg, jmp_buf *buf) | ||
| 29 | { | ||
| 30 | switch (reg) { | ||
| 31 | case RIP: | ||
| 32 | return buf[0]->__rip; | ||
| 33 | case RSP: | ||
| 34 | return buf[0]->__rsp; | ||
| 35 | case RBP: | ||
| 36 | return buf[0]->__rbp; | ||
| 37 | default: | ||
| 38 | printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n", | ||
| 39 | reg); | ||
| 40 | return 0; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | int get_fp_registers(int pid, unsigned long *regs) | ||
| 45 | { | ||
| 46 | return save_fp_registers(pid, regs); | ||
| 47 | } | ||
| 48 | |||
| 49 | int put_fp_registers(int pid, unsigned long *regs) | ||
| 50 | { | ||
| 51 | return restore_fp_registers(pid, regs); | ||
| 52 | } | ||
diff --git a/arch/um/os-Linux/sys-x86_64/signal.c b/arch/um/os-Linux/sys-x86_64/signal.c new file mode 100644 index 00000000000..82a388822cd --- /dev/null +++ b/arch/um/os-Linux/sys-x86_64/signal.c | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <signal.h> | ||
| 7 | |||
| 8 | extern void handle_signal(int sig, struct sigcontext *sc); | ||
| 9 | |||
| 10 | void hard_handler(int sig) | ||
| 11 | { | ||
| 12 | struct ucontext *uc; | ||
| 13 | asm("movq %%rdx, %0" : "=r" (uc)); | ||
| 14 | |||
| 15 | handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext); | ||
| 16 | } | ||
diff --git a/arch/um/os-Linux/sys-x86_64/task_size.c b/arch/um/os-Linux/sys-x86_64/task_size.c new file mode 100644 index 00000000000..26a0dd1f349 --- /dev/null +++ b/arch/um/os-Linux/sys-x86_64/task_size.c | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | unsigned long os_get_top_address(unsigned long shift) | ||
| 2 | { | ||
| 3 | /* The old value of CONFIG_TOP_ADDR */ | ||
| 4 | return 0x7fc0000000; | ||
| 5 | } | ||
diff --git a/arch/um/os-Linux/tls.c b/arch/um/os-Linux/tls.c new file mode 100644 index 00000000000..73277801ef1 --- /dev/null +++ b/arch/um/os-Linux/tls.c | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #include <errno.h> | ||
| 2 | #include <sys/ptrace.h> | ||
| 3 | #include "sysdep/tls.h" | ||
| 4 | |||
| 5 | /* TLS support - we basically rely on the host's one.*/ | ||
| 6 | |||
| 7 | #ifndef PTRACE_GET_THREAD_AREA | ||
| 8 | #define PTRACE_GET_THREAD_AREA 25 | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #ifndef PTRACE_SET_THREAD_AREA | ||
| 12 | #define PTRACE_SET_THREAD_AREA 26 | ||
| 13 | #endif | ||
| 14 | |||
| 15 | int os_set_thread_area(user_desc_t *info, int pid) | ||
| 16 | { | ||
| 17 | int ret; | ||
| 18 | |||
| 19 | ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number, | ||
| 20 | (unsigned long) info); | ||
| 21 | if (ret < 0) | ||
| 22 | ret = -errno; | ||
| 23 | return ret; | ||
| 24 | } | ||
| 25 | |||
| 26 | int os_get_thread_area(user_desc_t *info, int pid) | ||
| 27 | { | ||
| 28 | int ret; | ||
| 29 | |||
| 30 | ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number, | ||
| 31 | (unsigned long) info); | ||
| 32 | if (ret < 0) | ||
| 33 | ret = -errno; | ||
| 34 | return ret; | ||
| 35 | } | ||
diff --git a/arch/um/os-Linux/uaccess.c b/arch/um/os-Linux/uaccess.c new file mode 100644 index 00000000000..087ed74ffca --- /dev/null +++ b/arch/um/os-Linux/uaccess.c | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) | ||
| 3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
| 4 | * Licensed under the GPL | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <stddef.h> | ||
| 8 | #include "longjmp.h" | ||
| 9 | |||
| 10 | unsigned long __do_user_copy(void *to, const void *from, int n, | ||
| 11 | void **fault_addr, jmp_buf **fault_catcher, | ||
| 12 | void (*op)(void *to, const void *from, | ||
| 13 | int n), int *faulted_out) | ||
| 14 | { | ||
| 15 | unsigned long *faddrp = (unsigned long *) fault_addr, ret; | ||
| 16 | |||
| 17 | jmp_buf jbuf; | ||
| 18 | *fault_catcher = &jbuf; | ||
| 19 | if (UML_SETJMP(&jbuf) == 0) { | ||
| 20 | (*op)(to, from, n); | ||
| 21 | ret = 0; | ||
| 22 | *faulted_out = 0; | ||
| 23 | } | ||
| 24 | else { | ||
| 25 | ret = *faddrp; | ||
| 26 | *faulted_out = 1; | ||
| 27 | } | ||
| 28 | *fault_addr = NULL; | ||
| 29 | *fault_catcher = NULL; | ||
| 30 | return ret; | ||
| 31 | } | ||
| 32 | |||
