Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) |
| 3 | * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) |
| 4 | * Licensed under the GPL |
| 5 | */ |
| 6 | |
| 7 | #include <setjmp.h> |
| 8 | #include <string.h> |
Jeff Dike | 1d7173b | 2006-01-18 17:42:49 -0800 | [diff] [blame] | 9 | #include "longjmp.h" |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 10 | |
| 11 | unsigned long __do_user_copy(void *to, const void *from, int n, |
| 12 | void **fault_addr, void **fault_catcher, |
| 13 | void (*op)(void *to, const void *from, |
| 14 | int n), int *faulted_out) |
| 15 | { |
| 16 | unsigned long *faddrp = (unsigned long *) fault_addr, ret; |
Jeff Dike | 1d7173b | 2006-01-18 17:42:49 -0800 | [diff] [blame] | 17 | int enable; |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 18 | |
Jeff Dike | ad28e029 | 2006-04-18 22:21:41 -0700 | [diff] [blame] | 19 | jmp_buf jbuf; |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 20 | *fault_catcher = &jbuf; |
Jeff Dike | ad28e029 | 2006-04-18 22:21:41 -0700 | [diff] [blame] | 21 | if(UML_SETJMP(&jbuf, enable) == 0){ |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 22 | (*op)(to, from, n); |
| 23 | ret = 0; |
| 24 | *faulted_out = 0; |
| 25 | } |
| 26 | else { |
| 27 | ret = *faddrp; |
| 28 | *faulted_out = 1; |
| 29 | } |
| 30 | *fault_addr = NULL; |
| 31 | *fault_catcher = NULL; |
| 32 | return ret; |
| 33 | } |
| 34 | |