diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-10-27 05:50:54 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-27 05:50:54 -0400 |
commit | 4944dd62de21230af039eda7cd218e9a09021d11 (patch) | |
tree | bac70f7bab8506c7e1b0408bacbdb0b1d77262e9 /arch/um/sys-i386 | |
parent | f17845e5d97ead8fbdadfd40039e058ec7cf4a42 (diff) | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
Merge commit 'v2.6.28-rc2' into tracing/urgent
Diffstat (limited to 'arch/um/sys-i386')
23 files changed, 1280 insertions, 1 deletions
diff --git a/arch/um/sys-i386/asm/archparam.h b/arch/um/sys-i386/asm/archparam.h new file mode 100644 index 000000000000..93fd723344e5 --- /dev/null +++ b/arch/um/sys-i386/asm/archparam.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_ARCHPARAM_I386_H | ||
7 | #define __UM_ARCHPARAM_I386_H | ||
8 | |||
9 | #ifdef CONFIG_X86_PAE | ||
10 | #define LAST_PKMAP 512 | ||
11 | #else | ||
12 | #define LAST_PKMAP 1024 | ||
13 | #endif | ||
14 | |||
15 | #endif | ||
16 | |||
17 | /* | ||
18 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
19 | * Emacs will notice this stuff at the end of the file and automatically | ||
20 | * adjust the settings for this buffer only. This must remain at the end | ||
21 | * of the file. | ||
22 | * --------------------------------------------------------------------------- | ||
23 | * Local variables: | ||
24 | * c-file-style: "linux" | ||
25 | * End: | ||
26 | */ | ||
diff --git a/arch/um/sys-i386/asm/elf.h b/arch/um/sys-i386/asm/elf.h new file mode 100644 index 000000000000..d0da9d7c5371 --- /dev/null +++ b/arch/um/sys-i386/asm/elf.h | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | #ifndef __UM_ELF_I386_H | ||
6 | #define __UM_ELF_I386_H | ||
7 | |||
8 | #include <asm/user.h> | ||
9 | #include "skas.h" | ||
10 | |||
11 | #define R_386_NONE 0 | ||
12 | #define R_386_32 1 | ||
13 | #define R_386_PC32 2 | ||
14 | #define R_386_GOT32 3 | ||
15 | #define R_386_PLT32 4 | ||
16 | #define R_386_COPY 5 | ||
17 | #define R_386_GLOB_DAT 6 | ||
18 | #define R_386_JMP_SLOT 7 | ||
19 | #define R_386_RELATIVE 8 | ||
20 | #define R_386_GOTOFF 9 | ||
21 | #define R_386_GOTPC 10 | ||
22 | #define R_386_NUM 11 | ||
23 | |||
24 | typedef unsigned long elf_greg_t; | ||
25 | |||
26 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) | ||
27 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | ||
28 | |||
29 | typedef struct user_i387_struct elf_fpregset_t; | ||
30 | |||
31 | /* | ||
32 | * This is used to ensure we don't load something for the wrong architecture. | ||
33 | */ | ||
34 | #define elf_check_arch(x) \ | ||
35 | (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) | ||
36 | |||
37 | #define ELF_CLASS ELFCLASS32 | ||
38 | #define ELF_DATA ELFDATA2LSB | ||
39 | #define ELF_ARCH EM_386 | ||
40 | |||
41 | #define ELF_PLAT_INIT(regs, load_addr) do { \ | ||
42 | PT_REGS_EBX(regs) = 0; \ | ||
43 | PT_REGS_ECX(regs) = 0; \ | ||
44 | PT_REGS_EDX(regs) = 0; \ | ||
45 | PT_REGS_ESI(regs) = 0; \ | ||
46 | PT_REGS_EDI(regs) = 0; \ | ||
47 | PT_REGS_EBP(regs) = 0; \ | ||
48 | PT_REGS_EAX(regs) = 0; \ | ||
49 | } while (0) | ||
50 | |||
51 | #define USE_ELF_CORE_DUMP | ||
52 | #define ELF_EXEC_PAGESIZE 4096 | ||
53 | |||
54 | #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) | ||
55 | |||
56 | /* Shamelessly stolen from include/asm-i386/elf.h */ | ||
57 | |||
58 | #define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ | ||
59 | pr_reg[0] = PT_REGS_EBX(regs); \ | ||
60 | pr_reg[1] = PT_REGS_ECX(regs); \ | ||
61 | pr_reg[2] = PT_REGS_EDX(regs); \ | ||
62 | pr_reg[3] = PT_REGS_ESI(regs); \ | ||
63 | pr_reg[4] = PT_REGS_EDI(regs); \ | ||
64 | pr_reg[5] = PT_REGS_EBP(regs); \ | ||
65 | pr_reg[6] = PT_REGS_EAX(regs); \ | ||
66 | pr_reg[7] = PT_REGS_DS(regs); \ | ||
67 | pr_reg[8] = PT_REGS_ES(regs); \ | ||
68 | /* fake once used fs and gs selectors? */ \ | ||
69 | pr_reg[9] = PT_REGS_DS(regs); \ | ||
70 | pr_reg[10] = PT_REGS_DS(regs); \ | ||
71 | pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \ | ||
72 | pr_reg[12] = PT_REGS_IP(regs); \ | ||
73 | pr_reg[13] = PT_REGS_CS(regs); \ | ||
74 | pr_reg[14] = PT_REGS_EFLAGS(regs); \ | ||
75 | pr_reg[15] = PT_REGS_SP(regs); \ | ||
76 | pr_reg[16] = PT_REGS_SS(regs); \ | ||
77 | } while (0); | ||
78 | |||
79 | extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu); | ||
80 | |||
81 | #define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu) | ||
82 | |||
83 | extern long elf_aux_hwcap; | ||
84 | #define ELF_HWCAP (elf_aux_hwcap) | ||
85 | |||
86 | extern char * elf_aux_platform; | ||
87 | #define ELF_PLATFORM (elf_aux_platform) | ||
88 | |||
89 | #define SET_PERSONALITY(ex) do { } while (0) | ||
90 | |||
91 | extern unsigned long vsyscall_ehdr; | ||
92 | extern unsigned long vsyscall_end; | ||
93 | extern unsigned long __kernel_vsyscall; | ||
94 | |||
95 | #define VSYSCALL_BASE vsyscall_ehdr | ||
96 | #define VSYSCALL_END vsyscall_end | ||
97 | |||
98 | /* | ||
99 | * This is the range that is readable by user mode, and things | ||
100 | * acting like user mode such as get_user_pages. | ||
101 | */ | ||
102 | #define FIXADDR_USER_START VSYSCALL_BASE | ||
103 | #define FIXADDR_USER_END VSYSCALL_END | ||
104 | |||
105 | /* | ||
106 | * Architecture-neutral AT_ values in 0-17, leave some room | ||
107 | * for more of them, start the x86-specific ones at 32. | ||
108 | */ | ||
109 | #define AT_SYSINFO 32 | ||
110 | #define AT_SYSINFO_EHDR 33 | ||
111 | |||
112 | #define ARCH_DLINFO \ | ||
113 | do { \ | ||
114 | if ( vsyscall_ehdr ) { \ | ||
115 | NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \ | ||
116 | NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr); \ | ||
117 | } \ | ||
118 | } while (0) | ||
119 | |||
120 | /* | ||
121 | * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out | ||
122 | * extra segments containing the vsyscall DSO contents. Dumping its | ||
123 | * contents makes post-mortem fully interpretable later without matching up | ||
124 | * the same kernel and hardware config to see what PC values meant. | ||
125 | * Dumping its extra ELF program headers includes all the other information | ||
126 | * a debugger needs to easily find how the vsyscall DSO was being used. | ||
127 | */ | ||
128 | #define ELF_CORE_EXTRA_PHDRS \ | ||
129 | (vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0 ) | ||
130 | |||
131 | #define ELF_CORE_WRITE_EXTRA_PHDRS \ | ||
132 | if ( vsyscall_ehdr ) { \ | ||
133 | const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \ | ||
134 | const struct elf_phdr *const phdrp = \ | ||
135 | (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \ | ||
136 | int i; \ | ||
137 | Elf32_Off ofs = 0; \ | ||
138 | for (i = 0; i < ehdrp->e_phnum; ++i) { \ | ||
139 | struct elf_phdr phdr = phdrp[i]; \ | ||
140 | if (phdr.p_type == PT_LOAD) { \ | ||
141 | ofs = phdr.p_offset = offset; \ | ||
142 | offset += phdr.p_filesz; \ | ||
143 | } \ | ||
144 | else \ | ||
145 | phdr.p_offset += ofs; \ | ||
146 | phdr.p_paddr = 0; /* match other core phdrs */ \ | ||
147 | DUMP_WRITE(&phdr, sizeof(phdr)); \ | ||
148 | } \ | ||
149 | } | ||
150 | #define ELF_CORE_WRITE_EXTRA_DATA \ | ||
151 | if ( vsyscall_ehdr ) { \ | ||
152 | const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \ | ||
153 | const struct elf_phdr *const phdrp = \ | ||
154 | (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \ | ||
155 | int i; \ | ||
156 | for (i = 0; i < ehdrp->e_phnum; ++i) { \ | ||
157 | if (phdrp[i].p_type == PT_LOAD) \ | ||
158 | DUMP_WRITE((void *) phdrp[i].p_vaddr, \ | ||
159 | phdrp[i].p_filesz); \ | ||
160 | } \ | ||
161 | } | ||
162 | |||
163 | #endif | ||
diff --git a/arch/um/sys-i386/asm/module.h b/arch/um/sys-i386/asm/module.h new file mode 100644 index 000000000000..5ead4a0b2e35 --- /dev/null +++ b/arch/um/sys-i386/asm/module.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __UM_MODULE_I386_H | ||
2 | #define __UM_MODULE_I386_H | ||
3 | |||
4 | /* UML is simple */ | ||
5 | struct mod_arch_specific | ||
6 | { | ||
7 | }; | ||
8 | |||
9 | #define Elf_Shdr Elf32_Shdr | ||
10 | #define Elf_Sym Elf32_Sym | ||
11 | #define Elf_Ehdr Elf32_Ehdr | ||
12 | |||
13 | #endif | ||
diff --git a/arch/um/sys-i386/asm/processor.h b/arch/um/sys-i386/asm/processor.h new file mode 100644 index 000000000000..82a9061ab5be --- /dev/null +++ b/arch/um/sys-i386/asm/processor.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_PROCESSOR_I386_H | ||
7 | #define __UM_PROCESSOR_I386_H | ||
8 | |||
9 | #include "linux/string.h" | ||
10 | #include <sysdep/host_ldt.h> | ||
11 | #include "asm/segment.h" | ||
12 | |||
13 | extern int host_has_cmov; | ||
14 | |||
15 | /* include faultinfo structure */ | ||
16 | #include "sysdep/faultinfo.h" | ||
17 | |||
18 | struct uml_tls_struct { | ||
19 | struct user_desc tls; | ||
20 | unsigned flushed:1; | ||
21 | unsigned present:1; | ||
22 | }; | ||
23 | |||
24 | struct arch_thread { | ||
25 | struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES]; | ||
26 | unsigned long debugregs[8]; | ||
27 | int debugregs_seq; | ||
28 | struct faultinfo faultinfo; | ||
29 | }; | ||
30 | |||
31 | #define INIT_ARCH_THREAD { \ | ||
32 | .tls_array = { [ 0 ... GDT_ENTRY_TLS_ENTRIES - 1 ] = \ | ||
33 | { .present = 0, .flushed = 0 } }, \ | ||
34 | .debugregs = { [ 0 ... 7 ] = 0 }, \ | ||
35 | .debugregs_seq = 0, \ | ||
36 | .faultinfo = { 0, 0, 0 } \ | ||
37 | } | ||
38 | |||
39 | static inline void arch_flush_thread(struct arch_thread *thread) | ||
40 | { | ||
41 | /* Clear any TLS still hanging */ | ||
42 | memset(&thread->tls_array, 0, sizeof(thread->tls_array)); | ||
43 | } | ||
44 | |||
45 | static inline void arch_copy_thread(struct arch_thread *from, | ||
46 | struct arch_thread *to) | ||
47 | { | ||
48 | memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array)); | ||
49 | } | ||
50 | |||
51 | #include <asm/user.h> | ||
52 | |||
53 | /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ | ||
54 | static inline void rep_nop(void) | ||
55 | { | ||
56 | __asm__ __volatile__("rep;nop": : :"memory"); | ||
57 | } | ||
58 | |||
59 | #define cpu_relax() rep_nop() | ||
60 | |||
61 | /* | ||
62 | * Default implementation of macro that returns current | ||
63 | * instruction pointer ("program counter"). Stolen | ||
64 | * from asm-i386/processor.h | ||
65 | */ | ||
66 | #define current_text_addr() \ | ||
67 | ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; }) | ||
68 | |||
69 | #define ARCH_IS_STACKGROW(address) \ | ||
70 | (address + 32 >= UPT_SP(¤t->thread.regs.regs)) | ||
71 | |||
72 | #define KSTK_EIP(tsk) KSTK_REG(tsk, EIP) | ||
73 | #define KSTK_ESP(tsk) KSTK_REG(tsk, UESP) | ||
74 | #define KSTK_EBP(tsk) KSTK_REG(tsk, EBP) | ||
75 | |||
76 | #include "asm/processor-generic.h" | ||
77 | |||
78 | #endif | ||
diff --git a/arch/um/sys-i386/asm/ptrace.h b/arch/um/sys-i386/asm/ptrace.h new file mode 100644 index 000000000000..0273e4d09af7 --- /dev/null +++ b/arch/um/sys-i386/asm/ptrace.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_PTRACE_I386_H | ||
7 | #define __UM_PTRACE_I386_H | ||
8 | |||
9 | #define HOST_AUDIT_ARCH AUDIT_ARCH_I386 | ||
10 | |||
11 | #include "linux/compiler.h" | ||
12 | #include "asm/ptrace-generic.h" | ||
13 | |||
14 | #define PT_REGS_EAX(r) UPT_EAX(&(r)->regs) | ||
15 | #define PT_REGS_EBX(r) UPT_EBX(&(r)->regs) | ||
16 | #define PT_REGS_ECX(r) UPT_ECX(&(r)->regs) | ||
17 | #define PT_REGS_EDX(r) UPT_EDX(&(r)->regs) | ||
18 | #define PT_REGS_ESI(r) UPT_ESI(&(r)->regs) | ||
19 | #define PT_REGS_EDI(r) UPT_EDI(&(r)->regs) | ||
20 | #define PT_REGS_EBP(r) UPT_EBP(&(r)->regs) | ||
21 | |||
22 | #define PT_REGS_CS(r) UPT_CS(&(r)->regs) | ||
23 | #define PT_REGS_SS(r) UPT_SS(&(r)->regs) | ||
24 | #define PT_REGS_DS(r) UPT_DS(&(r)->regs) | ||
25 | #define PT_REGS_ES(r) UPT_ES(&(r)->regs) | ||
26 | #define PT_REGS_FS(r) UPT_FS(&(r)->regs) | ||
27 | #define PT_REGS_GS(r) UPT_GS(&(r)->regs) | ||
28 | |||
29 | #define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs) | ||
30 | |||
31 | #define PT_REGS_ORIG_SYSCALL(r) PT_REGS_EAX(r) | ||
32 | #define PT_REGS_SYSCALL_RET(r) PT_REGS_EAX(r) | ||
33 | #define PT_FIX_EXEC_STACK(sp) do ; while(0) | ||
34 | |||
35 | #define profile_pc(regs) PT_REGS_IP(regs) | ||
36 | |||
37 | #define user_mode(r) UPT_IS_USER(&(r)->regs) | ||
38 | |||
39 | /* | ||
40 | * Forward declaration to avoid including sysdep/tls.h, which causes a | ||
41 | * circular include, and compilation failures. | ||
42 | */ | ||
43 | struct user_desc; | ||
44 | |||
45 | extern int get_fpxregs(struct user_fxsr_struct __user *buf, | ||
46 | struct task_struct *child); | ||
47 | extern int set_fpxregs(struct user_fxsr_struct __user *buf, | ||
48 | struct task_struct *tsk); | ||
49 | |||
50 | extern int ptrace_get_thread_area(struct task_struct *child, int idx, | ||
51 | struct user_desc __user *user_desc); | ||
52 | |||
53 | extern int ptrace_set_thread_area(struct task_struct *child, int idx, | ||
54 | struct user_desc __user *user_desc); | ||
55 | |||
56 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/archsetjmp.h b/arch/um/sys-i386/shared/sysdep/archsetjmp.h new file mode 100644 index 000000000000..0f312085ce1d --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/archsetjmp.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * arch/um/include/sysdep-i386/archsetjmp.h | ||
3 | */ | ||
4 | |||
5 | #ifndef _KLIBC_ARCHSETJMP_H | ||
6 | #define _KLIBC_ARCHSETJMP_H | ||
7 | |||
8 | struct __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 | |||
17 | typedef 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-i386/shared/sysdep/barrier.h b/arch/um/sys-i386/shared/sysdep/barrier.h new file mode 100644 index 000000000000..b58d52c5b2f4 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/barrier.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __SYSDEP_I386_BARRIER_H | ||
2 | #define __SYSDEP_I386_BARRIER_H | ||
3 | |||
4 | /* Copied from include/asm-i386 for use by userspace. i386 has the option | ||
5 | * of using mfence, but I'm just using this, which works everywhere, for now. | ||
6 | */ | ||
7 | #define mb() asm volatile("lock; addl $0,0(%esp)") | ||
8 | |||
9 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/checksum.h b/arch/um/sys-i386/shared/sysdep/checksum.h new file mode 100644 index 000000000000..0cb4645cbeb8 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/checksum.h | |||
@@ -0,0 +1,211 @@ | |||
1 | /* | ||
2 | * Licensed under the GPL | ||
3 | */ | ||
4 | |||
5 | #ifndef __UM_SYSDEP_CHECKSUM_H | ||
6 | #define __UM_SYSDEP_CHECKSUM_H | ||
7 | |||
8 | #include "linux/in6.h" | ||
9 | #include "linux/string.h" | ||
10 | |||
11 | /* | ||
12 | * computes the checksum of a memory block at buff, length len, | ||
13 | * and adds in "sum" (32-bit) | ||
14 | * | ||
15 | * returns a 32-bit number suitable for feeding into itself | ||
16 | * or csum_tcpudp_magic | ||
17 | * | ||
18 | * this function must be called with even lengths, except | ||
19 | * for the last fragment, which may be odd | ||
20 | * | ||
21 | * it's best to have buff aligned on a 32-bit boundary | ||
22 | */ | ||
23 | __wsum csum_partial(const void *buff, int len, __wsum sum); | ||
24 | |||
25 | /* | ||
26 | * Note: when you get a NULL pointer exception here this means someone | ||
27 | * passed in an incorrect kernel address to one of these functions. | ||
28 | * | ||
29 | * If you use these functions directly please don't forget the | ||
30 | * access_ok(). | ||
31 | */ | ||
32 | |||
33 | static __inline__ | ||
34 | __wsum csum_partial_copy_nocheck(const void *src, void *dst, | ||
35 | int len, __wsum sum) | ||
36 | { | ||
37 | memcpy(dst, src, len); | ||
38 | return csum_partial(dst, len, sum); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * the same as csum_partial, but copies from src while it | ||
43 | * checksums, and handles user-space pointer exceptions correctly, when needed. | ||
44 | * | ||
45 | * here even more important to align src and dst on a 32-bit (or even | ||
46 | * better 64-bit) boundary | ||
47 | */ | ||
48 | |||
49 | static __inline__ | ||
50 | __wsum csum_partial_copy_from_user(const void __user *src, void *dst, | ||
51 | int len, __wsum sum, int *err_ptr) | ||
52 | { | ||
53 | if (copy_from_user(dst, src, len)) { | ||
54 | *err_ptr = -EFAULT; | ||
55 | return (__force __wsum)-1; | ||
56 | } | ||
57 | |||
58 | return csum_partial(dst, len, sum); | ||
59 | } | ||
60 | |||
61 | /* | ||
62 | * This is a version of ip_compute_csum() optimized for IP headers, | ||
63 | * which always checksum on 4 octet boundaries. | ||
64 | * | ||
65 | * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by | ||
66 | * Arnt Gulbrandsen. | ||
67 | */ | ||
68 | static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) | ||
69 | { | ||
70 | unsigned int sum; | ||
71 | |||
72 | __asm__ __volatile__( | ||
73 | "movl (%1), %0 ;\n" | ||
74 | "subl $4, %2 ;\n" | ||
75 | "jbe 2f ;\n" | ||
76 | "addl 4(%1), %0 ;\n" | ||
77 | "adcl 8(%1), %0 ;\n" | ||
78 | "adcl 12(%1), %0 ;\n" | ||
79 | "1: adcl 16(%1), %0 ;\n" | ||
80 | "lea 4(%1), %1 ;\n" | ||
81 | "decl %2 ;\n" | ||
82 | "jne 1b ;\n" | ||
83 | "adcl $0, %0 ;\n" | ||
84 | "movl %0, %2 ;\n" | ||
85 | "shrl $16, %0 ;\n" | ||
86 | "addw %w2, %w0 ;\n" | ||
87 | "adcl $0, %0 ;\n" | ||
88 | "notl %0 ;\n" | ||
89 | "2: ;\n" | ||
90 | /* Since the input registers which are loaded with iph and ipl | ||
91 | are modified, we must also specify them as outputs, or gcc | ||
92 | will assume they contain their original values. */ | ||
93 | : "=r" (sum), "=r" (iph), "=r" (ihl) | ||
94 | : "1" (iph), "2" (ihl) | ||
95 | : "memory"); | ||
96 | return (__force __sum16)sum; | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Fold a partial checksum | ||
101 | */ | ||
102 | |||
103 | static inline __sum16 csum_fold(__wsum sum) | ||
104 | { | ||
105 | __asm__( | ||
106 | "addl %1, %0 ;\n" | ||
107 | "adcl $0xffff, %0 ;\n" | ||
108 | : "=r" (sum) | ||
109 | : "r" ((__force u32)sum << 16), | ||
110 | "0" ((__force u32)sum & 0xffff0000) | ||
111 | ); | ||
112 | return (__force __sum16)(~(__force u32)sum >> 16); | ||
113 | } | ||
114 | |||
115 | static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, | ||
116 | unsigned short len, | ||
117 | unsigned short proto, | ||
118 | __wsum sum) | ||
119 | { | ||
120 | __asm__( | ||
121 | "addl %1, %0 ;\n" | ||
122 | "adcl %2, %0 ;\n" | ||
123 | "adcl %3, %0 ;\n" | ||
124 | "adcl $0, %0 ;\n" | ||
125 | : "=r" (sum) | ||
126 | : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum)); | ||
127 | return sum; | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * computes the checksum of the TCP/UDP pseudo-header | ||
132 | * returns a 16-bit checksum, already complemented | ||
133 | */ | ||
134 | static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, | ||
135 | unsigned short len, | ||
136 | unsigned short proto, | ||
137 | __wsum sum) | ||
138 | { | ||
139 | return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * this routine is used for miscellaneous IP-like checksums, mainly | ||
144 | * in icmp.c | ||
145 | */ | ||
146 | |||
147 | static inline __sum16 ip_compute_csum(const void *buff, int len) | ||
148 | { | ||
149 | return csum_fold (csum_partial(buff, len, 0)); | ||
150 | } | ||
151 | |||
152 | #define _HAVE_ARCH_IPV6_CSUM | ||
153 | static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | ||
154 | const struct in6_addr *daddr, | ||
155 | __u32 len, unsigned short proto, | ||
156 | __wsum sum) | ||
157 | { | ||
158 | __asm__( | ||
159 | "addl 0(%1), %0 ;\n" | ||
160 | "adcl 4(%1), %0 ;\n" | ||
161 | "adcl 8(%1), %0 ;\n" | ||
162 | "adcl 12(%1), %0 ;\n" | ||
163 | "adcl 0(%2), %0 ;\n" | ||
164 | "adcl 4(%2), %0 ;\n" | ||
165 | "adcl 8(%2), %0 ;\n" | ||
166 | "adcl 12(%2), %0 ;\n" | ||
167 | "adcl %3, %0 ;\n" | ||
168 | "adcl %4, %0 ;\n" | ||
169 | "adcl $0, %0 ;\n" | ||
170 | : "=&r" (sum) | ||
171 | : "r" (saddr), "r" (daddr), | ||
172 | "r"(htonl(len)), "r"(htonl(proto)), "0"(sum)); | ||
173 | |||
174 | return csum_fold(sum); | ||
175 | } | ||
176 | |||
177 | /* | ||
178 | * Copy and checksum to user | ||
179 | */ | ||
180 | #define HAVE_CSUM_COPY_USER | ||
181 | static __inline__ __wsum csum_and_copy_to_user(const void *src, | ||
182 | void __user *dst, | ||
183 | int len, __wsum sum, int *err_ptr) | ||
184 | { | ||
185 | if (access_ok(VERIFY_WRITE, dst, len)) { | ||
186 | if (copy_to_user(dst, src, len)) { | ||
187 | *err_ptr = -EFAULT; | ||
188 | return (__force __wsum)-1; | ||
189 | } | ||
190 | |||
191 | return csum_partial(src, len, sum); | ||
192 | } | ||
193 | |||
194 | if (len) | ||
195 | *err_ptr = -EFAULT; | ||
196 | |||
197 | return (__force __wsum)-1; /* invalid checksum */ | ||
198 | } | ||
199 | |||
200 | #endif | ||
201 | |||
202 | /* | ||
203 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
204 | * Emacs will notice this stuff at the end of the file and automatically | ||
205 | * adjust the settings for this buffer only. This must remain at the end | ||
206 | * of the file. | ||
207 | * --------------------------------------------------------------------------- | ||
208 | * Local variables: | ||
209 | * c-file-style: "linux" | ||
210 | * End: | ||
211 | */ | ||
diff --git a/arch/um/sys-i386/shared/sysdep/faultinfo.h b/arch/um/sys-i386/shared/sysdep/faultinfo.h new file mode 100644 index 000000000000..db437cc373bc --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/faultinfo.h | |||
@@ -0,0 +1,29 @@ | |||
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 | */ | ||
18 | struct 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 | #define PTRACE_FULL_FAULTINFO 0 | ||
28 | |||
29 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/host_ldt.h b/arch/um/sys-i386/shared/sysdep/host_ldt.h new file mode 100644 index 000000000000..0953cc4df652 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/host_ldt.h | |||
@@ -0,0 +1,34 @@ | |||
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-i386/shared/sysdep/kernel-offsets.h b/arch/um/sys-i386/shared/sysdep/kernel-offsets.h new file mode 100644 index 000000000000..5868526b5eef --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/kernel-offsets.h | |||
@@ -0,0 +1,21 @@ | |||
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 | |||
18 | void foo(void) | ||
19 | { | ||
20 | #include <common-offsets.h> | ||
21 | } | ||
diff --git a/arch/um/sys-i386/shared/sysdep/ptrace.h b/arch/um/sys-i386/shared/sysdep/ptrace.h new file mode 100644 index 000000000000..d50e62e07070 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/ptrace.h | |||
@@ -0,0 +1,170 @@ | |||
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 "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 | |||
15 | static 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 | |||
23 | void set_using_sysemu(int value); | ||
24 | int get_using_sysemu(void); | ||
25 | extern int sysemu_supported; | ||
26 | |||
27 | #include "skas_ptregs.h" | ||
28 | |||
29 | #define REGS_IP(r) ((r)[HOST_IP]) | ||
30 | #define REGS_SP(r) ((r)[HOST_SP]) | ||
31 | #define REGS_EFLAGS(r) ((r)[HOST_EFLAGS]) | ||
32 | #define REGS_EAX(r) ((r)[HOST_EAX]) | ||
33 | #define REGS_EBX(r) ((r)[HOST_EBX]) | ||
34 | #define REGS_ECX(r) ((r)[HOST_ECX]) | ||
35 | #define REGS_EDX(r) ((r)[HOST_EDX]) | ||
36 | #define REGS_ESI(r) ((r)[HOST_ESI]) | ||
37 | #define REGS_EDI(r) ((r)[HOST_EDI]) | ||
38 | #define REGS_EBP(r) ((r)[HOST_EBP]) | ||
39 | #define REGS_CS(r) ((r)[HOST_CS]) | ||
40 | #define REGS_SS(r) ((r)[HOST_SS]) | ||
41 | #define REGS_DS(r) ((r)[HOST_DS]) | ||
42 | #define REGS_ES(r) ((r)[HOST_ES]) | ||
43 | #define REGS_FS(r) ((r)[HOST_FS]) | ||
44 | #define REGS_GS(r) ((r)[HOST_GS]) | ||
45 | |||
46 | #define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res) | ||
47 | |||
48 | #define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r)) | ||
49 | |||
50 | #ifndef PTRACE_SYSEMU_SINGLESTEP | ||
51 | #define PTRACE_SYSEMU_SINGLESTEP 32 | ||
52 | #endif | ||
53 | |||
54 | struct uml_pt_regs { | ||
55 | unsigned long gp[MAX_REG_NR]; | ||
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 | |||
88 | extern int user_context(unsigned long sp); | ||
89 | |||
90 | #define UPT_IS_USER(r) ((r)->is_user) | ||
91 | |||
92 | struct 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_REG(regs, reg) \ | ||
105 | ({ unsigned long val; \ | ||
106 | switch(reg){ \ | ||
107 | case EIP: val = UPT_IP(regs); break; \ | ||
108 | case UESP: val = UPT_SP(regs); break; \ | ||
109 | case EAX: val = UPT_EAX(regs); break; \ | ||
110 | case EBX: val = UPT_EBX(regs); break; \ | ||
111 | case ECX: val = UPT_ECX(regs); break; \ | ||
112 | case EDX: val = UPT_EDX(regs); break; \ | ||
113 | case ESI: val = UPT_ESI(regs); break; \ | ||
114 | case EDI: val = UPT_EDI(regs); break; \ | ||
115 | case EBP: val = UPT_EBP(regs); break; \ | ||
116 | case ORIG_EAX: val = UPT_ORIG_EAX(regs); break; \ | ||
117 | case CS: val = UPT_CS(regs); break; \ | ||
118 | case SS: val = UPT_SS(regs); break; \ | ||
119 | case DS: val = UPT_DS(regs); break; \ | ||
120 | case ES: val = UPT_ES(regs); break; \ | ||
121 | case FS: val = UPT_FS(regs); break; \ | ||
122 | case GS: val = UPT_GS(regs); break; \ | ||
123 | case EFL: val = UPT_EFLAGS(regs); break; \ | ||
124 | default : \ | ||
125 | panic("Bad register in UPT_REG : %d\n", reg); \ | ||
126 | val = -1; \ | ||
127 | } \ | ||
128 | val; \ | ||
129 | }) | ||
130 | |||
131 | #define UPT_SET(regs, reg, val) \ | ||
132 | do { \ | ||
133 | switch(reg){ \ | ||
134 | case EIP: UPT_IP(regs) = val; break; \ | ||
135 | case UESP: UPT_SP(regs) = val; break; \ | ||
136 | case EAX: UPT_EAX(regs) = val; break; \ | ||
137 | case EBX: UPT_EBX(regs) = val; break; \ | ||
138 | case ECX: UPT_ECX(regs) = val; break; \ | ||
139 | case EDX: UPT_EDX(regs) = val; break; \ | ||
140 | case ESI: UPT_ESI(regs) = val; break; \ | ||
141 | case EDI: UPT_EDI(regs) = val; break; \ | ||
142 | case EBP: UPT_EBP(regs) = val; break; \ | ||
143 | case ORIG_EAX: UPT_ORIG_EAX(regs) = val; break; \ | ||
144 | case CS: UPT_CS(regs) = val; break; \ | ||
145 | case SS: UPT_SS(regs) = val; break; \ | ||
146 | case DS: UPT_DS(regs) = val; break; \ | ||
147 | case ES: UPT_ES(regs) = val; break; \ | ||
148 | case FS: UPT_FS(regs) = val; break; \ | ||
149 | case GS: UPT_GS(regs) = val; break; \ | ||
150 | case EFL: UPT_EFLAGS(regs) = val; break; \ | ||
151 | default : \ | ||
152 | panic("Bad register in UPT_SET : %d\n", reg); \ | ||
153 | break; \ | ||
154 | } \ | ||
155 | } while (0) | ||
156 | |||
157 | #define UPT_SET_SYSCALL_RETURN(r, res) \ | ||
158 | REGS_SET_SYSCALL_RETURN((r)->regs, (res)) | ||
159 | |||
160 | #define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp) | ||
161 | |||
162 | #define UPT_ORIG_SYSCALL(r) UPT_EAX(r) | ||
163 | #define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r) | ||
164 | #define UPT_SYSCALL_RET(r) UPT_EAX(r) | ||
165 | |||
166 | #define UPT_FAULTINFO(r) (&(r)->faultinfo) | ||
167 | |||
168 | extern void arch_init_registers(int pid); | ||
169 | |||
170 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/ptrace_user.h b/arch/um/sys-i386/shared/sysdep/ptrace_user.h new file mode 100644 index 000000000000..ef56247e4143 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/ptrace_user.h | |||
@@ -0,0 +1,50 @@ | |||
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 "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_ARG1_OFFSET PT_OFFSET(EBX) | ||
20 | #define PT_SYSCALL_ARG2_OFFSET PT_OFFSET(ECX) | ||
21 | #define PT_SYSCALL_ARG3_OFFSET PT_OFFSET(EDX) | ||
22 | #define PT_SYSCALL_ARG4_OFFSET PT_OFFSET(ESI) | ||
23 | #define PT_SYSCALL_ARG5_OFFSET PT_OFFSET(EDI) | ||
24 | #define PT_SYSCALL_ARG6_OFFSET PT_OFFSET(EBP) | ||
25 | |||
26 | #define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX) | ||
27 | |||
28 | #define REGS_SYSCALL_NR EAX /* This is used before a system call */ | ||
29 | #define REGS_SYSCALL_ARG1 EBX | ||
30 | #define REGS_SYSCALL_ARG2 ECX | ||
31 | #define REGS_SYSCALL_ARG3 EDX | ||
32 | #define REGS_SYSCALL_ARG4 ESI | ||
33 | #define REGS_SYSCALL_ARG5 EDI | ||
34 | #define REGS_SYSCALL_ARG6 EBP | ||
35 | |||
36 | #define REGS_IP_INDEX EIP | ||
37 | #define REGS_SP_INDEX UESP | ||
38 | |||
39 | #define PT_IP_OFFSET PT_OFFSET(EIP) | ||
40 | #define PT_IP(regs) ((regs)[EIP]) | ||
41 | #define PT_SP_OFFSET PT_OFFSET(UESP) | ||
42 | #define PT_SP(regs) ((regs)[UESP]) | ||
43 | |||
44 | #define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE) | ||
45 | |||
46 | #ifndef FRAME_SIZE | ||
47 | #define FRAME_SIZE (17) | ||
48 | #endif | ||
49 | |||
50 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/sc.h b/arch/um/sys-i386/shared/sysdep/sc.h new file mode 100644 index 000000000000..c57d1780ad37 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/sc.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __SYSDEP_I386_SC_H | ||
2 | #define __SYSDEP_I386_SC_H | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #define SC_OFFSET(sc, field) \ | ||
7 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
8 | #define SC_FP_OFFSET(sc, field) \ | ||
9 | *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) | ||
10 | #define SC_FP_OFFSET_PTR(sc, field, type) \ | ||
11 | ((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) | ||
12 | |||
13 | #define SC_IP(sc) SC_OFFSET(sc, SC_IP) | ||
14 | #define SC_SP(sc) SC_OFFSET(sc, SC_SP) | ||
15 | #define SC_FS(sc) SC_OFFSET(sc, SC_FS) | ||
16 | #define SC_GS(sc) SC_OFFSET(sc, SC_GS) | ||
17 | #define SC_DS(sc) SC_OFFSET(sc, SC_DS) | ||
18 | #define SC_ES(sc) SC_OFFSET(sc, SC_ES) | ||
19 | #define SC_SS(sc) SC_OFFSET(sc, SC_SS) | ||
20 | #define SC_CS(sc) SC_OFFSET(sc, SC_CS) | ||
21 | #define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) | ||
22 | #define SC_EAX(sc) SC_OFFSET(sc, SC_EAX) | ||
23 | #define SC_EBX(sc) SC_OFFSET(sc, SC_EBX) | ||
24 | #define SC_ECX(sc) SC_OFFSET(sc, SC_ECX) | ||
25 | #define SC_EDX(sc) SC_OFFSET(sc, SC_EDX) | ||
26 | #define SC_EDI(sc) SC_OFFSET(sc, SC_EDI) | ||
27 | #define SC_ESI(sc) SC_OFFSET(sc, SC_ESI) | ||
28 | #define SC_EBP(sc) SC_OFFSET(sc, SC_EBP) | ||
29 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
30 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
31 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
32 | #define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE) | ||
33 | #define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) | ||
34 | #define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW) | ||
35 | #define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW) | ||
36 | #define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG) | ||
37 | #define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF) | ||
38 | #define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL) | ||
39 | #define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF) | ||
40 | #define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL) | ||
41 | #define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate) | ||
42 | #define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void) | ||
43 | |||
44 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/sigcontext.h b/arch/um/sys-i386/shared/sysdep/sigcontext.h new file mode 100644 index 000000000000..f583c87111a0 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/sigcontext.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYS_SIGCONTEXT_I386_H | ||
7 | #define __SYS_SIGCONTEXT_I386_H | ||
8 | |||
9 | #include "sysdep/sc.h" | ||
10 | |||
11 | #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) | ||
12 | |||
13 | #define GET_FAULTINFO_FROM_SC(fi, sc) \ | ||
14 | { \ | ||
15 | (fi).cr2 = SC_CR2(sc); \ | ||
16 | (fi).error_code = SC_ERR(sc); \ | ||
17 | (fi).trap_no = SC_TRAPNO(sc); \ | ||
18 | } | ||
19 | |||
20 | /* This is Page Fault */ | ||
21 | #define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) | ||
22 | |||
23 | /* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */ | ||
24 | #define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo) | ||
25 | |||
26 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/skas_ptrace.h b/arch/um/sys-i386/shared/sysdep/skas_ptrace.h new file mode 100644 index 000000000000..e27b8a791773 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/skas_ptrace.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYSDEP_I386_SKAS_PTRACE_H | ||
7 | #define __SYSDEP_I386_SKAS_PTRACE_H | ||
8 | |||
9 | struct ptrace_faultinfo { | ||
10 | int is_write; | ||
11 | unsigned long addr; | ||
12 | }; | ||
13 | |||
14 | struct 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-i386/shared/sysdep/stub.h b/arch/um/sys-i386/shared/sysdep/stub.h new file mode 100644 index 000000000000..977dedd9221b --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/stub.h | |||
@@ -0,0 +1,101 @@ | |||
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 <sys/mman.h> | ||
10 | #include <asm/ptrace.h> | ||
11 | #include <asm/unistd.h> | ||
12 | #include "as-layout.h" | ||
13 | #include "stub-data.h" | ||
14 | #include "kern_constants.h" | ||
15 | |||
16 | extern void stub_segv_handler(int sig); | ||
17 | extern void stub_clone_handler(void); | ||
18 | |||
19 | #define STUB_SYSCALL_RET EAX | ||
20 | #define STUB_MMAP_NR __NR_mmap2 | ||
21 | #define MMAP_OFFSET(o) ((o) >> UM_KERN_PAGE_SHIFT) | ||
22 | |||
23 | static inline long stub_syscall0(long syscall) | ||
24 | { | ||
25 | long ret; | ||
26 | |||
27 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall)); | ||
28 | |||
29 | return ret; | ||
30 | } | ||
31 | |||
32 | static inline long stub_syscall1(long syscall, long arg1) | ||
33 | { | ||
34 | long ret; | ||
35 | |||
36 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1)); | ||
37 | |||
38 | return ret; | ||
39 | } | ||
40 | |||
41 | static inline long stub_syscall2(long syscall, long arg1, long arg2) | ||
42 | { | ||
43 | long ret; | ||
44 | |||
45 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
46 | "c" (arg2)); | ||
47 | |||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) | ||
52 | { | ||
53 | long ret; | ||
54 | |||
55 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
56 | "c" (arg2), "d" (arg3)); | ||
57 | |||
58 | return ret; | ||
59 | } | ||
60 | |||
61 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, | ||
62 | long arg4) | ||
63 | { | ||
64 | long ret; | ||
65 | |||
66 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
67 | "c" (arg2), "d" (arg3), "S" (arg4)); | ||
68 | |||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, | ||
73 | long arg4, long arg5) | ||
74 | { | ||
75 | long ret; | ||
76 | |||
77 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
78 | "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)); | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | static inline void trap_myself(void) | ||
84 | { | ||
85 | __asm("int3"); | ||
86 | } | ||
87 | |||
88 | static inline void remap_stack(int fd, unsigned long offset) | ||
89 | { | ||
90 | __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;" | ||
91 | "movl %7, %%ebx ; movl %%eax, (%%ebx)" | ||
92 | : : "g" (STUB_MMAP_NR), "b" (STUB_DATA), | ||
93 | "c" (UM_KERN_PAGE_SIZE), | ||
94 | "d" (PROT_READ | PROT_WRITE), | ||
95 | "S" (MAP_FIXED | MAP_SHARED), "D" (fd), | ||
96 | "a" (offset), | ||
97 | "i" (&((struct stub_data *) STUB_DATA)->err) | ||
98 | : "memory"); | ||
99 | } | ||
100 | |||
101 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/syscalls.h b/arch/um/sys-i386/shared/sysdep/syscalls.h new file mode 100644 index 000000000000..905698197e35 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/syscalls.h | |||
@@ -0,0 +1,26 @@ | |||
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 | |||
9 | typedef 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 | */ | ||
14 | extern syscall_handler_t sys_rt_sigaction; | ||
15 | |||
16 | extern syscall_handler_t old_mmap_i386; | ||
17 | |||
18 | extern syscall_handler_t *sys_call_table[]; | ||
19 | |||
20 | #define EXECUTE_SYSCALL(syscall, regs) \ | ||
21 | ((long (*)(struct syscall_args)) \ | ||
22 | (*sys_call_table[syscall]))(SYSCALL_ARGS(®s->regs)) | ||
23 | |||
24 | extern long sys_mmap2(unsigned long addr, unsigned long len, | ||
25 | unsigned long prot, unsigned long flags, | ||
26 | unsigned long fd, unsigned long pgoff); | ||
diff --git a/arch/um/sys-i386/shared/sysdep/system.h b/arch/um/sys-i386/shared/sysdep/system.h new file mode 100644 index 000000000000..d1b93c436200 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/system.h | |||
@@ -0,0 +1,132 @@ | |||
1 | #ifndef _ASM_X86_SYSTEM_H_ | ||
2 | #define _ASM_X86_SYSTEM_H_ | ||
3 | |||
4 | #include <asm/asm.h> | ||
5 | #include <asm/segment.h> | ||
6 | #include <asm/cpufeature.h> | ||
7 | #include <asm/cmpxchg.h> | ||
8 | #include <asm/nops.h> | ||
9 | |||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/irqflags.h> | ||
12 | |||
13 | /* entries in ARCH_DLINFO: */ | ||
14 | #ifdef CONFIG_IA32_EMULATION | ||
15 | # define AT_VECTOR_SIZE_ARCH 2 | ||
16 | #else | ||
17 | # define AT_VECTOR_SIZE_ARCH 1 | ||
18 | #endif | ||
19 | |||
20 | extern unsigned long arch_align_stack(unsigned long sp); | ||
21 | |||
22 | void default_idle(void); | ||
23 | |||
24 | /* | ||
25 | * Force strict CPU ordering. | ||
26 | * And yes, this is required on UP too when we're talking | ||
27 | * to devices. | ||
28 | */ | ||
29 | #ifdef CONFIG_X86_32 | ||
30 | /* | ||
31 | * Some non-Intel clones support out of order store. wmb() ceases to be a | ||
32 | * nop for these. | ||
33 | */ | ||
34 | #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) | ||
35 | #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) | ||
36 | #define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) | ||
37 | #else | ||
38 | #define mb() asm volatile("mfence":::"memory") | ||
39 | #define rmb() asm volatile("lfence":::"memory") | ||
40 | #define wmb() asm volatile("sfence" ::: "memory") | ||
41 | #endif | ||
42 | |||
43 | /** | ||
44 | * read_barrier_depends - Flush all pending reads that subsequents reads | ||
45 | * depend on. | ||
46 | * | ||
47 | * No data-dependent reads from memory-like regions are ever reordered | ||
48 | * over this barrier. All reads preceding this primitive are guaranteed | ||
49 | * to access memory (but not necessarily other CPUs' caches) before any | ||
50 | * reads following this primitive that depend on the data return by | ||
51 | * any of the preceding reads. This primitive is much lighter weight than | ||
52 | * rmb() on most CPUs, and is never heavier weight than is | ||
53 | * rmb(). | ||
54 | * | ||
55 | * These ordering constraints are respected by both the local CPU | ||
56 | * and the compiler. | ||
57 | * | ||
58 | * Ordering is not guaranteed by anything other than these primitives, | ||
59 | * not even by data dependencies. See the documentation for | ||
60 | * memory_barrier() for examples and URLs to more information. | ||
61 | * | ||
62 | * For example, the following code would force ordering (the initial | ||
63 | * value of "a" is zero, "b" is one, and "p" is "&a"): | ||
64 | * | ||
65 | * <programlisting> | ||
66 | * CPU 0 CPU 1 | ||
67 | * | ||
68 | * b = 2; | ||
69 | * memory_barrier(); | ||
70 | * p = &b; q = p; | ||
71 | * read_barrier_depends(); | ||
72 | * d = *q; | ||
73 | * </programlisting> | ||
74 | * | ||
75 | * because the read of "*q" depends on the read of "p" and these | ||
76 | * two reads are separated by a read_barrier_depends(). However, | ||
77 | * the following code, with the same initial values for "a" and "b": | ||
78 | * | ||
79 | * <programlisting> | ||
80 | * CPU 0 CPU 1 | ||
81 | * | ||
82 | * a = 2; | ||
83 | * memory_barrier(); | ||
84 | * b = 3; y = b; | ||
85 | * read_barrier_depends(); | ||
86 | * x = a; | ||
87 | * </programlisting> | ||
88 | * | ||
89 | * does not enforce ordering, since there is no data dependency between | ||
90 | * the read of "a" and the read of "b". Therefore, on some CPUs, such | ||
91 | * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() | ||
92 | * in cases like this where there are no data dependencies. | ||
93 | **/ | ||
94 | |||
95 | #define read_barrier_depends() do { } while (0) | ||
96 | |||
97 | #ifdef CONFIG_SMP | ||
98 | #define smp_mb() mb() | ||
99 | #ifdef CONFIG_X86_PPRO_FENCE | ||
100 | # define smp_rmb() rmb() | ||
101 | #else | ||
102 | # define smp_rmb() barrier() | ||
103 | #endif | ||
104 | #ifdef CONFIG_X86_OOSTORE | ||
105 | # define smp_wmb() wmb() | ||
106 | #else | ||
107 | # define smp_wmb() barrier() | ||
108 | #endif | ||
109 | #define smp_read_barrier_depends() read_barrier_depends() | ||
110 | #define set_mb(var, value) do { (void)xchg(&var, value); } while (0) | ||
111 | #else | ||
112 | #define smp_mb() barrier() | ||
113 | #define smp_rmb() barrier() | ||
114 | #define smp_wmb() barrier() | ||
115 | #define smp_read_barrier_depends() do { } while (0) | ||
116 | #define set_mb(var, value) do { var = value; barrier(); } while (0) | ||
117 | #endif | ||
118 | |||
119 | /* | ||
120 | * Stop RDTSC speculation. This is needed when you need to use RDTSC | ||
121 | * (or get_cycles or vread that possibly accesses the TSC) in a defined | ||
122 | * code region. | ||
123 | * | ||
124 | * (Could use an alternative three way for this if there was one.) | ||
125 | */ | ||
126 | static inline void rdtsc_barrier(void) | ||
127 | { | ||
128 | alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC); | ||
129 | alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC); | ||
130 | } | ||
131 | |||
132 | #endif | ||
diff --git a/arch/um/sys-i386/shared/sysdep/tls.h b/arch/um/sys-i386/shared/sysdep/tls.h new file mode 100644 index 000000000000..34550755b2a1 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/tls.h | |||
@@ -0,0 +1,32 @@ | |||
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 | |||
10 | typedef 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> | ||
25 | typedef 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-i386/shared/sysdep/vm-flags.h b/arch/um/sys-i386/shared/sysdep/vm-flags.h new file mode 100644 index 000000000000..e0d24c568dbc --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/vm-flags.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __VM_FLAGS_I386_H | ||
7 | #define __VM_FLAGS_I386_H | ||
8 | |||
9 | #define VM_DATA_DEFAULT_FLAGS \ | ||
10 | (VM_READ | VM_WRITE | \ | ||
11 | ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ | ||
12 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
13 | |||
14 | #endif | ||
diff --git a/arch/um/sys-i386/stub.S b/arch/um/sys-i386/stub.S index 7699e89f660f..c41b04bf5fa0 100644 --- a/arch/um/sys-i386/stub.S +++ b/arch/um/sys-i386/stub.S | |||
@@ -1,4 +1,3 @@ | |||
1 | #include "uml-config.h" | ||
2 | #include "as-layout.h" | 1 | #include "as-layout.h" |
3 | 2 | ||
4 | .globl syscall_stub | 3 | .globl syscall_stub |
diff --git a/arch/um/sys-i386/syscalls.c b/arch/um/sys-i386/syscalls.c index e2d142684412..857ca0b3bdef 100644 --- a/arch/um/sys-i386/syscalls.c +++ b/arch/um/sys-i386/syscalls.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "linux/sched.h" | 6 | #include "linux/sched.h" |
7 | #include "linux/shm.h" | 7 | #include "linux/shm.h" |
8 | #include "linux/ipc.h" | 8 | #include "linux/ipc.h" |
9 | #include "linux/syscalls.h" | ||
9 | #include "asm/mman.h" | 10 | #include "asm/mman.h" |
10 | #include "asm/uaccess.h" | 11 | #include "asm/uaccess.h" |
11 | #include "asm/unistd.h" | 12 | #include "asm/unistd.h" |