aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-x86/shared
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2011-08-18 15:06:39 -0400
committerRichard Weinberger <richard@nod.at>2011-11-02 09:15:05 -0400
commit5c48b108ecbf6505d929e64d50dace13ac2bdf34 (patch)
tree016904f84fbe05aa301c5cdfe712d90f6bb828fe /arch/um/sys-x86/shared
parent7bbe7204e93734fe79d8aac3e08a7cb4624b5004 (diff)
um: take arch/um/sys-x86 to arch/x86/um
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/sys-x86/shared')
-rw-r--r--arch/um/sys-x86/shared/sysdep/archsetjmp.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/archsetjmp_32.h22
-rw-r--r--arch/um/sys-x86/shared/sysdep/archsetjmp_64.h24
-rw-r--r--arch/um/sys-x86/shared/sysdep/faultinfo.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/faultinfo_32.h35
-rw-r--r--arch/um/sys-x86/shared/sysdep/faultinfo_64.h35
-rw-r--r--arch/um/sys-x86/shared/sysdep/host_ldt.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/host_ldt_32.h34
-rw-r--r--arch/um/sys-x86/shared/sysdep/host_ldt_64.h38
-rw-r--r--arch/um/sys-x86/shared/sysdep/kernel-offsets.h21
-rw-r--r--arch/um/sys-x86/shared/sysdep/mcontext.h31
-rw-r--r--arch/um/sys-x86/shared/sysdep/ptrace.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/ptrace_32.h117
-rw-r--r--arch/um/sys-x86/shared/sysdep/ptrace_64.h160
-rw-r--r--arch/um/sys-x86/shared/sysdep/ptrace_user.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/ptrace_user_32.h26
-rw-r--r--arch/um/sys-x86/shared/sysdep/ptrace_user_64.h38
-rw-r--r--arch/um/sys-x86/shared/sysdep/skas_ptrace.h22
-rw-r--r--arch/um/sys-x86/shared/sysdep/stub.h14
-rw-r--r--arch/um/sys-x86/shared/sysdep/stub_32.h93
-rw-r--r--arch/um/sys-x86/shared/sysdep/stub_64.h99
-rw-r--r--arch/um/sys-x86/shared/sysdep/syscalls.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/syscalls_32.h20
-rw-r--r--arch/um/sys-x86/shared/sysdep/syscalls_64.h32
-rw-r--r--arch/um/sys-x86/shared/sysdep/tls.h5
-rw-r--r--arch/um/sys-x86/shared/sysdep/tls_32.h32
-rw-r--r--arch/um/sys-x86/shared/sysdep/tls_64.h29
27 files changed, 0 insertions, 957 deletions
diff --git a/arch/um/sys-x86/shared/sysdep/archsetjmp.h b/arch/um/sys-x86/shared/sysdep/archsetjmp.h
deleted file mode 100644
index ff7766d28226..000000000000
--- a/arch/um/sys-x86/shared/sysdep/archsetjmp.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "archsetjmp_32.h"
3#else
4#include "archsetjmp_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/archsetjmp_32.h b/arch/um/sys-x86/shared/sysdep/archsetjmp_32.h
deleted file mode 100644
index 0f312085ce1d..000000000000
--- a/arch/um/sys-x86/shared/sysdep/archsetjmp_32.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * arch/um/include/sysdep-i386/archsetjmp.h
3 */
4
5#ifndef _KLIBC_ARCHSETJMP_H
6#define _KLIBC_ARCHSETJMP_H
7
8struct __jmp_buf {
9 unsigned int __ebx;
10 unsigned int __esp;
11 unsigned int __ebp;
12 unsigned int __esi;
13 unsigned int __edi;
14 unsigned int __eip;
15};
16
17typedef struct __jmp_buf jmp_buf[1];
18
19#define JB_IP __eip
20#define JB_SP __esp
21
22#endif /* _SETJMP_H */
diff --git a/arch/um/sys-x86/shared/sysdep/archsetjmp_64.h b/arch/um/sys-x86/shared/sysdep/archsetjmp_64.h
deleted file mode 100644
index 2af8f12ca161..000000000000
--- a/arch/um/sys-x86/shared/sysdep/archsetjmp_64.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * arch/um/include/sysdep-x86_64/archsetjmp.h
3 */
4
5#ifndef _KLIBC_ARCHSETJMP_H
6#define _KLIBC_ARCHSETJMP_H
7
8struct __jmp_buf {
9 unsigned long __rbx;
10 unsigned long __rsp;
11 unsigned long __rbp;
12 unsigned long __r12;
13 unsigned long __r13;
14 unsigned long __r14;
15 unsigned long __r15;
16 unsigned long __rip;
17};
18
19typedef struct __jmp_buf jmp_buf[1];
20
21#define JB_IP __rip
22#define JB_SP __rsp
23
24#endif /* _SETJMP_H */
diff --git a/arch/um/sys-x86/shared/sysdep/faultinfo.h b/arch/um/sys-x86/shared/sysdep/faultinfo.h
deleted file mode 100644
index 862ecb1c7781..000000000000
--- a/arch/um/sys-x86/shared/sysdep/faultinfo.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "faultinfo_32.h"
3#else
4#include "faultinfo_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/faultinfo_32.h b/arch/um/sys-x86/shared/sysdep/faultinfo_32.h
deleted file mode 100644
index a26086b8a800..000000000000
--- a/arch/um/sys-x86/shared/sysdep/faultinfo_32.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
4 * Licensed under the GPL
5 */
6
7#ifndef __FAULTINFO_I386_H
8#define __FAULTINFO_I386_H
9
10/* this structure contains the full arch-specific faultinfo
11 * from the traps.
12 * On i386, ptrace_faultinfo unfortunately doesn't provide
13 * all the info, since trap_no is missing.
14 * All common elements are defined at the same position in
15 * both structures, thus making it easy to copy the
16 * contents without knowledge about the structure elements.
17 */
18struct faultinfo {
19 int error_code; /* in ptrace_faultinfo misleadingly called is_write */
20 unsigned long cr2; /* in ptrace_faultinfo called addr */
21 int trap_no; /* missing in ptrace_faultinfo */
22};
23
24#define FAULT_WRITE(fi) ((fi).error_code & 2)
25#define FAULT_ADDRESS(fi) ((fi).cr2)
26
27/* This is Page Fault */
28#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
29
30/* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */
31#define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo)
32
33#define PTRACE_FULL_FAULTINFO 0
34
35#endif
diff --git a/arch/um/sys-x86/shared/sysdep/faultinfo_64.h b/arch/um/sys-x86/shared/sysdep/faultinfo_64.h
deleted file mode 100644
index f811cbe15d62..000000000000
--- a/arch/um/sys-x86/shared/sysdep/faultinfo_64.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
4 * Licensed under the GPL
5 */
6
7#ifndef __FAULTINFO_X86_64_H
8#define __FAULTINFO_X86_64_H
9
10/* this structure contains the full arch-specific faultinfo
11 * from the traps.
12 * On i386, ptrace_faultinfo unfortunately doesn't provide
13 * all the info, since trap_no is missing.
14 * All common elements are defined at the same position in
15 * both structures, thus making it easy to copy the
16 * contents without knowledge about the structure elements.
17 */
18struct faultinfo {
19 int error_code; /* in ptrace_faultinfo misleadingly called is_write */
20 unsigned long cr2; /* in ptrace_faultinfo called addr */
21 int trap_no; /* missing in ptrace_faultinfo */
22};
23
24#define FAULT_WRITE(fi) ((fi).error_code & 2)
25#define FAULT_ADDRESS(fi) ((fi).cr2)
26
27/* This is Page Fault */
28#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
29
30/* No broken SKAS API, which doesn't pass trap_no, here. */
31#define SEGV_MAYBE_FIXABLE(fi) 0
32
33#define PTRACE_FULL_FAULTINFO 1
34
35#endif
diff --git a/arch/um/sys-x86/shared/sysdep/host_ldt.h b/arch/um/sys-x86/shared/sysdep/host_ldt.h
deleted file mode 100644
index 94518b3e0da5..000000000000
--- a/arch/um/sys-x86/shared/sysdep/host_ldt.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "host_ldt_32.h"
3#else
4#include "host_ldt_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/host_ldt_32.h b/arch/um/sys-x86/shared/sysdep/host_ldt_32.h
deleted file mode 100644
index 0953cc4df652..000000000000
--- a/arch/um/sys-x86/shared/sysdep/host_ldt_32.h
+++ /dev/null
@@ -1,34 +0,0 @@
1#ifndef __ASM_HOST_LDT_I386_H
2#define __ASM_HOST_LDT_I386_H
3
4#include <asm/ldt.h>
5
6/*
7 * macros stolen from include/asm-i386/desc.h
8 */
9#define LDT_entry_a(info) \
10 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
11
12#define LDT_entry_b(info) \
13 (((info)->base_addr & 0xff000000) | \
14 (((info)->base_addr & 0x00ff0000) >> 16) | \
15 ((info)->limit & 0xf0000) | \
16 (((info)->read_exec_only ^ 1) << 9) | \
17 ((info)->contents << 10) | \
18 (((info)->seg_not_present ^ 1) << 15) | \
19 ((info)->seg_32bit << 22) | \
20 ((info)->limit_in_pages << 23) | \
21 ((info)->useable << 20) | \
22 0x7000)
23
24#define LDT_empty(info) (\
25 (info)->base_addr == 0 && \
26 (info)->limit == 0 && \
27 (info)->contents == 0 && \
28 (info)->read_exec_only == 1 && \
29 (info)->seg_32bit == 0 && \
30 (info)->limit_in_pages == 0 && \
31 (info)->seg_not_present == 1 && \
32 (info)->useable == 0 )
33
34#endif
diff --git a/arch/um/sys-x86/shared/sysdep/host_ldt_64.h b/arch/um/sys-x86/shared/sysdep/host_ldt_64.h
deleted file mode 100644
index e8b1be1e154f..000000000000
--- a/arch/um/sys-x86/shared/sysdep/host_ldt_64.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef __ASM_HOST_LDT_X86_64_H
2#define __ASM_HOST_LDT_X86_64_H
3
4#include <asm/ldt.h>
5
6/*
7 * macros stolen from include/asm-x86_64/desc.h
8 */
9#define LDT_entry_a(info) \
10 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
11
12/* Don't allow setting of the lm bit. It is useless anyways because
13 * 64bit system calls require __USER_CS. */
14#define LDT_entry_b(info) \
15 (((info)->base_addr & 0xff000000) | \
16 (((info)->base_addr & 0x00ff0000) >> 16) | \
17 ((info)->limit & 0xf0000) | \
18 (((info)->read_exec_only ^ 1) << 9) | \
19 ((info)->contents << 10) | \
20 (((info)->seg_not_present ^ 1) << 15) | \
21 ((info)->seg_32bit << 22) | \
22 ((info)->limit_in_pages << 23) | \
23 ((info)->useable << 20) | \
24 /* ((info)->lm << 21) | */ \
25 0x7000)
26
27#define LDT_empty(info) (\
28 (info)->base_addr == 0 && \
29 (info)->limit == 0 && \
30 (info)->contents == 0 && \
31 (info)->read_exec_only == 1 && \
32 (info)->seg_32bit == 0 && \
33 (info)->limit_in_pages == 0 && \
34 (info)->seg_not_present == 1 && \
35 (info)->useable == 0 && \
36 (info)->lm == 0)
37
38#endif
diff --git a/arch/um/sys-x86/shared/sysdep/kernel-offsets.h b/arch/um/sys-x86/shared/sysdep/kernel-offsets.h
deleted file mode 100644
index 5868526b5eef..000000000000
--- a/arch/um/sys-x86/shared/sysdep/kernel-offsets.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#include <linux/stddef.h>
2#include <linux/sched.h>
3#include <linux/elf.h>
4#include <linux/crypto.h>
5#include <asm/mman.h>
6
7#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9
10#define STR(x) #x
11#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : )
12
13#define BLANK() asm volatile("\n->" : : )
14
15#define OFFSET(sym, str, mem) \
16 DEFINE(sym, offsetof(struct str, mem));
17
18void foo(void)
19{
20#include <common-offsets.h>
21}
diff --git a/arch/um/sys-x86/shared/sysdep/mcontext.h b/arch/um/sys-x86/shared/sysdep/mcontext.h
deleted file mode 100644
index b724c54da316..000000000000
--- a/arch/um/sys-x86/shared/sysdep/mcontext.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYS_SIGCONTEXT_X86_H
7#define __SYS_SIGCONTEXT_X86_H
8
9extern void get_regs_from_mc(struct uml_pt_regs *, mcontext_t *);
10
11#ifdef __i386__
12
13#define GET_FAULTINFO_FROM_MC(fi, mc) \
14 { \
15 (fi).cr2 = (mc)->cr2; \
16 (fi).error_code = (mc)->gregs[REG_ERR]; \
17 (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \
18 }
19
20#else
21
22#define GET_FAULTINFO_FROM_MC(fi, mc) \
23 { \
24 (fi).cr2 = (mc)->gregs[REG_CR2]; \
25 (fi).error_code = (mc)->gregs[REG_ERR]; \
26 (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \
27 }
28
29#endif
30
31#endif
diff --git a/arch/um/sys-x86/shared/sysdep/ptrace.h b/arch/um/sys-x86/shared/sysdep/ptrace.h
deleted file mode 100644
index 711b1621747f..000000000000
--- a/arch/um/sys-x86/shared/sysdep/ptrace.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "ptrace_32.h"
3#else
4#include "ptrace_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/ptrace_32.h b/arch/um/sys-x86/shared/sysdep/ptrace_32.h
deleted file mode 100644
index ce77fa1e2a15..000000000000
--- a/arch/um/sys-x86/shared/sysdep/ptrace_32.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_I386_PTRACE_H
7#define __SYSDEP_I386_PTRACE_H
8
9#include <generated/user_constants.h>
10#include "sysdep/faultinfo.h"
11
12#define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
13#define MAX_REG_OFFSET (UM_FRAME_SIZE)
14
15static inline void update_debugregs(int seq) {}
16
17/* syscall emulation path in ptrace */
18
19#ifndef PTRACE_SYSEMU
20#define PTRACE_SYSEMU 31
21#endif
22
23void set_using_sysemu(int value);
24int get_using_sysemu(void);
25extern int sysemu_supported;
26
27#define REGS_IP(r) ((r)[HOST_IP])
28#define REGS_SP(r) ((r)[HOST_SP])
29#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
30#define REGS_EAX(r) ((r)[HOST_EAX])
31#define REGS_EBX(r) ((r)[HOST_EBX])
32#define REGS_ECX(r) ((r)[HOST_ECX])
33#define REGS_EDX(r) ((r)[HOST_EDX])
34#define REGS_ESI(r) ((r)[HOST_ESI])
35#define REGS_EDI(r) ((r)[HOST_EDI])
36#define REGS_EBP(r) ((r)[HOST_EBP])
37#define REGS_CS(r) ((r)[HOST_CS])
38#define REGS_SS(r) ((r)[HOST_SS])
39#define REGS_DS(r) ((r)[HOST_DS])
40#define REGS_ES(r) ((r)[HOST_ES])
41#define REGS_FS(r) ((r)[HOST_FS])
42#define REGS_GS(r) ((r)[HOST_GS])
43
44#define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
45
46#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
47#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
48
49#ifndef PTRACE_SYSEMU_SINGLESTEP
50#define PTRACE_SYSEMU_SINGLESTEP 32
51#endif
52
53struct uml_pt_regs {
54 unsigned long gp[MAX_REG_NR];
55 unsigned long fp[HOST_FPX_SIZE];
56 struct faultinfo faultinfo;
57 long syscall;
58 int is_user;
59};
60
61#define EMPTY_UML_PT_REGS { }
62
63#define UPT_IP(r) REGS_IP((r)->gp)
64#define UPT_SP(r) REGS_SP((r)->gp)
65#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
66#define UPT_EAX(r) REGS_EAX((r)->gp)
67#define UPT_EBX(r) REGS_EBX((r)->gp)
68#define UPT_ECX(r) REGS_ECX((r)->gp)
69#define UPT_EDX(r) REGS_EDX((r)->gp)
70#define UPT_ESI(r) REGS_ESI((r)->gp)
71#define UPT_EDI(r) REGS_EDI((r)->gp)
72#define UPT_EBP(r) REGS_EBP((r)->gp)
73#define UPT_ORIG_EAX(r) ((r)->syscall)
74#define UPT_CS(r) REGS_CS((r)->gp)
75#define UPT_SS(r) REGS_SS((r)->gp)
76#define UPT_DS(r) REGS_DS((r)->gp)
77#define UPT_ES(r) REGS_ES((r)->gp)
78#define UPT_FS(r) REGS_FS((r)->gp)
79#define UPT_GS(r) REGS_GS((r)->gp)
80
81#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
82#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
83#define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
84#define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
85#define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
86#define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
87
88extern int user_context(unsigned long sp);
89
90#define UPT_IS_USER(r) ((r)->is_user)
91
92struct syscall_args {
93 unsigned long args[6];
94};
95
96#define SYSCALL_ARGS(r) ((struct syscall_args) \
97 { .args = { UPT_SYSCALL_ARG1(r), \
98 UPT_SYSCALL_ARG2(r), \
99 UPT_SYSCALL_ARG3(r), \
100 UPT_SYSCALL_ARG4(r), \
101 UPT_SYSCALL_ARG5(r), \
102 UPT_SYSCALL_ARG6(r) } } )
103
104#define UPT_SET_SYSCALL_RETURN(r, res) \
105 REGS_SET_SYSCALL_RETURN((r)->regs, (res))
106
107#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
108
109#define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
110#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
111#define UPT_SYSCALL_RET(r) UPT_EAX(r)
112
113#define UPT_FAULTINFO(r) (&(r)->faultinfo)
114
115extern void arch_init_registers(int pid);
116
117#endif
diff --git a/arch/um/sys-x86/shared/sysdep/ptrace_64.h b/arch/um/sys-x86/shared/sysdep/ptrace_64.h
deleted file mode 100644
index 866fe7e47369..000000000000
--- a/arch/um/sys-x86/shared/sysdep/ptrace_64.h
+++ /dev/null
@@ -1,160 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 *
5 * Licensed under the GPL
6 */
7
8#ifndef __SYSDEP_X86_64_PTRACE_H
9#define __SYSDEP_X86_64_PTRACE_H
10
11#include <generated/user_constants.h>
12#include "sysdep/faultinfo.h"
13
14#define MAX_REG_OFFSET (UM_FRAME_SIZE)
15#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
16
17#define REGS_IP(r) ((r)[HOST_IP])
18#define REGS_SP(r) ((r)[HOST_SP])
19
20#define REGS_RBX(r) ((r)[HOST_RBX])
21#define REGS_RCX(r) ((r)[HOST_RCX])
22#define REGS_RDX(r) ((r)[HOST_RDX])
23#define REGS_RSI(r) ((r)[HOST_RSI])
24#define REGS_RDI(r) ((r)[HOST_RDI])
25#define REGS_RBP(r) ((r)[HOST_RBP])
26#define REGS_RAX(r) ((r)[HOST_RAX])
27#define REGS_R8(r) ((r)[HOST_R8])
28#define REGS_R9(r) ((r)[HOST_R9])
29#define REGS_R10(r) ((r)[HOST_R10])
30#define REGS_R11(r) ((r)[HOST_R11])
31#define REGS_R12(r) ((r)[HOST_R12])
32#define REGS_R13(r) ((r)[HOST_R13])
33#define REGS_R14(r) ((r)[HOST_R14])
34#define REGS_R15(r) ((r)[HOST_R15])
35#define REGS_CS(r) ((r)[HOST_CS])
36#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
37#define REGS_SS(r) ((r)[HOST_SS])
38
39#define HOST_FS_BASE 21
40#define HOST_GS_BASE 22
41#define HOST_DS 23
42#define HOST_ES 24
43#define HOST_FS 25
44#define HOST_GS 26
45
46/* Also defined in asm/ptrace-x86_64.h, but not in libc headers. So, these
47 * are already defined for kernel code, but not for userspace code.
48 */
49#ifndef FS_BASE
50/* These aren't defined in ptrace.h, but exist in struct user_regs_struct,
51 * which is what x86_64 ptrace actually uses.
52 */
53#define FS_BASE (HOST_FS_BASE * sizeof(long))
54#define GS_BASE (HOST_GS_BASE * sizeof(long))
55#define DS (HOST_DS * sizeof(long))
56#define ES (HOST_ES * sizeof(long))
57#define FS (HOST_FS * sizeof(long))
58#define GS (HOST_GS * sizeof(long))
59#endif
60
61#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
62#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
63#define REGS_DS(r) ((r)[HOST_DS])
64#define REGS_ES(r) ((r)[HOST_ES])
65#define REGS_FS(r) ((r)[HOST_FS])
66#define REGS_GS(r) ((r)[HOST_GS])
67
68#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_RAX])
69
70#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
71
72#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
73#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
74
75#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
76
77#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
78
79#define REGS_TRAP(r) ((r)->trap_type)
80
81#define REGS_ERR(r) ((r)->fault_type)
82
83struct uml_pt_regs {
84 unsigned long gp[MAX_REG_NR];
85 unsigned long fp[HOST_FP_SIZE];
86 struct faultinfo faultinfo;
87 long syscall;
88 int is_user;
89};
90
91#define EMPTY_UML_PT_REGS { }
92
93#define UPT_RBX(r) REGS_RBX((r)->gp)
94#define UPT_RCX(r) REGS_RCX((r)->gp)
95#define UPT_RDX(r) REGS_RDX((r)->gp)
96#define UPT_RSI(r) REGS_RSI((r)->gp)
97#define UPT_RDI(r) REGS_RDI((r)->gp)
98#define UPT_RBP(r) REGS_RBP((r)->gp)
99#define UPT_RAX(r) REGS_RAX((r)->gp)
100#define UPT_R8(r) REGS_R8((r)->gp)
101#define UPT_R9(r) REGS_R9((r)->gp)
102#define UPT_R10(r) REGS_R10((r)->gp)
103#define UPT_R11(r) REGS_R11((r)->gp)
104#define UPT_R12(r) REGS_R12((r)->gp)
105#define UPT_R13(r) REGS_R13((r)->gp)
106#define UPT_R14(r) REGS_R14((r)->gp)
107#define UPT_R15(r) REGS_R15((r)->gp)
108#define UPT_CS(r) REGS_CS((r)->gp)
109#define UPT_FS_BASE(r) REGS_FS_BASE((r)->gp)
110#define UPT_FS(r) REGS_FS((r)->gp)
111#define UPT_GS_BASE(r) REGS_GS_BASE((r)->gp)
112#define UPT_GS(r) REGS_GS((r)->gp)
113#define UPT_DS(r) REGS_DS((r)->gp)
114#define UPT_ES(r) REGS_ES((r)->gp)
115#define UPT_CS(r) REGS_CS((r)->gp)
116#define UPT_SS(r) REGS_SS((r)->gp)
117#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->gp)
118
119#define UPT_IP(r) REGS_IP((r)->gp)
120#define UPT_SP(r) REGS_SP((r)->gp)
121
122#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
123#define UPT_SYSCALL_NR(r) ((r)->syscall)
124#define UPT_SYSCALL_RET(r) UPT_RAX(r)
125
126extern int user_context(unsigned long sp);
127
128#define UPT_IS_USER(r) ((r)->is_user)
129
130#define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
131#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
132#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
133#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
134#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
135#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
136
137struct syscall_args {
138 unsigned long args[6];
139};
140
141#define SYSCALL_ARGS(r) ((struct syscall_args) \
142 { .args = { UPT_SYSCALL_ARG1(r), \
143 UPT_SYSCALL_ARG2(r), \
144 UPT_SYSCALL_ARG3(r), \
145 UPT_SYSCALL_ARG4(r), \
146 UPT_SYSCALL_ARG5(r), \
147 UPT_SYSCALL_ARG6(r) } } )
148
149#define UPT_SET_SYSCALL_RETURN(r, res) \
150 REGS_SET_SYSCALL_RETURN((r)->regs, (res))
151
152#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
153
154#define UPT_FAULTINFO(r) (&(r)->faultinfo)
155
156static inline void arch_init_registers(int pid)
157{
158}
159
160#endif
diff --git a/arch/um/sys-x86/shared/sysdep/ptrace_user.h b/arch/um/sys-x86/shared/sysdep/ptrace_user.h
deleted file mode 100644
index a92f883264ed..000000000000
--- a/arch/um/sys-x86/shared/sysdep/ptrace_user.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "ptrace_user_32.h"
3#else
4#include "ptrace_user_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/ptrace_user_32.h b/arch/um/sys-x86/shared/sysdep/ptrace_user_32.h
deleted file mode 100644
index 9d88a79a138b..000000000000
--- a/arch/um/sys-x86/shared/sysdep/ptrace_user_32.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_I386_PTRACE_USER_H__
7#define __SYSDEP_I386_PTRACE_USER_H__
8
9#include <sys/ptrace.h>
10#include <linux/ptrace.h>
11#include <asm/ptrace.h>
12#include <generated/user_constants.h>
13
14#define PT_OFFSET(r) ((r) * sizeof(long))
15
16#define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX])
17#define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX)
18
19#define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX)
20
21#define REGS_IP_INDEX EIP
22#define REGS_SP_INDEX UESP
23
24#define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE)
25
26#endif
diff --git a/arch/um/sys-x86/shared/sysdep/ptrace_user_64.h b/arch/um/sys-x86/shared/sysdep/ptrace_user_64.h
deleted file mode 100644
index 2f1b6e33d590..000000000000
--- a/arch/um/sys-x86/shared/sysdep/ptrace_user_64.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_PTRACE_USER_H__
8#define __SYSDEP_X86_64_PTRACE_USER_H__
9
10#define __FRAME_OFFSETS
11#include <sys/ptrace.h>
12#include <linux/ptrace.h>
13#include <asm/ptrace.h>
14#undef __FRAME_OFFSETS
15#include <generated/user_constants.h>
16
17#define PT_INDEX(off) ((off) / sizeof(unsigned long))
18
19#define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)])
20#define PT_SYSCALL_NR_OFFSET (ORIG_RAX)
21
22#define PT_SYSCALL_RET_OFFSET (RAX)
23
24/*
25 * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
26 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
27 * 2.4 name and value for 2.4 host compatibility.
28 */
29#ifndef PTRACE_OLDSETOPTIONS
30#define PTRACE_OLDSETOPTIONS 21
31#endif
32
33#define REGS_IP_INDEX PT_INDEX(RIP)
34#define REGS_SP_INDEX PT_INDEX(RSP)
35
36#define FP_SIZE (HOST_FP_SIZE)
37
38#endif
diff --git a/arch/um/sys-x86/shared/sysdep/skas_ptrace.h b/arch/um/sys-x86/shared/sysdep/skas_ptrace.h
deleted file mode 100644
index 453febe98993..000000000000
--- a/arch/um/sys-x86/shared/sysdep/skas_ptrace.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_X86_SKAS_PTRACE_H
7#define __SYSDEP_X86_SKAS_PTRACE_H
8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_LDT 54
21
22#endif
diff --git a/arch/um/sys-x86/shared/sysdep/stub.h b/arch/um/sys-x86/shared/sysdep/stub.h
deleted file mode 100644
index bd161e300102..000000000000
--- a/arch/um/sys-x86/shared/sysdep/stub.h
+++ /dev/null
@@ -1,14 +0,0 @@
1#include <asm/unistd.h>
2#include <sys/mman.h>
3#include <signal.h>
4#include "as-layout.h"
5#include "stub-data.h"
6
7#ifdef __i386__
8#include "stub_32.h"
9#else
10#include "stub_64.h"
11#endif
12
13extern void stub_segv_handler(int, siginfo_t *, void *);
14extern void stub_clone_handler(void);
diff --git a/arch/um/sys-x86/shared/sysdep/stub_32.h b/arch/um/sys-x86/shared/sysdep/stub_32.h
deleted file mode 100644
index 51fd256c75f0..000000000000
--- a/arch/um/sys-x86/shared/sysdep/stub_32.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_STUB_H
7#define __SYSDEP_STUB_H
8
9#include <asm/ptrace.h>
10
11#define STUB_SYSCALL_RET EAX
12#define STUB_MMAP_NR __NR_mmap2
13#define MMAP_OFFSET(o) ((o) >> UM_KERN_PAGE_SHIFT)
14
15static inline long stub_syscall0(long syscall)
16{
17 long ret;
18
19 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
20
21 return ret;
22}
23
24static inline long stub_syscall1(long syscall, long arg1)
25{
26 long ret;
27
28 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
29
30 return ret;
31}
32
33static inline long stub_syscall2(long syscall, long arg1, long arg2)
34{
35 long ret;
36
37 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
38 "c" (arg2));
39
40 return ret;
41}
42
43static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
44{
45 long ret;
46
47 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
48 "c" (arg2), "d" (arg3));
49
50 return ret;
51}
52
53static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
54 long arg4)
55{
56 long ret;
57
58 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
59 "c" (arg2), "d" (arg3), "S" (arg4));
60
61 return ret;
62}
63
64static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
65 long arg4, long arg5)
66{
67 long ret;
68
69 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
70 "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
71
72 return ret;
73}
74
75static inline void trap_myself(void)
76{
77 __asm("int3");
78}
79
80static inline void remap_stack(int fd, unsigned long offset)
81{
82 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
83 "movl %7, %%ebx ; movl %%eax, (%%ebx)"
84 : : "g" (STUB_MMAP_NR), "b" (STUB_DATA),
85 "c" (UM_KERN_PAGE_SIZE),
86 "d" (PROT_READ | PROT_WRITE),
87 "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
88 "a" (offset),
89 "i" (&((struct stub_data *) STUB_DATA)->err)
90 : "memory");
91}
92
93#endif
diff --git a/arch/um/sys-x86/shared/sysdep/stub_64.h b/arch/um/sys-x86/shared/sysdep/stub_64.h
deleted file mode 100644
index 994df93c5ed3..000000000000
--- a/arch/um/sys-x86/shared/sysdep/stub_64.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_STUB_H
7#define __SYSDEP_STUB_H
8
9#include <sysdep/ptrace_user.h>
10
11#define STUB_SYSCALL_RET PT_INDEX(RAX)
12#define STUB_MMAP_NR __NR_mmap
13#define MMAP_OFFSET(o) (o)
14
15#define __syscall_clobber "r11","rcx","memory"
16#define __syscall "syscall"
17
18static inline long stub_syscall0(long syscall)
19{
20 long ret;
21
22 __asm__ volatile (__syscall
23 : "=a" (ret)
24 : "0" (syscall) : __syscall_clobber );
25
26 return ret;
27}
28
29static inline long stub_syscall2(long syscall, long arg1, long arg2)
30{
31 long ret;
32
33 __asm__ volatile (__syscall
34 : "=a" (ret)
35 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
36
37 return ret;
38}
39
40static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
41{
42 long ret;
43
44 __asm__ volatile (__syscall
45 : "=a" (ret)
46 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
47 : __syscall_clobber );
48
49 return ret;
50}
51
52static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
53 long arg4)
54{
55 long ret;
56
57 __asm__ volatile ("movq %5,%%r10 ; " __syscall
58 : "=a" (ret)
59 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
60 "g" (arg4)
61 : __syscall_clobber, "r10" );
62
63 return ret;
64}
65
66static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
67 long arg4, long arg5)
68{
69 long ret;
70
71 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
72 : "=a" (ret)
73 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
74 "g" (arg4), "g" (arg5)
75 : __syscall_clobber, "r10", "r8" );
76
77 return ret;
78}
79
80static inline void trap_myself(void)
81{
82 __asm("int3");
83}
84
85static inline void remap_stack(long fd, unsigned long offset)
86{
87 __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
88 "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
89 "movq %%rax, (%%rbx)":
90 : "a" (STUB_MMAP_NR), "D" (STUB_DATA),
91 "S" (UM_KERN_PAGE_SIZE),
92 "d" (PROT_READ | PROT_WRITE),
93 "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
94 "g" (offset),
95 "i" (&((struct stub_data *) STUB_DATA)->err)
96 : __syscall_clobber, "r10", "r8", "r9" );
97}
98
99#endif
diff --git a/arch/um/sys-x86/shared/sysdep/syscalls.h b/arch/um/sys-x86/shared/sysdep/syscalls.h
deleted file mode 100644
index bd9a89b67e41..000000000000
--- a/arch/um/sys-x86/shared/sysdep/syscalls.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "syscalls_32.h"
3#else
4#include "syscalls_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/syscalls_32.h b/arch/um/sys-x86/shared/sysdep/syscalls_32.h
deleted file mode 100644
index 05cb796aecb5..000000000000
--- a/arch/um/sys-x86/shared/sysdep/syscalls_32.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * Copyright (C) 2000 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#include "asm/unistd.h"
7#include "sysdep/ptrace.h"
8
9typedef long syscall_handler_t(struct pt_regs);
10
11/* Not declared on x86, incompatible declarations on x86_64, so these have
12 * to go here rather than in sys_call_table.c
13 */
14extern syscall_handler_t sys_rt_sigaction;
15
16extern syscall_handler_t *sys_call_table[];
17
18#define EXECUTE_SYSCALL(syscall, regs) \
19 ((long (*)(struct syscall_args)) \
20 (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
diff --git a/arch/um/sys-x86/shared/sysdep/syscalls_64.h b/arch/um/sys-x86/shared/sysdep/syscalls_64.h
deleted file mode 100644
index 8a7d5e1da98e..000000000000
--- a/arch/um/sys-x86/shared/sysdep/syscalls_64.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_SYSCALLS_H__
8#define __SYSDEP_X86_64_SYSCALLS_H__
9
10#include <linux/msg.h>
11#include <linux/shm.h>
12
13typedef long syscall_handler_t(void);
14
15extern syscall_handler_t *sys_call_table[];
16
17#define EXECUTE_SYSCALL(syscall, regs) \
18 (((long (*)(long, long, long, long, long, long)) \
19 (*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(&regs->regs), \
20 UPT_SYSCALL_ARG2(&regs->regs), \
21 UPT_SYSCALL_ARG3(&regs->regs), \
22 UPT_SYSCALL_ARG4(&regs->regs), \
23 UPT_SYSCALL_ARG5(&regs->regs), \
24 UPT_SYSCALL_ARG6(&regs->regs)))
25
26extern long old_mmap(unsigned long addr, unsigned long len,
27 unsigned long prot, unsigned long flags,
28 unsigned long fd, unsigned long pgoff);
29extern syscall_handler_t sys_modify_ldt;
30extern syscall_handler_t sys_arch_prctl;
31
32#endif
diff --git a/arch/um/sys-x86/shared/sysdep/tls.h b/arch/um/sys-x86/shared/sysdep/tls.h
deleted file mode 100644
index 4d8f75262370..000000000000
--- a/arch/um/sys-x86/shared/sysdep/tls.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifdef __i386__
2#include "tls_32.h"
3#else
4#include "tls_64.h"
5#endif
diff --git a/arch/um/sys-x86/shared/sysdep/tls_32.h b/arch/um/sys-x86/shared/sysdep/tls_32.h
deleted file mode 100644
index 34550755b2a1..000000000000
--- a/arch/um/sys-x86/shared/sysdep/tls_32.h
+++ /dev/null
@@ -1,32 +0,0 @@
1#ifndef _SYSDEP_TLS_H
2#define _SYSDEP_TLS_H
3
4# ifndef __KERNEL__
5
6/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
7 * may be named user_desc (but in 2.4 and in header matching its API was named
8 * modify_ldt_ldt_s). */
9
10typedef struct um_dup_user_desc {
11 unsigned int entry_number;
12 unsigned int base_addr;
13 unsigned int limit;
14 unsigned int seg_32bit:1;
15 unsigned int contents:2;
16 unsigned int read_exec_only:1;
17 unsigned int limit_in_pages:1;
18 unsigned int seg_not_present:1;
19 unsigned int useable:1;
20} user_desc_t;
21
22# else /* __KERNEL__ */
23
24# include <ldt.h>
25typedef struct user_desc user_desc_t;
26
27# endif /* __KERNEL__ */
28
29#define GDT_ENTRY_TLS_MIN_I386 6
30#define GDT_ENTRY_TLS_MIN_X86_64 12
31
32#endif /* _SYSDEP_TLS_H */
diff --git a/arch/um/sys-x86/shared/sysdep/tls_64.h b/arch/um/sys-x86/shared/sysdep/tls_64.h
deleted file mode 100644
index 18c000d0357a..000000000000
--- a/arch/um/sys-x86/shared/sysdep/tls_64.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef _SYSDEP_TLS_H
2#define _SYSDEP_TLS_H
3
4# ifndef __KERNEL__
5
6/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
7 * may be named user_desc (but in 2.4 and in header matching its API was named
8 * modify_ldt_ldt_s). */
9
10typedef struct um_dup_user_desc {
11 unsigned int entry_number;
12 unsigned int base_addr;
13 unsigned int limit;
14 unsigned int seg_32bit:1;
15 unsigned int contents:2;
16 unsigned int read_exec_only:1;
17 unsigned int limit_in_pages:1;
18 unsigned int seg_not_present:1;
19 unsigned int useable:1;
20 unsigned int lm:1;
21} user_desc_t;
22
23# else /* __KERNEL__ */
24
25# include <ldt.h>
26typedef struct user_desc user_desc_t;
27
28# endif /* __KERNEL__ */
29#endif /* _SYSDEP_TLS_H */