aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-08 13:47:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-08 13:47:39 -0400
commitda1ba891f22835db9a2c349315c3763e9f4e4e67 (patch)
tree958c53bfbe540c14370709d64c538e5c3f6cff2b /arch/s390/kernel
parent8b2cc917a02936c3ea7d8da46801c7b7b6233093 (diff)
parent45e576b1c3d0020607b8666c0247164e92c7d719 (diff)
Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6
* 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6: [S390] guest page hinting light [S390] tty3270: fix put_char fail/success conversion. [S390] compat ptrace cleanup [S390] s390mach compile warning [S390] cio: Fix parsing mechanism for blacklisted devices. [S390] cio: Remove cio_msg kernel parameter. [S390] s390-kvm: leave sie context on work. Removes preemption requirement [S390] s390: Optimize user and work TIF check
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/kernel/entry.S29
-rw-r--r--arch/s390/kernel/entry64.S57
-rw-r--r--arch/s390/kernel/ptrace.c100
4 files changed, 63 insertions, 125 deletions
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 743d54f0b8db..d003a6e16afb 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -121,7 +121,7 @@ sys32_ptrace_wrapper:
121 lgfr %r3,%r3 # long 121 lgfr %r3,%r3 # long
122 llgtr %r4,%r4 # long 122 llgtr %r4,%r4 # long
123 llgfr %r5,%r5 # long 123 llgfr %r5,%r5 # long
124 jg sys_ptrace # branch to system call 124 jg compat_sys_ptrace # branch to system call
125 125
126 .globl sys32_alarm_wrapper 126 .globl sys32_alarm_wrapper
127sys32_alarm_wrapper: 127sys32_alarm_wrapper:
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index bdbb3bcd78a5..708cf9cf9a35 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -279,8 +279,6 @@ sysc_do_restart:
279 st %r2,SP_R2(%r15) # store return value (change R2 on stack) 279 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
280 280
281sysc_return: 281sysc_return:
282 tm SP_PSW+1(%r15),0x01 # returning to user ?
283 bno BASED(sysc_restore)
284 tm __TI_flags+3(%r9),_TIF_WORK_SVC 282 tm __TI_flags+3(%r9),_TIF_WORK_SVC
285 bnz BASED(sysc_work) # there is work to do (signals etc.) 283 bnz BASED(sysc_work) # there is work to do (signals etc.)
286sysc_restore: 284sysc_restore:
@@ -312,6 +310,8 @@ sysc_work_loop:
312# One of the work bits is on. Find out which one. 310# One of the work bits is on. Find out which one.
313# 311#
314sysc_work: 312sysc_work:
313 tm SP_PSW+1(%r15),0x01 # returning to user ?
314 bno BASED(sysc_restore)
315 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING 315 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
316 bo BASED(sysc_mcck_pending) 316 bo BASED(sysc_mcck_pending)
317 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED 317 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
@@ -602,12 +602,6 @@ io_no_vtime:
602 la %r2,SP_PTREGS(%r15) # address of register-save area 602 la %r2,SP_PTREGS(%r15) # address of register-save area
603 basr %r14,%r1 # branch to standard irq handler 603 basr %r14,%r1 # branch to standard irq handler
604io_return: 604io_return:
605 tm SP_PSW+1(%r15),0x01 # returning to user ?
606#ifdef CONFIG_PREEMPT
607 bno BASED(io_preempt) # no -> check for preemptive scheduling
608#else
609 bno BASED(io_restore) # no-> skip resched & signal
610#endif
611 tm __TI_flags+3(%r9),_TIF_WORK_INT 605 tm __TI_flags+3(%r9),_TIF_WORK_INT
612 bnz BASED(io_work) # there is work to do (signals etc.) 606 bnz BASED(io_work) # there is work to do (signals etc.)
613io_restore: 607io_restore:
@@ -629,10 +623,18 @@ io_restore_trace_psw:
629 .long 0, io_restore_trace + 0x80000000 623 .long 0, io_restore_trace + 0x80000000
630#endif 624#endif
631 625
632#ifdef CONFIG_PREEMPT 626#
633io_preempt: 627# switch to kernel stack, then check the TIF bits
628#
629io_work:
630 tm SP_PSW+1(%r15),0x01 # returning to user ?
631#ifndef CONFIG_PREEMPT
632 bno BASED(io_restore) # no-> skip resched & signal
633#else
634 bnz BASED(io_work_user) # no -> check for preemptive scheduling
635 # check for preemptive scheduling
634 icm %r0,15,__TI_precount(%r9) 636 icm %r0,15,__TI_precount(%r9)
635 bnz BASED(io_restore) 637 bnz BASED(io_restore) # preemption disabled
636 l %r1,SP_R15(%r15) 638 l %r1,SP_R15(%r15)
637 s %r1,BASED(.Lc_spsize) 639 s %r1,BASED(.Lc_spsize)
638 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15) 640 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
@@ -646,10 +648,7 @@ io_resume_loop:
646 br %r1 # call schedule 648 br %r1 # call schedule
647#endif 649#endif
648 650
649# 651io_work_user:
650# switch to kernel stack, then check the TIF bits
651#
652io_work:
653 l %r1,__LC_KERNEL_STACK 652 l %r1,__LC_KERNEL_STACK
654 s %r1,BASED(.Lc_spsize) 653 s %r1,BASED(.Lc_spsize)
655 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15) 654 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 5a4a7bcd2bba..fee10177dbfc 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -271,8 +271,6 @@ sysc_noemu:
271 stg %r2,SP_R2(%r15) # store return value (change R2 on stack) 271 stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
272 272
273sysc_return: 273sysc_return:
274 tm SP_PSW+1(%r15),0x01 # returning to user ?
275 jno sysc_restore
276 tm __TI_flags+7(%r9),_TIF_WORK_SVC 274 tm __TI_flags+7(%r9),_TIF_WORK_SVC
277 jnz sysc_work # there is work to do (signals etc.) 275 jnz sysc_work # there is work to do (signals etc.)
278sysc_restore: 276sysc_restore:
@@ -304,6 +302,8 @@ sysc_work_loop:
304# One of the work bits is on. Find out which one. 302# One of the work bits is on. Find out which one.
305# 303#
306sysc_work: 304sysc_work:
305 tm SP_PSW+1(%r15),0x01 # returning to user ?
306 jno sysc_restore
307 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING 307 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
308 jo sysc_mcck_pending 308 jo sysc_mcck_pending
309 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED 309 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
@@ -585,12 +585,6 @@ io_no_vtime:
585 la %r2,SP_PTREGS(%r15) # address of register-save area 585 la %r2,SP_PTREGS(%r15) # address of register-save area
586 brasl %r14,do_IRQ # call standard irq handler 586 brasl %r14,do_IRQ # call standard irq handler
587io_return: 587io_return:
588 tm SP_PSW+1(%r15),0x01 # returning to user ?
589#ifdef CONFIG_PREEMPT
590 jno io_preempt # no -> check for preemptive scheduling
591#else
592 jno io_restore # no-> skip resched & signal
593#endif
594 tm __TI_flags+7(%r9),_TIF_WORK_INT 588 tm __TI_flags+7(%r9),_TIF_WORK_INT
595 jnz io_work # there is work to do (signals etc.) 589 jnz io_work # there is work to do (signals etc.)
596io_restore: 590io_restore:
@@ -612,10 +606,41 @@ io_restore_trace_psw:
612 .quad 0, io_restore_trace 606 .quad 0, io_restore_trace
613#endif 607#endif
614 608
615#ifdef CONFIG_PREEMPT 609#
616io_preempt: 610# There is work todo, we need to check if we return to userspace, then
611# check, if we are in SIE, if yes leave it
612#
613io_work:
614 tm SP_PSW+1(%r15),0x01 # returning to user ?
615#ifndef CONFIG_PREEMPT
616#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
617 jnz io_work_user # yes -> no need to check for SIE
618 la %r1, BASED(sie_opcode) # we return to kernel here
619 lg %r2, SP_PSW+8(%r15)
620 clc 0(2,%r1), 0(%r2) # is current instruction = SIE?
621 jne io_restore # no-> return to kernel
622 lg %r1, SP_PSW+8(%r15) # yes-> add 4 bytes to leave SIE
623 aghi %r1, 4
624 stg %r1, SP_PSW+8(%r15)
625 j io_restore # return to kernel
626#else
627 jno io_restore # no-> skip resched & signal
628#endif
629#else
630 jnz io_work_user # yes -> do resched & signal
631#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
632 la %r1, BASED(sie_opcode)
633 lg %r2, SP_PSW+8(%r15)
634 clc 0(2,%r1), 0(%r2) # is current instruction = SIE?
635 jne 0f # no -> leave PSW alone
636 lg %r1, SP_PSW+8(%r15) # yes-> add 4 bytes to leave SIE
637 aghi %r1, 4
638 stg %r1, SP_PSW+8(%r15)
6390:
640#endif
641 # check for preemptive scheduling
617 icm %r0,15,__TI_precount(%r9) 642 icm %r0,15,__TI_precount(%r9)
618 jnz io_restore 643 jnz io_restore # preemption is disabled
619 # switch to kernel stack 644 # switch to kernel stack
620 lg %r1,SP_R15(%r15) 645 lg %r1,SP_R15(%r15)
621 aghi %r1,-SP_SIZE 646 aghi %r1,-SP_SIZE
@@ -629,10 +654,7 @@ io_resume_loop:
629 jg preempt_schedule_irq 654 jg preempt_schedule_irq
630#endif 655#endif
631 656
632# 657io_work_user:
633# switch to kernel stack, then check TIF bits
634#
635io_work:
636 lg %r1,__LC_KERNEL_STACK 658 lg %r1,__LC_KERNEL_STACK
637 aghi %r1,-SP_SIZE 659 aghi %r1,-SP_SIZE
638 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15) 660 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
@@ -653,6 +675,11 @@ io_work_loop:
653 j io_restore 675 j io_restore
654io_work_done: 676io_work_done:
655 677
678#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
679sie_opcode:
680 .long 0xb2140000
681#endif
682
656# 683#
657# _TIF_MCCK_PENDING is set, call handler 684# _TIF_MCCK_PENDING is set, call handler
658# 685#
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 7f4270163744..35827b9bd4d1 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -292,8 +292,7 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data)
292 return 0; 292 return 0;
293} 293}
294 294
295static int 295long arch_ptrace(struct task_struct *child, long request, long addr, long data)
296do_ptrace_normal(struct task_struct *child, long request, long addr, long data)
297{ 296{
298 ptrace_area parea; 297 ptrace_area parea;
299 int copied, ret; 298 int copied, ret;
@@ -529,35 +528,19 @@ poke_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
529 return 0; 528 return 0;
530} 529}
531 530
532static int 531long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
533do_ptrace_emu31(struct task_struct *child, long request, long addr, long data) 532 compat_ulong_t caddr, compat_ulong_t cdata)
534{ 533{
535 unsigned int tmp; /* 4 bytes !! */ 534 unsigned long addr = caddr;
535 unsigned long data = cdata;
536 ptrace_area_emu31 parea; 536 ptrace_area_emu31 parea;
537 int copied, ret; 537 int copied, ret;
538 538
539 switch (request) { 539 switch (request) {
540 case PTRACE_PEEKTEXT:
541 case PTRACE_PEEKDATA:
542 /* read word at location addr. */
543 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
544 if (copied != sizeof(tmp))
545 return -EIO;
546 return put_user(tmp, (unsigned int __force __user *) data);
547
548 case PTRACE_PEEKUSR: 540 case PTRACE_PEEKUSR:
549 /* read the word at location addr in the USER area. */ 541 /* read the word at location addr in the USER area. */
550 return peek_user_emu31(child, addr, data); 542 return peek_user_emu31(child, addr, data);
551 543
552 case PTRACE_POKETEXT:
553 case PTRACE_POKEDATA:
554 /* write the word at location addr. */
555 tmp = data;
556 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 1);
557 if (copied != sizeof(tmp))
558 return -EIO;
559 return 0;
560
561 case PTRACE_POKEUSR: 544 case PTRACE_POKEUSR:
562 /* write the word at location addr in the USER area */ 545 /* write the word at location addr in the USER area */
563 return poke_user_emu31(child, addr, data); 546 return poke_user_emu31(child, addr, data);
@@ -587,82 +570,11 @@ do_ptrace_emu31(struct task_struct *child, long request, long addr, long data)
587 copied += sizeof(unsigned int); 570 copied += sizeof(unsigned int);
588 } 571 }
589 return 0; 572 return 0;
590 case PTRACE_GETEVENTMSG:
591 return put_user((__u32) child->ptrace_message,
592 (unsigned int __force __user *) data);
593 case PTRACE_GETSIGINFO:
594 if (child->last_siginfo == NULL)
595 return -EINVAL;
596 return copy_siginfo_to_user32((compat_siginfo_t
597 __force __user *) data,
598 child->last_siginfo);
599 case PTRACE_SETSIGINFO:
600 if (child->last_siginfo == NULL)
601 return -EINVAL;
602 return copy_siginfo_from_user32(child->last_siginfo,
603 (compat_siginfo_t
604 __force __user *) data);
605 } 573 }
606 return ptrace_request(child, request, addr, data); 574 return compat_ptrace_request(child, request, addr, data);
607} 575}
608#endif 576#endif
609 577
610long arch_ptrace(struct task_struct *child, long request, long addr, long data)
611{
612 switch (request) {
613 case PTRACE_SYSCALL:
614 /* continue and stop at next (return from) syscall */
615 case PTRACE_CONT:
616 /* restart after signal. */
617 if (!valid_signal(data))
618 return -EIO;
619 if (request == PTRACE_SYSCALL)
620 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
621 else
622 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
623 child->exit_code = data;
624 /* make sure the single step bit is not set. */
625 user_disable_single_step(child);
626 wake_up_process(child);
627 return 0;
628
629 case PTRACE_KILL:
630 /*
631 * make the child exit. Best I can do is send it a sigkill.
632 * perhaps it should be put in the status that it wants to
633 * exit.
634 */
635 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
636 return 0;
637 child->exit_code = SIGKILL;
638 /* make sure the single step bit is not set. */
639 user_disable_single_step(child);
640 wake_up_process(child);
641 return 0;
642
643 case PTRACE_SINGLESTEP:
644 /* set the trap flag. */
645 if (!valid_signal(data))
646 return -EIO;
647 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
648 child->exit_code = data;
649 user_enable_single_step(child);
650 /* give it a chance to run. */
651 wake_up_process(child);
652 return 0;
653
654 /* Do requests that differ for 31/64 bit */
655 default:
656#ifdef CONFIG_COMPAT
657 if (test_thread_flag(TIF_31BIT))
658 return do_ptrace_emu31(child, request, addr, data);
659#endif
660 return do_ptrace_normal(child, request, addr, data);
661 }
662 /* Not reached. */
663 return -EIO;
664}
665
666asmlinkage void 578asmlinkage void
667syscall_trace(struct pt_regs *regs, int entryexit) 579syscall_trace(struct pt_regs *regs, int entryexit)
668{ 580{