diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-01-30 07:30:56 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:56 -0500 |
commit | 65ea5b0349903585bfed9720fa06f5edb4f1cd25 (patch) | |
tree | 6c252228c34416b7e2077f23475de34500c2ab8a /arch/x86/kernel/signal_64.c | |
parent | 53756d3722172815f52272b28c6d5d5e9639adde (diff) |
x86: rename the struct pt_regs members for 32/64-bit consistency
We have a lot of code which differs only by the naming of specific
members of structures that contain registers. In order to enable
additional unifications, this patch drops the e- or r- size prefix
from the register names in struct pt_regs, and drops the x- prefixes
for segment registers on the 32-bit side.
This patch also performs the equivalent renames in some additional
places that might be candidates for unification in the future.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/signal_64.c')
-rw-r--r-- | arch/x86/kernel/signal_64.c | 115 |
1 files changed, 58 insertions, 57 deletions
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c index ab0178ebe00..4b228fd83b3 100644 --- a/arch/x86/kernel/signal_64.c +++ b/arch/x86/kernel/signal_64.c | |||
@@ -39,7 +39,7 @@ asmlinkage long | |||
39 | sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, | 39 | sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, |
40 | struct pt_regs *regs) | 40 | struct pt_regs *regs) |
41 | { | 41 | { |
42 | return do_sigaltstack(uss, uoss, regs->rsp); | 42 | return do_sigaltstack(uss, uoss, regs->sp); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
@@ -62,10 +62,11 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, unsigned | |||
62 | /* Always make any pending restarted system calls return -EINTR */ | 62 | /* Always make any pending restarted system calls return -EINTR */ |
63 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 63 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
64 | 64 | ||
65 | #define COPYR(x) err |= __get_user(regs->x, &sc->r ## x) | ||
65 | #define COPY(x) err |= __get_user(regs->x, &sc->x) | 66 | #define COPY(x) err |= __get_user(regs->x, &sc->x) |
66 | 67 | ||
67 | COPY(rdi); COPY(rsi); COPY(rbp); COPY(rsp); COPY(rbx); | 68 | COPYR(di); COPYR(si); COPYR(bp); COPYR(sp); COPYR(bx); |
68 | COPY(rdx); COPY(rcx); COPY(rip); | 69 | COPYR(dx); COPYR(cx); COPYR(ip); |
69 | COPY(r8); | 70 | COPY(r8); |
70 | COPY(r9); | 71 | COPY(r9); |
71 | COPY(r10); | 72 | COPY(r10); |
@@ -87,8 +88,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, unsigned | |||
87 | { | 88 | { |
88 | unsigned int tmpflags; | 89 | unsigned int tmpflags; |
89 | err |= __get_user(tmpflags, &sc->eflags); | 90 | err |= __get_user(tmpflags, &sc->eflags); |
90 | regs->eflags = (regs->eflags & ~0x40DD5) | (tmpflags & 0x40DD5); | 91 | regs->flags = (regs->flags & ~0x40DD5) | (tmpflags & 0x40DD5); |
91 | regs->orig_rax = -1; /* disable syscall checks */ | 92 | regs->orig_ax = -1; /* disable syscall checks */ |
92 | } | 93 | } |
93 | 94 | ||
94 | { | 95 | { |
@@ -119,9 +120,9 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) | |||
119 | { | 120 | { |
120 | struct rt_sigframe __user *frame; | 121 | struct rt_sigframe __user *frame; |
121 | sigset_t set; | 122 | sigset_t set; |
122 | unsigned long eax; | 123 | unsigned long ax; |
123 | 124 | ||
124 | frame = (struct rt_sigframe __user *)(regs->rsp - 8); | 125 | frame = (struct rt_sigframe __user *)(regs->sp - 8); |
125 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) { | 126 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) { |
126 | goto badframe; | 127 | goto badframe; |
127 | } | 128 | } |
@@ -135,17 +136,17 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) | |||
135 | recalc_sigpending(); | 136 | recalc_sigpending(); |
136 | spin_unlock_irq(¤t->sighand->siglock); | 137 | spin_unlock_irq(¤t->sighand->siglock); |
137 | 138 | ||
138 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &eax)) | 139 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax)) |
139 | goto badframe; | 140 | goto badframe; |
140 | 141 | ||
141 | #ifdef DEBUG_SIG | 142 | #ifdef DEBUG_SIG |
142 | printk("%d sigreturn rip:%lx rsp:%lx frame:%p rax:%lx\n",current->pid,regs->rip,regs->rsp,frame,eax); | 143 | printk("%d sigreturn ip:%lx sp:%lx frame:%p ax:%lx\n",current->pid,regs->ip,regs->sp,frame,ax); |
143 | #endif | 144 | #endif |
144 | 145 | ||
145 | if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->rsp) == -EFAULT) | 146 | if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT) |
146 | goto badframe; | 147 | goto badframe; |
147 | 148 | ||
148 | return eax; | 149 | return ax; |
149 | 150 | ||
150 | badframe: | 151 | badframe: |
151 | signal_fault(regs,frame,"sigreturn"); | 152 | signal_fault(regs,frame,"sigreturn"); |
@@ -165,14 +166,14 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned lo | |||
165 | err |= __put_user(0, &sc->gs); | 166 | err |= __put_user(0, &sc->gs); |
166 | err |= __put_user(0, &sc->fs); | 167 | err |= __put_user(0, &sc->fs); |
167 | 168 | ||
168 | err |= __put_user(regs->rdi, &sc->rdi); | 169 | err |= __put_user(regs->di, &sc->rdi); |
169 | err |= __put_user(regs->rsi, &sc->rsi); | 170 | err |= __put_user(regs->si, &sc->rsi); |
170 | err |= __put_user(regs->rbp, &sc->rbp); | 171 | err |= __put_user(regs->bp, &sc->rbp); |
171 | err |= __put_user(regs->rsp, &sc->rsp); | 172 | err |= __put_user(regs->sp, &sc->rsp); |
172 | err |= __put_user(regs->rbx, &sc->rbx); | 173 | err |= __put_user(regs->bx, &sc->rbx); |
173 | err |= __put_user(regs->rdx, &sc->rdx); | 174 | err |= __put_user(regs->dx, &sc->rdx); |
174 | err |= __put_user(regs->rcx, &sc->rcx); | 175 | err |= __put_user(regs->cx, &sc->rcx); |
175 | err |= __put_user(regs->rax, &sc->rax); | 176 | err |= __put_user(regs->ax, &sc->rax); |
176 | err |= __put_user(regs->r8, &sc->r8); | 177 | err |= __put_user(regs->r8, &sc->r8); |
177 | err |= __put_user(regs->r9, &sc->r9); | 178 | err |= __put_user(regs->r9, &sc->r9); |
178 | err |= __put_user(regs->r10, &sc->r10); | 179 | err |= __put_user(regs->r10, &sc->r10); |
@@ -183,8 +184,8 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned lo | |||
183 | err |= __put_user(regs->r15, &sc->r15); | 184 | err |= __put_user(regs->r15, &sc->r15); |
184 | err |= __put_user(me->thread.trap_no, &sc->trapno); | 185 | err |= __put_user(me->thread.trap_no, &sc->trapno); |
185 | err |= __put_user(me->thread.error_code, &sc->err); | 186 | err |= __put_user(me->thread.error_code, &sc->err); |
186 | err |= __put_user(regs->rip, &sc->rip); | 187 | err |= __put_user(regs->ip, &sc->rip); |
187 | err |= __put_user(regs->eflags, &sc->eflags); | 188 | err |= __put_user(regs->flags, &sc->eflags); |
188 | err |= __put_user(mask, &sc->oldmask); | 189 | err |= __put_user(mask, &sc->oldmask); |
189 | err |= __put_user(me->thread.cr2, &sc->cr2); | 190 | err |= __put_user(me->thread.cr2, &sc->cr2); |
190 | 191 | ||
@@ -198,18 +199,18 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned lo | |||
198 | static void __user * | 199 | static void __user * |
199 | get_stack(struct k_sigaction *ka, struct pt_regs *regs, unsigned long size) | 200 | get_stack(struct k_sigaction *ka, struct pt_regs *regs, unsigned long size) |
200 | { | 201 | { |
201 | unsigned long rsp; | 202 | unsigned long sp; |
202 | 203 | ||
203 | /* Default to using normal stack - redzone*/ | 204 | /* Default to using normal stack - redzone*/ |
204 | rsp = regs->rsp - 128; | 205 | sp = regs->sp - 128; |
205 | 206 | ||
206 | /* This is the X/Open sanctioned signal stack switching. */ | 207 | /* This is the X/Open sanctioned signal stack switching. */ |
207 | if (ka->sa.sa_flags & SA_ONSTACK) { | 208 | if (ka->sa.sa_flags & SA_ONSTACK) { |
208 | if (sas_ss_flags(rsp) == 0) | 209 | if (sas_ss_flags(sp) == 0) |
209 | rsp = current->sas_ss_sp + current->sas_ss_size; | 210 | sp = current->sas_ss_sp + current->sas_ss_size; |
210 | } | 211 | } |
211 | 212 | ||
212 | return (void __user *)round_down(rsp - size, 16); | 213 | return (void __user *)round_down(sp - size, 16); |
213 | } | 214 | } |
214 | 215 | ||
215 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 216 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
@@ -246,7 +247,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
246 | err |= __put_user(0, &frame->uc.uc_flags); | 247 | err |= __put_user(0, &frame->uc.uc_flags); |
247 | err |= __put_user(0, &frame->uc.uc_link); | 248 | err |= __put_user(0, &frame->uc.uc_link); |
248 | err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | 249 | err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
249 | err |= __put_user(sas_ss_flags(regs->rsp), | 250 | err |= __put_user(sas_ss_flags(regs->sp), |
250 | &frame->uc.uc_stack.ss_flags); | 251 | &frame->uc.uc_stack.ss_flags); |
251 | err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size); | 252 | err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size); |
252 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0], me); | 253 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0], me); |
@@ -271,21 +272,21 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
271 | goto give_sigsegv; | 272 | goto give_sigsegv; |
272 | 273 | ||
273 | #ifdef DEBUG_SIG | 274 | #ifdef DEBUG_SIG |
274 | printk("%d old rip %lx old rsp %lx old rax %lx\n", current->pid,regs->rip,regs->rsp,regs->rax); | 275 | printk("%d old ip %lx old sp %lx old ax %lx\n", current->pid,regs->ip,regs->sp,regs->ax); |
275 | #endif | 276 | #endif |
276 | 277 | ||
277 | /* Set up registers for signal handler */ | 278 | /* Set up registers for signal handler */ |
278 | regs->rdi = sig; | 279 | regs->di = sig; |
279 | /* In case the signal handler was declared without prototypes */ | 280 | /* In case the signal handler was declared without prototypes */ |
280 | regs->rax = 0; | 281 | regs->ax = 0; |
281 | 282 | ||
282 | /* This also works for non SA_SIGINFO handlers because they expect the | 283 | /* This also works for non SA_SIGINFO handlers because they expect the |
283 | next argument after the signal number on the stack. */ | 284 | next argument after the signal number on the stack. */ |
284 | regs->rsi = (unsigned long)&frame->info; | 285 | regs->si = (unsigned long)&frame->info; |
285 | regs->rdx = (unsigned long)&frame->uc; | 286 | regs->dx = (unsigned long)&frame->uc; |
286 | regs->rip = (unsigned long) ka->sa.sa_handler; | 287 | regs->ip = (unsigned long) ka->sa.sa_handler; |
287 | 288 | ||
288 | regs->rsp = (unsigned long)frame; | 289 | regs->sp = (unsigned long)frame; |
289 | 290 | ||
290 | /* Set up the CS register to run signal handlers in 64-bit mode, | 291 | /* Set up the CS register to run signal handlers in 64-bit mode, |
291 | even if the handler happens to be interrupting 32-bit code. */ | 292 | even if the handler happens to be interrupting 32-bit code. */ |
@@ -295,12 +296,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
295 | see include/asm-x86_64/uaccess.h for details. */ | 296 | see include/asm-x86_64/uaccess.h for details. */ |
296 | set_fs(USER_DS); | 297 | set_fs(USER_DS); |
297 | 298 | ||
298 | regs->eflags &= ~TF_MASK; | 299 | regs->flags &= ~TF_MASK; |
299 | if (test_thread_flag(TIF_SINGLESTEP)) | 300 | if (test_thread_flag(TIF_SINGLESTEP)) |
300 | ptrace_notify(SIGTRAP); | 301 | ptrace_notify(SIGTRAP); |
301 | #ifdef DEBUG_SIG | 302 | #ifdef DEBUG_SIG |
302 | printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%p\n", | 303 | printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%p\n", |
303 | current->comm, current->pid, frame, regs->rip, frame->pretcode); | 304 | current->comm, current->pid, frame, regs->ip, frame->pretcode); |
304 | #endif | 305 | #endif |
305 | 306 | ||
306 | return 0; | 307 | return 0; |
@@ -321,29 +322,29 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
321 | int ret; | 322 | int ret; |
322 | 323 | ||
323 | #ifdef DEBUG_SIG | 324 | #ifdef DEBUG_SIG |
324 | printk("handle_signal pid:%d sig:%lu rip:%lx rsp:%lx regs=%p\n", | 325 | printk("handle_signal pid:%d sig:%lu ip:%lx sp:%lx regs=%p\n", |
325 | current->pid, sig, | 326 | current->pid, sig, |
326 | regs->rip, regs->rsp, regs); | 327 | regs->ip, regs->sp, regs); |
327 | #endif | 328 | #endif |
328 | 329 | ||
329 | /* Are we from a system call? */ | 330 | /* Are we from a system call? */ |
330 | if ((long)regs->orig_rax >= 0) { | 331 | if ((long)regs->orig_ax >= 0) { |
331 | /* If so, check system call restarting.. */ | 332 | /* If so, check system call restarting.. */ |
332 | switch (regs->rax) { | 333 | switch (regs->ax) { |
333 | case -ERESTART_RESTARTBLOCK: | 334 | case -ERESTART_RESTARTBLOCK: |
334 | case -ERESTARTNOHAND: | 335 | case -ERESTARTNOHAND: |
335 | regs->rax = -EINTR; | 336 | regs->ax = -EINTR; |
336 | break; | 337 | break; |
337 | 338 | ||
338 | case -ERESTARTSYS: | 339 | case -ERESTARTSYS: |
339 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 340 | if (!(ka->sa.sa_flags & SA_RESTART)) { |
340 | regs->rax = -EINTR; | 341 | regs->ax = -EINTR; |
341 | break; | 342 | break; |
342 | } | 343 | } |
343 | /* fallthrough */ | 344 | /* fallthrough */ |
344 | case -ERESTARTNOINTR: | 345 | case -ERESTARTNOINTR: |
345 | regs->rax = regs->orig_rax; | 346 | regs->ax = regs->orig_ax; |
346 | regs->rip -= 2; | 347 | regs->ip -= 2; |
347 | break; | 348 | break; |
348 | } | 349 | } |
349 | } | 350 | } |
@@ -352,9 +353,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
352 | * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF | 353 | * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF |
353 | * flag so that register information in the sigcontext is correct. | 354 | * flag so that register information in the sigcontext is correct. |
354 | */ | 355 | */ |
355 | if (unlikely(regs->eflags & X86_EFLAGS_TF) && | 356 | if (unlikely(regs->flags & X86_EFLAGS_TF) && |
356 | likely(test_and_clear_thread_flag(TIF_FORCED_TF))) | 357 | likely(test_and_clear_thread_flag(TIF_FORCED_TF))) |
357 | regs->eflags &= ~X86_EFLAGS_TF; | 358 | regs->flags &= ~X86_EFLAGS_TF; |
358 | 359 | ||
359 | #ifdef CONFIG_IA32_EMULATION | 360 | #ifdef CONFIG_IA32_EMULATION |
360 | if (test_thread_flag(TIF_IA32)) { | 361 | if (test_thread_flag(TIF_IA32)) { |
@@ -426,21 +427,21 @@ static void do_signal(struct pt_regs *regs) | |||
426 | } | 427 | } |
427 | 428 | ||
428 | /* Did we come from a system call? */ | 429 | /* Did we come from a system call? */ |
429 | if ((long)regs->orig_rax >= 0) { | 430 | if ((long)regs->orig_ax >= 0) { |
430 | /* Restart the system call - no handlers present */ | 431 | /* Restart the system call - no handlers present */ |
431 | long res = regs->rax; | 432 | long res = regs->ax; |
432 | switch (res) { | 433 | switch (res) { |
433 | case -ERESTARTNOHAND: | 434 | case -ERESTARTNOHAND: |
434 | case -ERESTARTSYS: | 435 | case -ERESTARTSYS: |
435 | case -ERESTARTNOINTR: | 436 | case -ERESTARTNOINTR: |
436 | regs->rax = regs->orig_rax; | 437 | regs->ax = regs->orig_ax; |
437 | regs->rip -= 2; | 438 | regs->ip -= 2; |
438 | break; | 439 | break; |
439 | case -ERESTART_RESTARTBLOCK: | 440 | case -ERESTART_RESTARTBLOCK: |
440 | regs->rax = test_thread_flag(TIF_IA32) ? | 441 | regs->ax = test_thread_flag(TIF_IA32) ? |
441 | __NR_ia32_restart_syscall : | 442 | __NR_ia32_restart_syscall : |
442 | __NR_restart_syscall; | 443 | __NR_restart_syscall; |
443 | regs->rip -= 2; | 444 | regs->ip -= 2; |
444 | break; | 445 | break; |
445 | } | 446 | } |
446 | } | 447 | } |
@@ -457,13 +458,13 @@ void | |||
457 | do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) | 458 | do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) |
458 | { | 459 | { |
459 | #ifdef DEBUG_SIG | 460 | #ifdef DEBUG_SIG |
460 | printk("do_notify_resume flags:%x rip:%lx rsp:%lx caller:%p pending:%x\n", | 461 | printk("do_notify_resume flags:%x ip:%lx sp:%lx caller:%p pending:%x\n", |
461 | thread_info_flags, regs->rip, regs->rsp, __builtin_return_address(0),signal_pending(current)); | 462 | thread_info_flags, regs->ip, regs->sp, __builtin_return_address(0),signal_pending(current)); |
462 | #endif | 463 | #endif |
463 | 464 | ||
464 | /* Pending single-step? */ | 465 | /* Pending single-step? */ |
465 | if (thread_info_flags & _TIF_SINGLESTEP) { | 466 | if (thread_info_flags & _TIF_SINGLESTEP) { |
466 | regs->eflags |= TF_MASK; | 467 | regs->flags |= TF_MASK; |
467 | clear_thread_flag(TIF_SINGLESTEP); | 468 | clear_thread_flag(TIF_SINGLESTEP); |
468 | } | 469 | } |
469 | 470 | ||
@@ -485,8 +486,8 @@ void signal_fault(struct pt_regs *regs, void __user *frame, char *where) | |||
485 | { | 486 | { |
486 | struct task_struct *me = current; | 487 | struct task_struct *me = current; |
487 | if (show_unhandled_signals && printk_ratelimit()) | 488 | if (show_unhandled_signals && printk_ratelimit()) |
488 | printk("%s[%d] bad frame in %s frame:%p rip:%lx rsp:%lx orax:%lx\n", | 489 | printk("%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx\n", |
489 | me->comm,me->pid,where,frame,regs->rip,regs->rsp,regs->orig_rax); | 490 | me->comm,me->pid,where,frame,regs->ip,regs->sp,regs->orig_ax); |
490 | 491 | ||
491 | force_sig(SIGSEGV, me); | 492 | force_sig(SIGSEGV, me); |
492 | } | 493 | } |