diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-01-30 07:33:16 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:16 -0500 |
commit | 90d43d728d22a5e20c63c8db1cfb497210768f19 (patch) | |
tree | 72f5ba536cc5791ff3ec2ed6473e5ab8a8bb59a5 /include/asm-x86/ptrace.h | |
parent | 064954761254ef17fae2b84fb5a034d48a769143 (diff) |
x86: unify pt_regs accessors ptrace.h
Unify the definiton of:
v8086_mode
user_mode
user_mode_vm
stack_pointer
instruction_pointer
frame_pointer
in ptrace.h to make it clear where the differences are between
32 and 64 bit. Changes macros to static inlines as well.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86/ptrace.h')
-rw-r--r-- | include/asm-x86/ptrace.h | 84 |
1 files changed, 54 insertions, 30 deletions
diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h index ee4b595e1ccc..0ad9a2b7f8c0 100644 --- a/include/asm-x86/ptrace.h +++ b/include/asm-x86/ptrace.h | |||
@@ -76,30 +76,6 @@ convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs); | |||
76 | 76 | ||
77 | extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); | 77 | extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); |
78 | 78 | ||
79 | /* | ||
80 | * user_mode_vm(regs) determines whether a register set came from user mode. | ||
81 | * This is true if V8086 mode was enabled OR if the register set was from | ||
82 | * protected mode with RPL-3 CS value. This tricky test checks that with | ||
83 | * one comparison. Many places in the kernel can bypass this full check | ||
84 | * if they have already ruled out V8086 mode, so user_mode(regs) can be used. | ||
85 | */ | ||
86 | static inline int user_mode(struct pt_regs *regs) | ||
87 | { | ||
88 | return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL; | ||
89 | } | ||
90 | static inline int user_mode_vm(struct pt_regs *regs) | ||
91 | { | ||
92 | return ((regs->cs & SEGMENT_RPL_MASK) | | ||
93 | (regs->flags & VM_MASK)) >= USER_RPL; | ||
94 | } | ||
95 | static inline int v8086_mode(struct pt_regs *regs) | ||
96 | { | ||
97 | return (regs->flags & VM_MASK); | ||
98 | } | ||
99 | |||
100 | #define instruction_pointer(regs) ((regs)->ip) | ||
101 | #define frame_pointer(regs) ((regs)->bp) | ||
102 | #define stack_pointer(regs) ((unsigned long)(regs)) | ||
103 | #define regs_return_value(regs) ((regs)->ax) | 79 | #define regs_return_value(regs) ((regs)->ax) |
104 | 80 | ||
105 | extern unsigned long profile_pc(struct pt_regs *regs); | 81 | extern unsigned long profile_pc(struct pt_regs *regs); |
@@ -167,12 +143,6 @@ struct pt_regs { | |||
167 | /* top of stack page */ | 143 | /* top of stack page */ |
168 | }; | 144 | }; |
169 | 145 | ||
170 | #define user_mode(regs) (!!((regs)->cs & 3)) | ||
171 | #define user_mode_vm(regs) user_mode(regs) | ||
172 | #define v8086_mode(regs) 0 /* No V86 mode support in long mode */ | ||
173 | #define instruction_pointer(regs) ((regs)->ip) | ||
174 | #define frame_pointer(regs) ((regs)->bp) | ||
175 | #define stack_pointer(regs) ((regs)->sp) | ||
176 | #define regs_return_value(regs) ((regs)->ax) | 146 | #define regs_return_value(regs) ((regs)->ax) |
177 | 147 | ||
178 | extern unsigned long profile_pc(struct pt_regs *regs); | 148 | extern unsigned long profile_pc(struct pt_regs *regs); |
@@ -189,6 +159,60 @@ convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs); | |||
189 | #ifdef __KERNEL__ | 159 | #ifdef __KERNEL__ |
190 | 160 | ||
191 | /* | 161 | /* |
162 | * user_mode_vm(regs) determines whether a register set came from user mode. | ||
163 | * This is true if V8086 mode was enabled OR if the register set was from | ||
164 | * protected mode with RPL-3 CS value. This tricky test checks that with | ||
165 | * one comparison. Many places in the kernel can bypass this full check | ||
166 | * if they have already ruled out V8086 mode, so user_mode(regs) can be used. | ||
167 | */ | ||
168 | static inline int user_mode(struct pt_regs *regs) | ||
169 | { | ||
170 | #ifdef CONFIG_X86_32 | ||
171 | return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL; | ||
172 | #else | ||
173 | return !!(regs->cs & 3); | ||
174 | #endif | ||
175 | } | ||
176 | |||
177 | static inline int user_mode_vm(struct pt_regs *regs) | ||
178 | { | ||
179 | #ifdef CONFIG_X86_32 | ||
180 | return ((regs->cs & SEGMENT_RPL_MASK) | | ||
181 | (regs->flags & VM_MASK)) >= USER_RPL; | ||
182 | #else | ||
183 | return user_mode(regs); | ||
184 | #endif | ||
185 | } | ||
186 | |||
187 | static inline int v8086_mode(struct pt_regs *regs) | ||
188 | { | ||
189 | #ifdef CONFIG_X86_32 | ||
190 | return (regs->flags & VM_MASK); | ||
191 | #else | ||
192 | return 0; /* No V86 mode support in long mode */ | ||
193 | #endif | ||
194 | } | ||
195 | |||
196 | static inline unsigned long stack_pointer(struct pt_regs *regs) | ||
197 | { | ||
198 | #ifdef CONFIG_X86_32 | ||
199 | return (unsigned long)regs; | ||
200 | #else | ||
201 | return regs->sp; | ||
202 | #endif | ||
203 | } | ||
204 | |||
205 | static inline unsigned long instruction_pointer(struct pt_regs *regs) | ||
206 | { | ||
207 | return regs->ip; | ||
208 | } | ||
209 | |||
210 | static inline unsigned long frame_pointer(struct pt_regs *regs) | ||
211 | { | ||
212 | return regs->bp; | ||
213 | } | ||
214 | |||
215 | /* | ||
192 | * These are defined as per linux/ptrace.h, which see. | 216 | * These are defined as per linux/ptrace.h, which see. |
193 | */ | 217 | */ |
194 | #define arch_has_single_step() (1) | 218 | #define arch_has_single_step() (1) |