Commit 7d256175 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

s390: make use of user_mode() macro where possible

We use the user_mode() helper already at several places but also
have the open coded variant at other places.
Convert the code to always use the helper function.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 37fe1d73
...@@ -1531,7 +1531,7 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr) ...@@ -1531,7 +1531,7 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr)
void show_code(struct pt_regs *regs) void show_code(struct pt_regs *regs)
{ {
char *mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl"; char *mode = user_mode(regs) ? "User" : "Krnl";
unsigned char code[64]; unsigned char code[64];
char buffer[64], *ptr; char buffer[64], *ptr;
mm_segment_t old_fs; mm_segment_t old_fs;
...@@ -1540,7 +1540,7 @@ void show_code(struct pt_regs *regs) ...@@ -1540,7 +1540,7 @@ void show_code(struct pt_regs *regs)
/* Get a snapshot of the 64 bytes surrounding the fault address. */ /* Get a snapshot of the 64 bytes surrounding the fault address. */
old_fs = get_fs(); old_fs = get_fs();
set_fs((regs->psw.mask & PSW_MASK_PSTATE) ? USER_DS : KERNEL_DS); set_fs(user_mode(regs) ? USER_DS : KERNEL_DS);
for (start = 32; start && regs->psw.addr >= 34 - start; start -= 2) { for (start = 32; start && regs->psw.addr >= 34 - start; start -= 2) {
addr = regs->psw.addr - 34 + start; addr = regs->psw.addr - 34 + start;
if (__copy_from_user(code + start - 2, if (__copy_from_user(code + start - 2,
......
...@@ -185,7 +185,7 @@ void show_registers(struct pt_regs *regs) ...@@ -185,7 +185,7 @@ void show_registers(struct pt_regs *regs)
{ {
char *mode; char *mode;
mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl"; mode = user_mode(regs) ? "User" : "Krnl";
printk("%s PSW : %p %p", printk("%s PSW : %p %p",
mode, (void *) regs->psw.mask, mode, (void *) regs->psw.mask,
(void *) regs->psw.addr); (void *) regs->psw.addr);
...@@ -225,7 +225,7 @@ void show_regs(struct pt_regs *regs) ...@@ -225,7 +225,7 @@ void show_regs(struct pt_regs *regs)
(void *) current->thread.ksp); (void *) current->thread.ksp);
show_registers(regs); show_registers(regs);
/* Show stack backtrace if pt_regs is from kernel mode */ /* Show stack backtrace if pt_regs is from kernel mode */
if (!(regs->psw.mask & PSW_MASK_PSTATE)) if (!user_mode(regs))
show_trace(NULL, (unsigned long *) regs->gprs[15]); show_trace(NULL, (unsigned long *) regs->gprs[15]);
show_last_breaking_event(regs); show_last_breaking_event(regs);
} }
...@@ -300,7 +300,7 @@ static void __kprobes do_trap(struct pt_regs *regs, ...@@ -300,7 +300,7 @@ static void __kprobes do_trap(struct pt_regs *regs,
regs->int_code, si_signo) == NOTIFY_STOP) regs->int_code, si_signo) == NOTIFY_STOP)
return; return;
if (regs->psw.mask & PSW_MASK_PSTATE) { if (user_mode(regs)) {
info.si_signo = si_signo; info.si_signo = si_signo;
info.si_errno = 0; info.si_errno = 0;
info.si_code = si_code; info.si_code = si_code;
...@@ -341,7 +341,7 @@ void __kprobes do_per_trap(struct pt_regs *regs) ...@@ -341,7 +341,7 @@ void __kprobes do_per_trap(struct pt_regs *regs)
static void default_trap_handler(struct pt_regs *regs) static void default_trap_handler(struct pt_regs *regs)
{ {
if (regs->psw.mask & PSW_MASK_PSTATE) { if (user_mode(regs)) {
report_user_fault(regs, SIGSEGV); report_user_fault(regs, SIGSEGV);
do_exit(SIGSEGV); do_exit(SIGSEGV);
} else } else
...@@ -410,7 +410,7 @@ static void __kprobes illegal_op(struct pt_regs *regs) ...@@ -410,7 +410,7 @@ static void __kprobes illegal_op(struct pt_regs *regs)
location = get_psw_address(regs); location = get_psw_address(regs);
if (regs->psw.mask & PSW_MASK_PSTATE) { if (user_mode(regs)) {
if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
return; return;
if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
...@@ -478,7 +478,7 @@ void specification_exception(struct pt_regs *regs) ...@@ -478,7 +478,7 @@ void specification_exception(struct pt_regs *regs)
location = (__u16 __user *) get_psw_address(regs); location = (__u16 __user *) get_psw_address(regs);
if (regs->psw.mask & PSW_MASK_PSTATE) { if (user_mode(regs)) {
get_user(*((__u16 *) opcode), location); get_user(*((__u16 *) opcode), location);
switch (opcode[0]) { switch (opcode[0]) {
case 0x28: /* LDR Rx,Ry */ case 0x28: /* LDR Rx,Ry */
...@@ -531,7 +531,7 @@ static void data_exception(struct pt_regs *regs) ...@@ -531,7 +531,7 @@ static void data_exception(struct pt_regs *regs)
asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc)); asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc));
#ifdef CONFIG_MATHEMU #ifdef CONFIG_MATHEMU
else if (regs->psw.mask & PSW_MASK_PSTATE) { else if (user_mode(regs)) {
__u8 opcode[6]; __u8 opcode[6];
get_user(*((__u16 *) opcode), location); get_user(*((__u16 *) opcode), location);
switch (opcode[0]) { switch (opcode[0]) {
...@@ -598,7 +598,7 @@ static void data_exception(struct pt_regs *regs) ...@@ -598,7 +598,7 @@ static void data_exception(struct pt_regs *regs)
static void space_switch_exception(struct pt_regs *regs) static void space_switch_exception(struct pt_regs *regs)
{ {
/* Set user psw back to home space mode. */ /* Set user psw back to home space mode. */
if (regs->psw.mask & PSW_MASK_PSTATE) if (user_mode(regs))
regs->psw.mask |= PSW_ASC_HOME; regs->psw.mask |= PSW_ASC_HOME;
/* Send SIGILL. */ /* Send SIGILL. */
do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event");
......
...@@ -220,7 +220,7 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault) ...@@ -220,7 +220,7 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
case VM_FAULT_BADACCESS: case VM_FAULT_BADACCESS:
case VM_FAULT_BADMAP: case VM_FAULT_BADMAP:
/* Bad memory access. Check if it is kernel or user space. */ /* Bad memory access. Check if it is kernel or user space. */
if (regs->psw.mask & PSW_MASK_PSTATE) { if (user_mode(regs)) {
/* User mode accesses just cause a SIGSEGV */ /* User mode accesses just cause a SIGSEGV */
si_code = (fault == VM_FAULT_BADMAP) ? si_code = (fault == VM_FAULT_BADMAP) ?
SEGV_MAPERR : SEGV_ACCERR; SEGV_MAPERR : SEGV_ACCERR;
...@@ -236,13 +236,13 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault) ...@@ -236,13 +236,13 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
break; break;
default: /* fault & VM_FAULT_ERROR */ default: /* fault & VM_FAULT_ERROR */
if (fault & VM_FAULT_OOM) { if (fault & VM_FAULT_OOM) {
if (!(regs->psw.mask & PSW_MASK_PSTATE)) if (!user_mode(regs))
do_no_context(regs); do_no_context(regs);
else else
pagefault_out_of_memory(); pagefault_out_of_memory();
} else if (fault & VM_FAULT_SIGBUS) { } else if (fault & VM_FAULT_SIGBUS) {
/* Kernel mode? Handle exceptions or die */ /* Kernel mode? Handle exceptions or die */
if (!(regs->psw.mask & PSW_MASK_PSTATE)) if (!user_mode(regs))
do_no_context(regs); do_no_context(regs);
else else
do_sigbus(regs); do_sigbus(regs);
...@@ -436,7 +436,7 @@ void __kprobes do_asce_exception(struct pt_regs *regs) ...@@ -436,7 +436,7 @@ void __kprobes do_asce_exception(struct pt_regs *regs)
} }
/* User mode accesses just cause a SIGSEGV */ /* User mode accesses just cause a SIGSEGV */
if (regs->psw.mask & PSW_MASK_PSTATE) { if (user_mode(regs)) {
do_sigsegv(regs, SEGV_MAPERR); do_sigsegv(regs, SEGV_MAPERR);
return; return;
} }
......
...@@ -58,7 +58,7 @@ void s390_backtrace(struct pt_regs * const regs, unsigned int depth) ...@@ -58,7 +58,7 @@ void s390_backtrace(struct pt_regs * const regs, unsigned int depth)
unsigned long head; unsigned long head;
struct stack_frame* head_sf; struct stack_frame* head_sf;
if (user_mode (regs)) if (user_mode(regs))
return; return;
head = regs->gprs[15]; head = regs->gprs[15];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment