diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2012-07-27 04:31:12 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2012-07-30 05:03:12 -0400 |
commit | 7d25617597ff8dcfe4d0e1d0ac9214e7cc7ded92 (patch) | |
tree | 5195733687b3194e053be0687137f6f6b05472e0 /arch/s390 | |
parent | 37fe1d73a449bdebc4908d04e518f5852d6c453b (diff) |
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: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kernel/dis.c | 4 | ||||
-rw-r--r-- | arch/s390/kernel/traps.c | 16 | ||||
-rw-r--r-- | arch/s390/mm/fault.c | 8 | ||||
-rw-r--r-- | arch/s390/oprofile/backtrace.c | 2 |
4 files changed, 15 insertions, 15 deletions
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c index 1f6b428e2762..619c5d350726 100644 --- a/arch/s390/kernel/dis.c +++ b/arch/s390/kernel/dis.c | |||
@@ -1531,7 +1531,7 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr) | |||
1531 | 1531 | ||
1532 | void show_code(struct pt_regs *regs) | 1532 | void show_code(struct pt_regs *regs) |
1533 | { | 1533 | { |
1534 | char *mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl"; | 1534 | char *mode = user_mode(regs) ? "User" : "Krnl"; |
1535 | unsigned char code[64]; | 1535 | unsigned char code[64]; |
1536 | char buffer[64], *ptr; | 1536 | char buffer[64], *ptr; |
1537 | mm_segment_t old_fs; | 1537 | mm_segment_t old_fs; |
@@ -1540,7 +1540,7 @@ void show_code(struct pt_regs *regs) | |||
1540 | 1540 | ||
1541 | /* Get a snapshot of the 64 bytes surrounding the fault address. */ | 1541 | /* Get a snapshot of the 64 bytes surrounding the fault address. */ |
1542 | old_fs = get_fs(); | 1542 | old_fs = get_fs(); |
1543 | set_fs((regs->psw.mask & PSW_MASK_PSTATE) ? USER_DS : KERNEL_DS); | 1543 | set_fs(user_mode(regs) ? USER_DS : KERNEL_DS); |
1544 | for (start = 32; start && regs->psw.addr >= 34 - start; start -= 2) { | 1544 | for (start = 32; start && regs->psw.addr >= 34 - start; start -= 2) { |
1545 | addr = regs->psw.addr - 34 + start; | 1545 | addr = regs->psw.addr - 34 + start; |
1546 | if (__copy_from_user(code + start - 2, | 1546 | if (__copy_from_user(code + start - 2, |
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c index af2421a0f315..01775c04a90e 100644 --- a/arch/s390/kernel/traps.c +++ b/arch/s390/kernel/traps.c | |||
@@ -185,7 +185,7 @@ void show_registers(struct pt_regs *regs) | |||
185 | { | 185 | { |
186 | char *mode; | 186 | char *mode; |
187 | 187 | ||
188 | mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl"; | 188 | mode = user_mode(regs) ? "User" : "Krnl"; |
189 | printk("%s PSW : %p %p", | 189 | printk("%s PSW : %p %p", |
190 | mode, (void *) regs->psw.mask, | 190 | mode, (void *) regs->psw.mask, |
191 | (void *) regs->psw.addr); | 191 | (void *) regs->psw.addr); |
@@ -225,7 +225,7 @@ void show_regs(struct pt_regs *regs) | |||
225 | (void *) current->thread.ksp); | 225 | (void *) current->thread.ksp); |
226 | show_registers(regs); | 226 | show_registers(regs); |
227 | /* Show stack backtrace if pt_regs is from kernel mode */ | 227 | /* Show stack backtrace if pt_regs is from kernel mode */ |
228 | if (!(regs->psw.mask & PSW_MASK_PSTATE)) | 228 | if (!user_mode(regs)) |
229 | show_trace(NULL, (unsigned long *) regs->gprs[15]); | 229 | show_trace(NULL, (unsigned long *) regs->gprs[15]); |
230 | show_last_breaking_event(regs); | 230 | show_last_breaking_event(regs); |
231 | } | 231 | } |
@@ -300,7 +300,7 @@ static void __kprobes do_trap(struct pt_regs *regs, | |||
300 | regs->int_code, si_signo) == NOTIFY_STOP) | 300 | regs->int_code, si_signo) == NOTIFY_STOP) |
301 | return; | 301 | return; |
302 | 302 | ||
303 | if (regs->psw.mask & PSW_MASK_PSTATE) { | 303 | if (user_mode(regs)) { |
304 | info.si_signo = si_signo; | 304 | info.si_signo = si_signo; |
305 | info.si_errno = 0; | 305 | info.si_errno = 0; |
306 | info.si_code = si_code; | 306 | info.si_code = si_code; |
@@ -341,7 +341,7 @@ void __kprobes do_per_trap(struct pt_regs *regs) | |||
341 | 341 | ||
342 | static void default_trap_handler(struct pt_regs *regs) | 342 | static void default_trap_handler(struct pt_regs *regs) |
343 | { | 343 | { |
344 | if (regs->psw.mask & PSW_MASK_PSTATE) { | 344 | if (user_mode(regs)) { |
345 | report_user_fault(regs, SIGSEGV); | 345 | report_user_fault(regs, SIGSEGV); |
346 | do_exit(SIGSEGV); | 346 | do_exit(SIGSEGV); |
347 | } else | 347 | } else |
@@ -410,7 +410,7 @@ static void __kprobes illegal_op(struct pt_regs *regs) | |||
410 | 410 | ||
411 | location = get_psw_address(regs); | 411 | location = get_psw_address(regs); |
412 | 412 | ||
413 | if (regs->psw.mask & PSW_MASK_PSTATE) { | 413 | if (user_mode(regs)) { |
414 | if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) | 414 | if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) |
415 | return; | 415 | return; |
416 | if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { | 416 | if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { |
@@ -478,7 +478,7 @@ void specification_exception(struct pt_regs *regs) | |||
478 | 478 | ||
479 | location = (__u16 __user *) get_psw_address(regs); | 479 | location = (__u16 __user *) get_psw_address(regs); |
480 | 480 | ||
481 | if (regs->psw.mask & PSW_MASK_PSTATE) { | 481 | if (user_mode(regs)) { |
482 | get_user(*((__u16 *) opcode), location); | 482 | get_user(*((__u16 *) opcode), location); |
483 | switch (opcode[0]) { | 483 | switch (opcode[0]) { |
484 | case 0x28: /* LDR Rx,Ry */ | 484 | case 0x28: /* LDR Rx,Ry */ |
@@ -531,7 +531,7 @@ static void data_exception(struct pt_regs *regs) | |||
531 | asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc)); | 531 | asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc)); |
532 | 532 | ||
533 | #ifdef CONFIG_MATHEMU | 533 | #ifdef CONFIG_MATHEMU |
534 | else if (regs->psw.mask & PSW_MASK_PSTATE) { | 534 | else if (user_mode(regs)) { |
535 | __u8 opcode[6]; | 535 | __u8 opcode[6]; |
536 | get_user(*((__u16 *) opcode), location); | 536 | get_user(*((__u16 *) opcode), location); |
537 | switch (opcode[0]) { | 537 | switch (opcode[0]) { |
@@ -598,7 +598,7 @@ static void data_exception(struct pt_regs *regs) | |||
598 | static void space_switch_exception(struct pt_regs *regs) | 598 | static void space_switch_exception(struct pt_regs *regs) |
599 | { | 599 | { |
600 | /* Set user psw back to home space mode. */ | 600 | /* Set user psw back to home space mode. */ |
601 | if (regs->psw.mask & PSW_MASK_PSTATE) | 601 | if (user_mode(regs)) |
602 | regs->psw.mask |= PSW_ASC_HOME; | 602 | regs->psw.mask |= PSW_ASC_HOME; |
603 | /* Send SIGILL. */ | 603 | /* Send SIGILL. */ |
604 | do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); | 604 | do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); |
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 5bddbe4895d5..6c013f544146 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c | |||
@@ -220,7 +220,7 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault) | |||
220 | case VM_FAULT_BADACCESS: | 220 | case VM_FAULT_BADACCESS: |
221 | case VM_FAULT_BADMAP: | 221 | case VM_FAULT_BADMAP: |
222 | /* Bad memory access. Check if it is kernel or user space. */ | 222 | /* Bad memory access. Check if it is kernel or user space. */ |
223 | if (regs->psw.mask & PSW_MASK_PSTATE) { | 223 | if (user_mode(regs)) { |
224 | /* User mode accesses just cause a SIGSEGV */ | 224 | /* User mode accesses just cause a SIGSEGV */ |
225 | si_code = (fault == VM_FAULT_BADMAP) ? | 225 | si_code = (fault == VM_FAULT_BADMAP) ? |
226 | SEGV_MAPERR : SEGV_ACCERR; | 226 | SEGV_MAPERR : SEGV_ACCERR; |
@@ -236,13 +236,13 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault) | |||
236 | break; | 236 | break; |
237 | default: /* fault & VM_FAULT_ERROR */ | 237 | default: /* fault & VM_FAULT_ERROR */ |
238 | if (fault & VM_FAULT_OOM) { | 238 | if (fault & VM_FAULT_OOM) { |
239 | if (!(regs->psw.mask & PSW_MASK_PSTATE)) | 239 | if (!user_mode(regs)) |
240 | do_no_context(regs); | 240 | do_no_context(regs); |
241 | else | 241 | else |
242 | pagefault_out_of_memory(); | 242 | pagefault_out_of_memory(); |
243 | } else if (fault & VM_FAULT_SIGBUS) { | 243 | } else if (fault & VM_FAULT_SIGBUS) { |
244 | /* Kernel mode? Handle exceptions or die */ | 244 | /* Kernel mode? Handle exceptions or die */ |
245 | if (!(regs->psw.mask & PSW_MASK_PSTATE)) | 245 | if (!user_mode(regs)) |
246 | do_no_context(regs); | 246 | do_no_context(regs); |
247 | else | 247 | else |
248 | do_sigbus(regs); | 248 | do_sigbus(regs); |
@@ -436,7 +436,7 @@ void __kprobes do_asce_exception(struct pt_regs *regs) | |||
436 | } | 436 | } |
437 | 437 | ||
438 | /* User mode accesses just cause a SIGSEGV */ | 438 | /* User mode accesses just cause a SIGSEGV */ |
439 | if (regs->psw.mask & PSW_MASK_PSTATE) { | 439 | if (user_mode(regs)) { |
440 | do_sigsegv(regs, SEGV_MAPERR); | 440 | do_sigsegv(regs, SEGV_MAPERR); |
441 | return; | 441 | return; |
442 | } | 442 | } |
diff --git a/arch/s390/oprofile/backtrace.c b/arch/s390/oprofile/backtrace.c index c82f62fb9c28..8a6811b2cdb9 100644 --- a/arch/s390/oprofile/backtrace.c +++ b/arch/s390/oprofile/backtrace.c | |||
@@ -58,7 +58,7 @@ void s390_backtrace(struct pt_regs * const regs, unsigned int depth) | |||
58 | unsigned long head; | 58 | unsigned long head; |
59 | struct stack_frame* head_sf; | 59 | struct stack_frame* head_sf; |
60 | 60 | ||
61 | if (user_mode (regs)) | 61 | if (user_mode(regs)) |
62 | return; | 62 | return; |
63 | 63 | ||
64 | head = regs->gprs[15]; | 64 | head = regs->gprs[15]; |