diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2011-08-18 15:02:29 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2011-11-02 09:14:48 -0400 |
commit | 412f90ed13c86f066a4ab14ed5bcd0793ef0355d (patch) | |
tree | 3c2c69ab63b5becb52e852bfa361c45a17bc345d /arch/um/sys-x86_64/ptrace.c | |
parent | ab785c1dd4bef85f308504c83bcf47ce787e1565 (diff) |
um: Get rid of UPT_SET/UPT_REG macros
the only users are arch getreg()/putreg() and it's easier to handle
it there instead of playing with macros from hell
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_64/ptrace.c')
-rw-r--r-- | arch/um/sys-x86_64/ptrace.c | 103 |
1 files changed, 88 insertions, 15 deletions
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c index 4005506834fd..44e68e0c0d10 100644 --- a/arch/um/sys-x86_64/ptrace.c +++ b/arch/um/sys-x86_64/ptrace.c | |||
@@ -18,10 +18,39 @@ | |||
18 | */ | 18 | */ |
19 | #define FLAG_MASK 0x44dd5UL | 19 | #define FLAG_MASK 0x44dd5UL |
20 | 20 | ||
21 | int putreg(struct task_struct *child, int regno, unsigned long value) | 21 | static const int reg_offsets[] = |
22 | { | 22 | { |
23 | unsigned long tmp; | 23 | [R8 >> 3] = HOST_R8, |
24 | [R9 >> 3] = HOST_R9, | ||
25 | [R10 >> 3] = HOST_R10, | ||
26 | [R11 >> 3] = HOST_R11, | ||
27 | [R12 >> 3] = HOST_R12, | ||
28 | [R13 >> 3] = HOST_R13, | ||
29 | [R14 >> 3] = HOST_R14, | ||
30 | [R15 >> 3] = HOST_R15, | ||
31 | [RIP >> 3] = HOST_IP, | ||
32 | [RSP >> 3] = HOST_SP, | ||
33 | [RAX >> 3] = HOST_RAX, | ||
34 | [RBX >> 3] = HOST_RBX, | ||
35 | [RCX >> 3] = HOST_RCX, | ||
36 | [RDX >> 3] = HOST_RDX, | ||
37 | [RSI >> 3] = HOST_RSI, | ||
38 | [RDI >> 3] = HOST_RDI, | ||
39 | [RBP >> 3] = HOST_RBP, | ||
40 | [CS >> 3] = HOST_CS, | ||
41 | [SS >> 3] = HOST_SS, | ||
42 | [FS_BASE >> 3] = HOST_FS_BASE, | ||
43 | [GS_BASE >> 3] = HOST_GS_BASE, | ||
44 | [DS >> 3] = HOST_DS, | ||
45 | [ES >> 3] = HOST_ES, | ||
46 | [FS >> 3] = HOST_FS, | ||
47 | [GS >> 3] = HOST_GS, | ||
48 | [EFLAGS >> 3] = HOST_EFLAGS, | ||
49 | [ORIG_RAX >> 3] = HOST_ORIG_RAX, | ||
50 | }; | ||
24 | 51 | ||
52 | int putreg(struct task_struct *child, int regno, unsigned long value) | ||
53 | { | ||
25 | #ifdef TIF_IA32 | 54 | #ifdef TIF_IA32 |
26 | /* | 55 | /* |
27 | * Some code in the 64bit emulation may not be 64bit clean. | 56 | * Some code in the 64bit emulation may not be 64bit clean. |
@@ -31,6 +60,26 @@ int putreg(struct task_struct *child, int regno, unsigned long value) | |||
31 | value &= 0xffffffff; | 60 | value &= 0xffffffff; |
32 | #endif | 61 | #endif |
33 | switch (regno) { | 62 | switch (regno) { |
63 | case R8: | ||
64 | case R9: | ||
65 | case R10: | ||
66 | case R11: | ||
67 | case R12: | ||
68 | case R13: | ||
69 | case R14: | ||
70 | case R15: | ||
71 | case RIP: | ||
72 | case RSP: | ||
73 | case RAX: | ||
74 | case RBX: | ||
75 | case RCX: | ||
76 | case RDX: | ||
77 | case RSI: | ||
78 | case RDI: | ||
79 | case RBP: | ||
80 | case ORIG_RAX: | ||
81 | break; | ||
82 | |||
34 | case FS: | 83 | case FS: |
35 | case GS: | 84 | case GS: |
36 | case DS: | 85 | case DS: |
@@ -50,12 +99,14 @@ int putreg(struct task_struct *child, int regno, unsigned long value) | |||
50 | 99 | ||
51 | case EFLAGS: | 100 | case EFLAGS: |
52 | value &= FLAG_MASK; | 101 | value &= FLAG_MASK; |
53 | tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK; | 102 | child->thread.regs.regs.gp[HOST_EFLAGS] |= value; |
54 | value |= tmp; | 103 | return 0; |
55 | break; | 104 | |
105 | default: | ||
106 | panic("Bad register in putreg(): %d\n", regno); | ||
56 | } | 107 | } |
57 | 108 | ||
58 | PT_REGS_SET(&child->thread.regs, regno, value); | 109 | child->thread.regs.regs.gp[reg_offsets[regno >> 3]] = value; |
59 | return 0; | 110 | return 0; |
60 | } | 111 | } |
61 | 112 | ||
@@ -80,24 +131,46 @@ int poke_user(struct task_struct *child, long addr, long data) | |||
80 | 131 | ||
81 | unsigned long getreg(struct task_struct *child, int regno) | 132 | unsigned long getreg(struct task_struct *child, int regno) |
82 | { | 133 | { |
83 | unsigned long retval = ~0UL; | 134 | unsigned long mask = ~0UL; |
135 | #ifdef TIF_IA32 | ||
136 | if (test_tsk_thread_flag(child, TIF_IA32)) | ||
137 | mask = 0xffffffff; | ||
138 | #endif | ||
84 | switch (regno) { | 139 | switch (regno) { |
140 | case R8: | ||
141 | case R9: | ||
142 | case R10: | ||
143 | case R11: | ||
144 | case R12: | ||
145 | case R13: | ||
146 | case R14: | ||
147 | case R15: | ||
148 | case RIP: | ||
149 | case RSP: | ||
150 | case RAX: | ||
151 | case RBX: | ||
152 | case RCX: | ||
153 | case RDX: | ||
154 | case RSI: | ||
155 | case RDI: | ||
156 | case RBP: | ||
157 | case ORIG_RAX: | ||
158 | case EFLAGS: | ||
159 | case FS_BASE: | ||
160 | case GS_BASE: | ||
161 | break; | ||
85 | case FS: | 162 | case FS: |
86 | case GS: | 163 | case GS: |
87 | case DS: | 164 | case DS: |
88 | case ES: | 165 | case ES: |
89 | case SS: | 166 | case SS: |
90 | case CS: | 167 | case CS: |
91 | retval = 0xffff; | 168 | mask = 0xffff; |
92 | /* fall through */ | 169 | break; |
93 | default: | 170 | default: |
94 | retval &= PT_REG(&child->thread.regs, regno); | 171 | panic("Bad register in getreg: %d\n", regno); |
95 | #ifdef TIF_IA32 | ||
96 | if (test_tsk_thread_flag(child, TIF_IA32)) | ||
97 | retval &= 0xffffffff; | ||
98 | #endif | ||
99 | } | 172 | } |
100 | return retval; | 173 | return mask & child->thread.regs.regs.gp[reg_offsets[regno >> 3]]; |
101 | } | 174 | } |
102 | 175 | ||
103 | int peek_user(struct task_struct *child, long addr, long data) | 176 | int peek_user(struct task_struct *child, long addr, long data) |