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 | 153d5f2e5787c74e9cbb6b6687c9b04be1b59893 (patch) | |
tree | cacde0a0ce46bb797a6b4b8e6817ceef996ebc5e | |
parent | 65ea5b0349903585bfed9720fa06f5edb4f1cd25 (diff) |
x86: use generic register names in struct user_regs_struct
Switch struct user_regs_struct (defined in <asm/user.h>, which is no
longer exported to userspace) to using register names without e- or
r-prefixes for both 32 and 64 bit x86. This is intended as a
preliminary step in unifying this code between architectures.
Also, be a bit more strict in truncating 32-bit "extended" segment
register values to 16 bits.
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>
-rw-r--r-- | arch/x86/kernel/process_32.c | 35 | ||||
-rw-r--r-- | arch/x86/kernel/ptrace_64.c | 4 | ||||
-rw-r--r-- | include/asm-x86/user_32.h | 24 | ||||
-rw-r--r-- | include/asm-x86/user_64.h | 41 |
4 files changed, 68 insertions, 36 deletions
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index c9f28e02e86d..53406461074f 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c | |||
@@ -523,6 +523,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, | |||
523 | void dump_thread(struct pt_regs * regs, struct user * dump) | 523 | void dump_thread(struct pt_regs * regs, struct user * dump) |
524 | { | 524 | { |
525 | int i; | 525 | int i; |
526 | u16 gs; | ||
526 | 527 | ||
527 | /* changed the size calculations - should hopefully work better. lbt */ | 528 | /* changed the size calculations - should hopefully work better. lbt */ |
528 | dump->magic = CMAGIC; | 529 | dump->magic = CMAGIC; |
@@ -538,23 +539,23 @@ void dump_thread(struct pt_regs * regs, struct user * dump) | |||
538 | if (dump->start_stack < TASK_SIZE) | 539 | if (dump->start_stack < TASK_SIZE) |
539 | dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; | 540 | dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; |
540 | 541 | ||
541 | dump->regs.ebx = regs->bx; | 542 | dump->regs.bx = regs->bx; |
542 | dump->regs.ecx = regs->cx; | 543 | dump->regs.cx = regs->cx; |
543 | dump->regs.edx = regs->dx; | 544 | dump->regs.dx = regs->dx; |
544 | dump->regs.esi = regs->si; | 545 | dump->regs.si = regs->si; |
545 | dump->regs.edi = regs->di; | 546 | dump->regs.di = regs->di; |
546 | dump->regs.ebp = regs->bp; | 547 | dump->regs.bp = regs->bp; |
547 | dump->regs.eax = regs->ax; | 548 | dump->regs.ax = regs->ax; |
548 | dump->regs.ds = regs->ds; | 549 | dump->regs.ds = (u16)regs->ds; |
549 | dump->regs.es = regs->es; | 550 | dump->regs.es = (u16)regs->es; |
550 | dump->regs.fs = regs->fs; | 551 | dump->regs.fs = (u16)regs->fs; |
551 | savesegment(gs,dump->regs.gs); | 552 | savesegment(gs,gs); |
552 | dump->regs.orig_eax = regs->orig_ax; | 553 | dump->regs.orig_ax = regs->orig_ax; |
553 | dump->regs.eip = regs->ip; | 554 | dump->regs.ip = regs->ip; |
554 | dump->regs.cs = regs->cs; | 555 | dump->regs.cs = (u16)regs->cs; |
555 | dump->regs.eflags = regs->flags; | 556 | dump->regs.flags = regs->flags; |
556 | dump->regs.esp = regs->sp; | 557 | dump->regs.sp = regs->sp; |
557 | dump->regs.ss = regs->ss; | 558 | dump->regs.ss = (u16)regs->ss; |
558 | 559 | ||
559 | dump->u_fpvalid = dump_fpu (regs, &dump->i387); | 560 | dump->u_fpvalid = dump_fpu (regs, &dump->i387); |
560 | } | 561 | } |
diff --git a/arch/x86/kernel/ptrace_64.c b/arch/x86/kernel/ptrace_64.c index bee20bb1a6c0..56b31cd3b865 100644 --- a/arch/x86/kernel/ptrace_64.c +++ b/arch/x86/kernel/ptrace_64.c | |||
@@ -108,7 +108,7 @@ static int putreg(struct task_struct *child, | |||
108 | if (child->thread.gs != value) | 108 | if (child->thread.gs != value) |
109 | return do_arch_prctl(child, ARCH_SET_GS, value); | 109 | return do_arch_prctl(child, ARCH_SET_GS, value); |
110 | return 0; | 110 | return 0; |
111 | case offsetof(struct user_regs_struct, eflags): | 111 | case offsetof(struct user_regs_struct,flags): |
112 | value &= FLAG_MASK; | 112 | value &= FLAG_MASK; |
113 | /* | 113 | /* |
114 | * If the user value contains TF, mark that | 114 | * If the user value contains TF, mark that |
@@ -164,7 +164,7 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) | |||
164 | if (child->thread.gsindex != GS_TLS_SEL) | 164 | if (child->thread.gsindex != GS_TLS_SEL) |
165 | return 0; | 165 | return 0; |
166 | return get_desc_base(&child->thread.tls_array[GS_TLS]); | 166 | return get_desc_base(&child->thread.tls_array[GS_TLS]); |
167 | case offsetof(struct user_regs_struct, eflags): | 167 | case offsetof(struct user_regs_struct, flags): |
168 | /* | 168 | /* |
169 | * If the debugger set TF, hide it from the readout. | 169 | * If the debugger set TF, hide it from the readout. |
170 | */ | 170 | */ |
diff --git a/include/asm-x86/user_32.h b/include/asm-x86/user_32.h index 0e85d2a5e33a..ed8b8fc6906c 100644 --- a/include/asm-x86/user_32.h +++ b/include/asm-x86/user_32.h | |||
@@ -75,13 +75,23 @@ struct user_fxsr_struct { | |||
75 | * doesn't use the extra segment registers) | 75 | * doesn't use the extra segment registers) |
76 | */ | 76 | */ |
77 | struct user_regs_struct { | 77 | struct user_regs_struct { |
78 | long ebx, ecx, edx, esi, edi, ebp, eax; | 78 | unsigned long bx; |
79 | unsigned short ds, __ds, es, __es; | 79 | unsigned long cx; |
80 | unsigned short fs, __fs, gs, __gs; | 80 | unsigned long dx; |
81 | long orig_eax, eip; | 81 | unsigned long si; |
82 | unsigned short cs, __cs; | 82 | unsigned long di; |
83 | long eflags, esp; | 83 | unsigned long bp; |
84 | unsigned short ss, __ss; | 84 | unsigned long ax; |
85 | unsigned long ds; | ||
86 | unsigned long es; | ||
87 | unsigned long fs; | ||
88 | unsigned long gs; | ||
89 | unsigned long orig_ax; | ||
90 | unsigned long ip; | ||
91 | unsigned long cs; | ||
92 | unsigned long flags; | ||
93 | unsigned long sp; | ||
94 | unsigned long ss; | ||
85 | }; | 95 | }; |
86 | 96 | ||
87 | /* When the kernel dumps core, it starts by dumping the user struct - | 97 | /* When the kernel dumps core, it starts by dumping the user struct - |
diff --git a/include/asm-x86/user_64.h b/include/asm-x86/user_64.h index 12785c649ac5..a5449d456cc0 100644 --- a/include/asm-x86/user_64.h +++ b/include/asm-x86/user_64.h | |||
@@ -40,13 +40,13 @@ | |||
40 | * and both the standard and SIMD floating point data can be accessed via | 40 | * and both the standard and SIMD floating point data can be accessed via |
41 | * the new ptrace requests. In either case, changes to the FPU environment | 41 | * the new ptrace requests. In either case, changes to the FPU environment |
42 | * will be reflected in the task's state as expected. | 42 | * will be reflected in the task's state as expected. |
43 | * | 43 | * |
44 | * x86-64 support by Andi Kleen. | 44 | * x86-64 support by Andi Kleen. |
45 | */ | 45 | */ |
46 | 46 | ||
47 | /* This matches the 64bit FXSAVE format as defined by AMD. It is the same | 47 | /* This matches the 64bit FXSAVE format as defined by AMD. It is the same |
48 | as the 32bit format defined by Intel, except that the selector:offset pairs for | 48 | as the 32bit format defined by Intel, except that the selector:offset pairs for |
49 | data and eip are replaced with flat 64bit pointers. */ | 49 | data and eip are replaced with flat 64bit pointers. */ |
50 | struct user_i387_struct { | 50 | struct user_i387_struct { |
51 | unsigned short cwd; | 51 | unsigned short cwd; |
52 | unsigned short swd; | 52 | unsigned short swd; |
@@ -65,13 +65,34 @@ struct user_i387_struct { | |||
65 | * Segment register layout in coredumps. | 65 | * Segment register layout in coredumps. |
66 | */ | 66 | */ |
67 | struct user_regs_struct { | 67 | struct user_regs_struct { |
68 | unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10; | 68 | unsigned long r15; |
69 | unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax; | 69 | unsigned long r14; |
70 | unsigned long rip,cs,eflags; | 70 | unsigned long r13; |
71 | unsigned long rsp,ss; | 71 | unsigned long r12; |
72 | unsigned long fs_base, gs_base; | 72 | unsigned long bp; |
73 | unsigned long ds,es,fs,gs; | 73 | unsigned long bx; |
74 | }; | 74 | unsigned long r11; |
75 | unsigned long r10; | ||
76 | unsigned long r9; | ||
77 | unsigned long r8; | ||
78 | unsigned long ax; | ||
79 | unsigned long cx; | ||
80 | unsigned long dx; | ||
81 | unsigned long si; | ||
82 | unsigned long di; | ||
83 | unsigned long orig_ax; | ||
84 | unsigned long ip; | ||
85 | unsigned long cs; | ||
86 | unsigned long flags; | ||
87 | unsigned long sp; | ||
88 | unsigned long ss; | ||
89 | unsigned long fs_base; | ||
90 | unsigned long gs_base; | ||
91 | unsigned long ds; | ||
92 | unsigned long es; | ||
93 | unsigned long fs; | ||
94 | unsigned long gs; | ||
95 | }; | ||
75 | 96 | ||
76 | /* When the kernel dumps core, it starts by dumping the user struct - | 97 | /* When the kernel dumps core, it starts by dumping the user struct - |
77 | this will be used by gdb to figure out where the data and stack segments | 98 | this will be used by gdb to figure out where the data and stack segments |
@@ -94,7 +115,7 @@ struct user{ | |||
94 | This is actually the bottom of the stack, | 115 | This is actually the bottom of the stack, |
95 | the top of the stack is always found in the | 116 | the top of the stack is always found in the |
96 | esp register. */ | 117 | esp register. */ |
97 | long int signal; /* Signal that caused the core dump. */ | 118 | long int signal; /* Signal that caused the core dump. */ |
98 | int reserved; /* No longer used */ | 119 | int reserved; /* No longer used */ |
99 | int pad1; | 120 | int pad1; |
100 | struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */ | 121 | struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */ |