Make use of the user_mode macro where it's possible. This is useful for Xen
because it will need only to redefine only the macro to a hypervisor call.
Signed-off-by: Vincent Hanquez <vincent.hanquez@cl.cam.ac.uk>
Cc: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* kernel mode. Just return without doing anything
* if so.
*/
* kernel mode. Just return without doing anything
* if so.
*/
- if ((regs->cs & 3) != 3)
return 1;
if (try_to_freeze(0))
return 1;
if (try_to_freeze(0))
void show_registers(struct pt_regs *regs)
{
int i;
void show_registers(struct pt_regs *regs)
{
int i;
- int in_kernel = (regs->cs & 3) == 0;
+ int in_kernel = !user_mode(regs);
unsigned long rsp;
const int cpu = safe_smp_processor_id();
struct task_struct *cur = cpu_pda[cpu].pcurrent;
unsigned long rsp;
const int cpu = safe_smp_processor_id();
struct task_struct *cur = cpu_pda[cpu].pcurrent;
struct bug_frame f;
char tmp;
struct bug_frame f;
char tmp;
return;
if (__copy_from_user(&f, (struct bug_frame *) regs->rip,
sizeof(struct bug_frame)))
return;
if (__copy_from_user(&f, (struct bug_frame *) regs->rip,
sizeof(struct bug_frame)))
- if ((regs->cs & 3) != 0) {
struct task_struct *tsk = current;
if (exception_trace && unhandled_signal(tsk, signr))
struct task_struct *tsk = current;
if (exception_trace && unhandled_signal(tsk, signr))
- if ((regs->cs & 3)!=0) {
struct task_struct *tsk = current;
if (exception_trace && unhandled_signal(tsk, SIGSEGV))
struct task_struct *tsk = current;
if (exception_trace && unhandled_signal(tsk, SIGSEGV))
if (eregs == (struct pt_regs *)eregs->rsp)
;
/* Exception from user space */
if (eregs == (struct pt_regs *)eregs->rsp)
;
/* Exception from user space */
- else if (eregs->cs & 3)
+ else if (user_mode(eregs))
regs = ((struct pt_regs *)current->thread.rsp0) - 1;
/* Exception from kernel and interrupts are enabled. Move to
kernel process stack. */
regs = ((struct pt_regs *)current->thread.rsp0) - 1;
/* Exception from kernel and interrupts are enabled. Move to
kernel process stack. */
* allowing programs to debug themselves without the ptrace()
* interface.
*/
* allowing programs to debug themselves without the ptrace()
* interface.
*/
- if ((regs->cs & 3) == 0)
goto clear_TF_reenable;
/*
* Was the TF flag set by a debugger? If so, clear it now,
goto clear_TF_reenable;
/*
* Was the TF flag set by a debugger? If so, clear it now,
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_BRKPT;
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_BRKPT;
- if ((regs->cs & 3) == 0)
goto clear_dr7;
info.si_addr = (void __user *)regs->rip;
goto clear_dr7;
info.si_addr = (void __user *)regs->rip;
unsigned short cwd, swd;
conditional_sti(regs);
unsigned short cwd, swd;
conditional_sti(regs);
- if ((regs->cs & 3) == 0 &&
+ if (!user_mode(regs) &&
kernel_math_error(regs, "kernel x87 math error"))
return;
kernel_math_error(regs, "kernel x87 math error"))
return;
unsigned short mxcsr;
conditional_sti(regs);
unsigned short mxcsr;
conditional_sti(regs);
- if ((regs->cs & 3) == 0 &&
+ if (!user_mode(regs) &&
kernel_math_error(regs, "kernel simd math error"))
return;
kernel_math_error(regs, "kernel simd math error"))
return;
instr = (unsigned char *)convert_rip_to_linear(current, regs);
max_instr = instr + 15;
instr = (unsigned char *)convert_rip_to_linear(current, regs);
max_instr = instr + 15;
- if ((regs->cs & 3) != 0 && instr >= (unsigned char *)TASK_SIZE)
+ if (user_mode(regs) && instr >= (unsigned char *)TASK_SIZE)
return 0;
while (scan_more && instr < max_instr) {
return 0;
while (scan_more && instr < max_instr) {
/* Could check the LDT for lm, but for now it's good
enough to assume that long mode only uses well known
segments or kernel. */
/* Could check the LDT for lm, but for now it's good
enough to assume that long mode only uses well known
segments or kernel. */
- scan_more = ((regs->cs & 3) == 0) || (regs->cs == __USER_CS);
+ scan_more = (!user_mode(regs)) || (regs->cs == __USER_CS);