uml: kernel_thread shouldn't panic
[pv_ops_mirror.git] / arch / um / sys-x86_64 / user-offsets.c
blob899cebb57c3f116177662399c805bffe5cee32e0
1 #include <stdio.h>
2 #include <stddef.h>
3 #include <signal.h>
4 #include <sys/poll.h>
5 #define __FRAME_OFFSETS
6 #include <asm/ptrace.h>
7 #include <asm/types.h>
8 /* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I
9 * refuse to include here, even though they're used throughout the headers.
10 * These are used in asm/user.h, and that include can't be avoided because of
11 * the sizeof(struct user_regs_struct) below.
13 typedef __u64 u64;
14 typedef __u32 u32;
15 #include <asm/user.h>
17 #define DEFINE(sym, val) \
18 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
20 #define DEFINE_LONGS(sym, val) \
21 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
23 #define OFFSET(sym, str, mem) \
24 DEFINE(sym, offsetof(struct str, mem));
26 void foo(void)
28 OFFSET(HOST_SC_RBX, sigcontext, rbx);
29 OFFSET(HOST_SC_RCX, sigcontext, rcx);
30 OFFSET(HOST_SC_RDX, sigcontext, rdx);
31 OFFSET(HOST_SC_RSI, sigcontext, rsi);
32 OFFSET(HOST_SC_RDI, sigcontext, rdi);
33 OFFSET(HOST_SC_RBP, sigcontext, rbp);
34 OFFSET(HOST_SC_RAX, sigcontext, rax);
35 OFFSET(HOST_SC_R8, sigcontext, r8);
36 OFFSET(HOST_SC_R9, sigcontext, r9);
37 OFFSET(HOST_SC_R10, sigcontext, r10);
38 OFFSET(HOST_SC_R11, sigcontext, r11);
39 OFFSET(HOST_SC_R12, sigcontext, r12);
40 OFFSET(HOST_SC_R13, sigcontext, r13);
41 OFFSET(HOST_SC_R14, sigcontext, r14);
42 OFFSET(HOST_SC_R15, sigcontext, r15);
43 OFFSET(HOST_SC_IP, sigcontext, rip);
44 OFFSET(HOST_SC_SP, sigcontext, rsp);
45 OFFSET(HOST_SC_CR2, sigcontext, cr2);
46 OFFSET(HOST_SC_ERR, sigcontext, err);
47 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
48 OFFSET(HOST_SC_CS, sigcontext, cs);
49 OFFSET(HOST_SC_FS, sigcontext, fs);
50 OFFSET(HOST_SC_GS, sigcontext, gs);
51 OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
52 OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
53 #if 0
54 OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax);
55 OFFSET(HOST_SC_DS, sigcontext, ds);
56 OFFSET(HOST_SC_ES, sigcontext, es);
57 OFFSET(HOST_SC_SS, sigcontext, ss);
58 #endif
60 DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE);
61 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
62 DEFINE(HOST_XFP_SIZE, 0);
63 DEFINE_LONGS(HOST_RBX, RBX);
64 DEFINE_LONGS(HOST_RCX, RCX);
65 DEFINE_LONGS(HOST_RDI, RDI);
66 DEFINE_LONGS(HOST_RSI, RSI);
67 DEFINE_LONGS(HOST_RDX, RDX);
68 DEFINE_LONGS(HOST_RBP, RBP);
69 DEFINE_LONGS(HOST_RAX, RAX);
70 DEFINE_LONGS(HOST_R8, R8);
71 DEFINE_LONGS(HOST_R9, R9);
72 DEFINE_LONGS(HOST_R10, R10);
73 DEFINE_LONGS(HOST_R11, R11);
74 DEFINE_LONGS(HOST_R12, R12);
75 DEFINE_LONGS(HOST_R13, R13);
76 DEFINE_LONGS(HOST_R14, R14);
77 DEFINE_LONGS(HOST_R15, R15);
78 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
79 DEFINE_LONGS(HOST_CS, CS);
80 DEFINE_LONGS(HOST_SS, SS);
81 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
82 #if 0
83 DEFINE_LONGS(HOST_FS, FS);
84 DEFINE_LONGS(HOST_GS, GS);
85 DEFINE_LONGS(HOST_DS, DS);
86 DEFINE_LONGS(HOST_ES, ES);
87 #endif
89 DEFINE_LONGS(HOST_IP, RIP);
90 DEFINE_LONGS(HOST_SP, RSP);
91 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
93 /* XXX Duplicated between i386 and x86_64 */
94 DEFINE(UM_POLLIN, POLLIN);
95 DEFINE(UM_POLLPRI, POLLPRI);
96 DEFINE(UM_POLLOUT, POLLOUT);