summaryrefslogtreecommitdiffstats
path: root/arch/um/include/sysdep-i386
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/include/sysdep-i386')
-rw-r--r--arch/um/include/sysdep-i386/checksum.h39
-rw-r--r--arch/um/include/sysdep-i386/faultinfo.h29
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h23
-rw-r--r--arch/um/include/sysdep-i386/sigcontext.h19
-rw-r--r--arch/um/include/sysdep-i386/signal.h2
-rw-r--r--arch/um/include/sysdep-i386/skas_ptrace.h22
-rw-r--r--arch/um/include/sysdep-i386/syscalls.h99
7 files changed, 87 insertions, 146 deletions
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h
index 3a2a458..764ba4d 100644
--- a/arch/um/include/sysdep-i386/checksum.h
+++ b/arch/um/include/sysdep-i386/checksum.h
@@ -24,19 +24,6 @@ unsigned int csum_partial(const unsigned char * buff, int len,
unsigned int sum);
/*
- * the same as csum_partial, but copies from src while it
- * checksums, and handles user-space pointer exceptions correctly, when needed.
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-
-unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst,
- int len, int sum, int *err_ptr);
-unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst,
- int len, int sum, int *err_ptr);
-
-/*
* Note: when you get a NULL pointer exception here this means someone
* passed in an incorrect kernel address to one of these functions.
*
@@ -52,11 +39,24 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
return(csum_partial(dst, len, sum));
}
+/*
+ * the same as csum_partial, but copies from src while it
+ * checksums, and handles user-space pointer exceptions correctly, when needed.
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
static __inline__
unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
int len, int sum, int *err_ptr)
{
- return csum_partial_copy_from(src, dst, len, sum, err_ptr);
+ if(copy_from_user(dst, src, len)){
+ *err_ptr = -EFAULT;
+ return(-1);
+ }
+
+ return csum_partial(dst, len, sum);
}
/*
@@ -67,7 +67,6 @@ unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char
*/
#define csum_partial_copy_fromuser csum_partial_copy_from_user
-unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum);
/*
* This is a version of ip_compute_csum() optimized for IP headers,
@@ -196,8 +195,14 @@ static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
unsigned char *dst,
int len, int sum, int *err_ptr)
{
- if (access_ok(VERIFY_WRITE, dst, len))
- return(csum_partial_copy_to(src, dst, len, sum, err_ptr));
+ if (access_ok(VERIFY_WRITE, dst, len)){
+ if(copy_to_user(dst, src, len)){
+ *err_ptr = -EFAULT;
+ return(-1);
+ }
+
+ return csum_partial(src, len, sum);
+ }
if (len)
*err_ptr = -EFAULT;
diff --git a/arch/um/include/sysdep-i386/faultinfo.h b/arch/um/include/sysdep-i386/faultinfo.h
new file mode 100644
index 0000000..db437cc
--- /dev/null
+++ b/arch/um/include/sysdep-i386/faultinfo.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
+ * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
+ * Licensed under the GPL
+ */
+
+#ifndef __FAULTINFO_I386_H
+#define __FAULTINFO_I386_H
+
+/* this structure contains the full arch-specific faultinfo
+ * from the traps.
+ * On i386, ptrace_faultinfo unfortunately doesn't provide
+ * all the info, since trap_no is missing.
+ * All common elements are defined at the same position in
+ * both structures, thus making it easy to copy the
+ * contents without knowledge about the structure elements.
+ */
+struct faultinfo {
+ int error_code; /* in ptrace_faultinfo misleadingly called is_write */
+ unsigned long cr2; /* in ptrace_faultinfo called addr */
+ int trap_no; /* missing in ptrace_faultinfo */
+};
+
+#define FAULT_WRITE(fi) ((fi).error_code & 2)
+#define FAULT_ADDRESS(fi) ((fi).cr2)
+
+#define PTRACE_FULL_FAULTINFO 0
+
+#endif
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
index 661d495..84ec7ff 100644
--- a/arch/um/include/sysdep-i386/ptrace.h
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -31,6 +31,7 @@ extern int sysemu_supported;
#ifdef UML_CONFIG_MODE_SKAS
#include "skas_ptregs.h"
+#include "sysdep/faultinfo.h"
#define REGS_IP(r) ((r)[HOST_IP])
#define REGS_SP(r) ((r)[HOST_SP])
@@ -53,12 +54,6 @@ extern int sysemu_supported;
#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
-#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
-
-#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
-
-#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
-
#endif
#ifndef PTRACE_SYSEMU_SINGLESTEP
#define PTRACE_SYSEMU_SINGLESTEP 32
@@ -71,6 +66,7 @@ union uml_pt_regs {
struct tt_regs {
long syscall;
void *sc;
+ struct faultinfo faultinfo;
} tt;
#endif
#ifdef UML_CONFIG_MODE_SKAS
@@ -78,9 +74,7 @@ union uml_pt_regs {
unsigned long regs[HOST_FRAME_SIZE];
unsigned long fp[HOST_FP_SIZE];
unsigned long xfp[HOST_XFP_SIZE];
- unsigned long fault_addr;
- unsigned long fault_type;
- unsigned long trap_type;
+ struct faultinfo faultinfo;
long syscall;
int is_user;
} skas;
@@ -217,15 +211,8 @@ struct syscall_args {
#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
#define UPT_SYSCALL_RET(r) UPT_EAX(r)
-#define UPT_SEGV_IS_FIXABLE(r) \
- CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
- REGS_SEGV_IS_FIXABLE(&r->skas))
-
-#define UPT_FAULT_ADDR(r) \
- __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas))
-
-#define UPT_FAULT_WRITE(r) \
- CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
+#define UPT_FAULTINFO(r) \
+ CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
#endif
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h
index dfee589..1fe7292 100644
--- a/arch/um/include/sysdep-i386/sigcontext.h
+++ b/arch/um/include/sysdep-i386/sigcontext.h
@@ -13,15 +13,12 @@
#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result)
-#define SC_FAULT_ADDR(sc) SC_CR2(sc)
-#define SC_FAULT_TYPE(sc) SC_ERR(sc)
-
-#define FAULT_WRITE(err) (err & 2)
-#define TO_SC_ERR(is_write) ((is_write) ? 2 : 0)
-
-#define SC_FAULT_WRITE(sc) (FAULT_WRITE(SC_ERR(sc)))
-
-#define SC_TRAP_TYPE(sc) SC_TRAPNO(sc)
+#define GET_FAULTINFO_FROM_SC(fi,sc) \
+ { \
+ (fi).cr2 = SC_CR2(sc); \
+ (fi).error_code = SC_ERR(sc); \
+ (fi).trap_no = SC_TRAPNO(sc); \
+ }
/* ptrace expects that, at the start of a system call, %eax contains
* -ENOSYS, so this makes it so.
@@ -29,9 +26,7 @@
#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
/* This is Page Fault */
-#define SEGV_IS_FIXABLE(trap) (trap == 14)
-
-#define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
+#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
extern unsigned long *sc_sigmask(void *sc_ptr);
extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
diff --git a/arch/um/include/sysdep-i386/signal.h b/arch/um/include/sysdep-i386/signal.h
index b1e1f7a..07518b1 100644
--- a/arch/um/include/sysdep-i386/signal.h
+++ b/arch/um/include/sysdep-i386/signal.h
@@ -8,6 +8,8 @@
#include <signal.h>
+#define ARCH_SIGHDLR_PARAM int sig
+
#define ARCH_GET_SIGCONTEXT(sc, sig) \
do sc = (struct sigcontext *) (&sig + 1); while(0)
diff --git a/arch/um/include/sysdep-i386/skas_ptrace.h b/arch/um/include/sysdep-i386/skas_ptrace.h
new file mode 100644
index 0000000..e27b8a7
--- /dev/null
+++ b/arch/um/include/sysdep-i386/skas_ptrace.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __SYSDEP_I386_SKAS_PTRACE_H
+#define __SYSDEP_I386_SKAS_PTRACE_H
+
+struct ptrace_faultinfo {
+ int is_write;
+ unsigned long addr;
+};
+
+struct ptrace_ldt {
+ int func;
+ void *ptr;
+ unsigned long bytecount;
+};
+
+#define PTRACE_LDT 54
+
+#endif
diff --git a/arch/um/include/sysdep-i386/syscalls.h b/arch/um/include/sysdep-i386/syscalls.h
index 5db81ec..be0a3e3 100644
--- a/arch/um/include/sysdep-i386/syscalls.h
+++ b/arch/um/include/sysdep-i386/syscalls.h
@@ -22,102 +22,3 @@ extern syscall_handler_t old_mmap_i386;
extern long sys_mmap2(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long pgoff);
-
-/* On i386 they choose a meaningless naming.*/
-#define __NR_kexec_load __NR_sys_kexec_load
-
-#define ARCH_SYSCALLS \
- [ __NR_waitpid ] = (syscall_handler_t *) sys_waitpid, \
- [ __NR_break ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_oldstat ] = (syscall_handler_t *) sys_stat, \
- [ __NR_umount ] = (syscall_handler_t *) sys_oldumount, \
- [ __NR_stime ] = um_stime, \
- [ __NR_oldfstat ] = (syscall_handler_t *) sys_fstat, \
- [ __NR_stty ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_gtty ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_nice ] = (syscall_handler_t *) sys_nice, \
- [ __NR_ftime ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_prof ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_signal ] = (syscall_handler_t *) sys_signal, \
- [ __NR_lock ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_mpx ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_ulimit ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_oldolduname ] = (syscall_handler_t *) sys_olduname, \
- [ __NR_sigaction ] = (syscall_handler_t *) sys_sigaction, \
- [ __NR_sgetmask ] = (syscall_handler_t *) sys_sgetmask, \
- [ __NR_ssetmask ] = (syscall_handler_t *) sys_ssetmask, \
- [ __NR_sigsuspend ] = (syscall_handler_t *) sys_sigsuspend, \
- [ __NR_sigpending ] = (syscall_handler_t *) sys_sigpending, \
- [ __NR_oldlstat ] = (syscall_handler_t *) sys_lstat, \
- [ __NR_readdir ] = old_readdir, \
- [ __NR_profil ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_socketcall ] = (syscall_handler_t *) sys_socketcall, \
- [ __NR_olduname ] = (syscall_handler_t *) sys_uname, \
- [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_idle ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_ipc ] = (syscall_handler_t *) sys_ipc, \
- [ __NR_sigreturn ] = (syscall_handler_t *) sys_sigreturn, \
- [ __NR_sigprocmask ] = (syscall_handler_t *) sys_sigprocmask, \
- [ __NR_bdflush ] = (syscall_handler_t *) sys_bdflush, \
- [ __NR__llseek ] = (syscall_handler_t *) sys_llseek, \
- [ __NR__newselect ] = (syscall_handler_t *) sys_select, \
- [ __NR_vm86 ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_mmap ] = (syscall_handler_t *) old_mmap_i386, \
- [ __NR_ugetrlimit ] = (syscall_handler_t *) sys_getrlimit, \
- [ __NR_mmap2 ] = (syscall_handler_t *) sys_mmap2, \
- [ __NR_truncate64 ] = (syscall_handler_t *) sys_truncate64, \
- [ __NR_ftruncate64 ] = (syscall_handler_t *) sys_ftruncate64, \
- [ __NR_stat64 ] = (syscall_handler_t *) sys_stat64, \
- [ __NR_lstat64 ] = (syscall_handler_t *) sys_lstat64, \
- [ __NR_fstat64 ] = (syscall_handler_t *) sys_fstat64, \
- [ __NR_fcntl64 ] = (syscall_handler_t *) sys_fcntl64, \
- [ __NR_sendfile64 ] = (syscall_handler_t *) sys_sendfile64, \
- [ __NR_statfs64 ] = (syscall_handler_t *) sys_statfs64, \
- [ __NR_fstatfs64 ] = (syscall_handler_t *) sys_fstatfs64, \
- [ __NR_fadvise64_64 ] = (syscall_handler_t *) sys_fadvise64_64, \
- [ __NR_select ] = (syscall_handler_t *) old_select, \
- [ __NR_vm86old ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \
- [ __NR_lchown32 ] = (syscall_handler_t *) sys_lchown, \
- [ __NR_getuid32 ] = (syscall_handler_t *) sys_getuid, \
- [ __NR_getgid32 ] = (syscall_handler_t *) sys_getgid, \
- [ __NR_geteuid32 ] = (syscall_handler_t *) sys_geteuid, \
- [ __NR_getegid32 ] = (syscall_handler_t *) sys_getegid, \
- [ __NR_setreuid32 ] = (syscall_handler_t *) sys_setreuid, \
- [ __NR_setregid32 ] = (syscall_handler_t *) sys_setregid, \
- [ __NR_getgroups32 ] = (syscall_handler_t *) sys_getgroups, \
- [ __NR_setgroups32 ] = (syscall_handler_t *) sys_setgroups, \
- [ __NR_fchown32 ] = (syscall_handler_t *) sys_fchown, \
- [ __NR_setresuid32 ] = (syscall_handler_t *) sys_setresuid, \
- [ __NR_getresuid32 ] = (syscall_handler_t *) sys_getresuid, \
- [ __NR_setresgid32 ] = (syscall_handler_t *) sys_setresgid, \
- [ __NR_getresgid32 ] = (syscall_handler_t *) sys_getresgid, \
- [ __NR_chown32 ] = (syscall_handler_t *) sys_chown, \
- [ __NR_setuid32 ] = (syscall_handler_t *) sys_setuid, \
- [ __NR_setgid32 ] = (syscall_handler_t *) sys_setgid, \
- [ __NR_setfsuid32 ] = (syscall_handler_t *) sys_setfsuid, \
- [ __NR_setfsgid32 ] = (syscall_handler_t *) sys_setfsgid, \
- [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \
- [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
- [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
- [ 222 ] = (syscall_handler_t *) sys_ni_syscall, \
- [ 223 ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
- [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
- [ 251 ] = (syscall_handler_t *) sys_ni_syscall, \
- [ 285 ] = (syscall_handler_t *) sys_ni_syscall,
-
-/* 222 doesn't yet have a name in include/asm-i386/unistd.h */
-
-#define LAST_ARCH_SYSCALL 285
-
-/*
- * 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:
- */
OpenPOWER on IntegriCloud