diff options
-rw-r--r-- | arch/um/Makefile | 8 | ||||
-rw-r--r-- | arch/um/os-Linux/util/Makefile | 2 | ||||
-rw-r--r-- | arch/um/os-Linux/util/mk_user_constants.c | 10 | ||||
-rw-r--r-- | arch/um/sys-i386/user-offsets.c | 69 | ||||
-rw-r--r-- | arch/um/sys-x86_64/user-offsets.c | 78 |
5 files changed, 158 insertions, 9 deletions
diff --git a/arch/um/Makefile b/arch/um/Makefile index 1d136640d360..e3465dab57fd 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -166,6 +166,14 @@ endef | |||
166 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | 166 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h |
167 | $(call filechk,umlconfig) | 167 | $(call filechk,umlconfig) |
168 | 168 | ||
169 | $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c | ||
170 | $(CC) $(USER_CFLAGS) -S -o $@ $< | ||
171 | |||
172 | $(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s | ||
173 | $(call filechk,gen-asm-offsets) | ||
174 | |||
175 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h | ||
176 | |||
169 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task | 177 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task |
170 | $(call filechk,gen_header) | 178 | $(call filechk,gen_header) |
171 | 179 | ||
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile index fb00ddf969bd..9778aed0c314 100644 --- a/arch/um/os-Linux/util/Makefile +++ b/arch/um/os-Linux/util/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | hostprogs-y := mk_user_constants | 1 | hostprogs-y := mk_user_constants |
2 | always := $(hostprogs-y) | 2 | always := $(hostprogs-y) |
3 | 3 | ||
4 | mk_user_constants-objs := mk_user_constants.o | 4 | HOSTCFLAGS_mk_user_constants.o := -I$(objtree)/arch/um |
diff --git a/arch/um/os-Linux/util/mk_user_constants.c b/arch/um/os-Linux/util/mk_user_constants.c index 0933518aa8bd..4838f30eecf0 100644 --- a/arch/um/os-Linux/util/mk_user_constants.c +++ b/arch/um/os-Linux/util/mk_user_constants.c | |||
@@ -1,11 +1,5 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <asm/types.h> | 2 | #include <user-offsets.h> |
3 | /* For some reason, x86_64 nowhere defines u64 and u32, even though they're | ||
4 | * used throughout the headers. | ||
5 | */ | ||
6 | typedef __u64 u64; | ||
7 | typedef __u32 u32; | ||
8 | #include <asm/user.h> | ||
9 | 3 | ||
10 | int main(int argc, char **argv) | 4 | int main(int argc, char **argv) |
11 | { | 5 | { |
@@ -20,7 +14,7 @@ int main(int argc, char **argv) | |||
20 | * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on | 14 | * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on |
21 | * both x86_64 and i386. | 15 | * both x86_64 and i386. |
22 | */ | 16 | */ |
23 | printf("#define UM_FRAME_SIZE %d\n", (int) sizeof(struct user_regs_struct)); | 17 | printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE); |
24 | 18 | ||
25 | printf("\n"); | 19 | printf("\n"); |
26 | printf("#endif\n"); | 20 | printf("#endif\n"); |
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c new file mode 100644 index 000000000000..3ceaabceb3d7 --- /dev/null +++ b/arch/um/sys-i386/user-offsets.c | |||
@@ -0,0 +1,69 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <signal.h> | ||
3 | #include <asm/ptrace.h> | ||
4 | #include <asm/user.h> | ||
5 | #include <linux/stddef.h> | ||
6 | |||
7 | #define DEFINE(sym, val) \ | ||
8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
9 | |||
10 | #define OFFSET(sym, str, mem) \ | ||
11 | DEFINE(sym, offsetof(struct str, mem)); | ||
12 | |||
13 | void foo(void) | ||
14 | { | ||
15 | OFFSET(SC_IP, sigcontext, eip); | ||
16 | OFFSET(SC_SP, sigcontext, esp); | ||
17 | OFFSET(SC_FS, sigcontext, fs); | ||
18 | OFFSET(SC_GS, sigcontext, gs); | ||
19 | OFFSET(SC_DS, sigcontext, ds); | ||
20 | OFFSET(SC_ES, sigcontext, es); | ||
21 | OFFSET(SC_SS, sigcontext, ss); | ||
22 | OFFSET(SC_CS, sigcontext, cs); | ||
23 | OFFSET(SC_EFLAGS, sigcontext, eflags); | ||
24 | OFFSET(SC_EAX, sigcontext, eax); | ||
25 | OFFSET(SC_EBX, sigcontext, ebx); | ||
26 | OFFSET(SC_ECX, sigcontext, ecx); | ||
27 | OFFSET(SC_EDX, sigcontext, edx); | ||
28 | OFFSET(SC_EDI, sigcontext, edi); | ||
29 | OFFSET(SC_ESI, sigcontext, esi); | ||
30 | OFFSET(SC_EBP, sigcontext, ebp); | ||
31 | OFFSET(SC_TRAPNO, sigcontext, trapno); | ||
32 | OFFSET(SC_ERR, sigcontext, err); | ||
33 | OFFSET(SC_CR2, sigcontext, cr2); | ||
34 | OFFSET(SC_FPSTATE, sigcontext, fpstate); | ||
35 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | ||
36 | OFFSET(SC_FP_CW, _fpstate, cw); | ||
37 | OFFSET(SC_FP_SW, _fpstate, sw); | ||
38 | OFFSET(SC_FP_TAG, _fpstate, tag); | ||
39 | OFFSET(SC_FP_IPOFF, _fpstate, ipoff); | ||
40 | OFFSET(SC_FP_CSSEL, _fpstate, cssel); | ||
41 | OFFSET(SC_FP_DATAOFF, _fpstate, dataoff); | ||
42 | OFFSET(SC_FP_DATASEL, _fpstate, datasel); | ||
43 | OFFSET(SC_FP_ST, _fpstate, _st); | ||
44 | OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env); | ||
45 | |||
46 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | ||
47 | DEFINE(HOST_FP_SIZE, | ||
48 | sizeof(struct user_i387_struct) / sizeof(unsigned long)); | ||
49 | DEFINE(HOST_XFP_SIZE, | ||
50 | sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); | ||
51 | |||
52 | DEFINE(HOST_IP, EIP); | ||
53 | DEFINE(HOST_SP, UESP); | ||
54 | DEFINE(HOST_EFLAGS, EFL); | ||
55 | DEFINE(HOST_EAX, EAX); | ||
56 | DEFINE(HOST_EBX, EBX); | ||
57 | DEFINE(HOST_ECX, ECX); | ||
58 | DEFINE(HOST_EDX, EDX); | ||
59 | DEFINE(HOST_ESI, ESI); | ||
60 | DEFINE(HOST_EDI, EDI); | ||
61 | DEFINE(HOST_EBP, EBP); | ||
62 | DEFINE(HOST_CS, CS); | ||
63 | DEFINE(HOST_SS, SS); | ||
64 | DEFINE(HOST_DS, DS); | ||
65 | DEFINE(HOST_FS, FS); | ||
66 | DEFINE(HOST_ES, ES); | ||
67 | DEFINE(HOST_GS, GS); | ||
68 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | ||
69 | } | ||
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c new file mode 100644 index 000000000000..5e14792e4838 --- /dev/null +++ b/arch/um/sys-x86_64/user-offsets.c | |||
@@ -0,0 +1,78 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stddef.h> | ||
3 | #include <signal.h> | ||
4 | #define __FRAME_OFFSETS | ||
5 | #include <asm/ptrace.h> | ||
6 | #include <asm/user.h> | ||
7 | |||
8 | #define DEFINE(sym, val) \ | ||
9 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
10 | |||
11 | #define OFFSET(sym, str, mem) \ | ||
12 | DEFINE(sym, offsetof(struct str, mem)); | ||
13 | |||
14 | void foo(void) | ||
15 | { | ||
16 | OFFSET(SC_RBX, sigcontext, rbx); | ||
17 | OFFSET(SC_RCX, sigcontext, rcx); | ||
18 | OFFSET(SC_RDX, sigcontext, rdx); | ||
19 | OFFSET(SC_RSI, sigcontext, rsi); | ||
20 | OFFSET(SC_RDI, sigcontext, rdi); | ||
21 | OFFSET(SC_RBP, sigcontext, rbp); | ||
22 | OFFSET(SC_RAX, sigcontext, rax); | ||
23 | OFFSET(SC_R8, sigcontext, r8); | ||
24 | OFFSET(SC_R9, sigcontext, r9); | ||
25 | OFFSET(SC_R10, sigcontext, r10); | ||
26 | OFFSET(SC_R11, sigcontext, r11); | ||
27 | OFFSET(SC_R12, sigcontext, r12); | ||
28 | OFFSET(SC_R13, sigcontext, r13); | ||
29 | OFFSET(SC_R14, sigcontext, r14); | ||
30 | OFFSET(SC_R15, sigcontext, r15); | ||
31 | OFFSET(SC_IP, sigcontext, rip); | ||
32 | OFFSET(SC_SP, sigcontext, rsp); | ||
33 | OFFSET(SC_CR2, sigcontext, cr2); | ||
34 | OFFSET(SC_ERR, sigcontext, err); | ||
35 | OFFSET(SC_TRAPNO, sigcontext, trapno); | ||
36 | OFFSET(SC_CS, sigcontext, cs); | ||
37 | OFFSET(SC_FS, sigcontext, fs); | ||
38 | OFFSET(SC_GS, sigcontext, gs); | ||
39 | OFFSET(SC_EFLAGS, sigcontext, eflags); | ||
40 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | ||
41 | #if 0 | ||
42 | OFFSET(SC_ORIG_RAX, sigcontext, orig_rax); | ||
43 | OFFSET(SC_DS, sigcontext, ds); | ||
44 | OFFSET(SC_ES, sigcontext, es); | ||
45 | OFFSET(SC_SS, sigcontext, ss); | ||
46 | #endif | ||
47 | |||
48 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | ||
49 | DEFINE(HOST_RBX, RBX); | ||
50 | DEFINE(HOST_RCX, RCX); | ||
51 | DEFINE(HOST_RDI, RDI); | ||
52 | DEFINE(HOST_RSI, RSI); | ||
53 | DEFINE(HOST_RDX, RDX); | ||
54 | DEFINE(HOST_RBP, RBP); | ||
55 | DEFINE(HOST_RAX, RAX); | ||
56 | DEFINE(HOST_R8, R8); | ||
57 | DEFINE(HOST_R9, R9); | ||
58 | DEFINE(HOST_R10, R10); | ||
59 | DEFINE(HOST_R11, R11); | ||
60 | DEFINE(HOST_R12, R12); | ||
61 | DEFINE(HOST_R13, R13); | ||
62 | DEFINE(HOST_R14, R14); | ||
63 | DEFINE(HOST_R15, R15); | ||
64 | DEFINE(HOST_ORIG_RAX, ORIG_RAX); | ||
65 | DEFINE(HOST_CS, CS); | ||
66 | DEFINE(HOST_SS, SS); | ||
67 | DEFINE(HOST_EFLAGS, EFLAGS); | ||
68 | #if 0 | ||
69 | DEFINE(HOST_FS, FS); | ||
70 | DEFINE(HOST_GS, GS); | ||
71 | DEFINE(HOST_DS, DS); | ||
72 | DEFINE(HOST_ES, ES); | ||
73 | #endif | ||
74 | |||
75 | DEFINE(HOST_IP, RIP); | ||
76 | DEFINE(HOST_SP, RSP); | ||
77 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | ||
78 | } | ||