2005-11-07 00:58:50 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
|
2008-02-08 04:22:08 -08:00
|
|
|
* Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-11-07 00:58:50 -08:00
|
|
|
* Licensed under the GPL
|
|
|
|
|
*/
|
|
|
|
|
|
2006-09-25 23:32:59 -07:00
|
|
|
#include <stddef.h>
|
2006-01-18 17:42:49 -08:00
|
|
|
#include "longjmp.h"
|
2005-11-07 00:58:50 -08:00
|
|
|
|
|
|
|
|
unsigned long __do_user_copy(void *to, const void *from, int n,
|
2007-10-16 01:27:05 -07:00
|
|
|
void **fault_addr, jmp_buf **fault_catcher,
|
2005-11-07 00:58:50 -08:00
|
|
|
void (*op)(void *to, const void *from,
|
|
|
|
|
int n), int *faulted_out)
|
|
|
|
|
{
|
|
|
|
|
unsigned long *faddrp = (unsigned long *) fault_addr, ret;
|
|
|
|
|
|
2006-04-18 22:21:41 -07:00
|
|
|
jmp_buf jbuf;
|
2005-11-07 00:58:50 -08:00
|
|
|
*fault_catcher = &jbuf;
|
2008-02-08 04:22:08 -08:00
|
|
|
if (UML_SETJMP(&jbuf) == 0) {
|
2005-11-07 00:58:50 -08:00
|
|
|
(*op)(to, from, n);
|
|
|
|
|
ret = 0;
|
|
|
|
|
*faulted_out = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ret = *faddrp;
|
|
|
|
|
*faulted_out = 1;
|
|
|
|
|
}
|
|
|
|
|
*fault_addr = NULL;
|
|
|
|
|
*fault_catcher = NULL;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|