]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
[S390] user per registers vs. ptrace single stepping
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Sun, 30 Oct 2011 14:16:07 +0000 (15:16 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Sun, 30 Oct 2011 14:16:15 +0000 (15:16 +0100)
git commit 5e9a2692 "[S390] ptrace cleanup" introduced a regression
for the case when both a user PER set (e.g. a storage alteration trace) and
PTRACE_SINGLESTEP are active. The new code will overrule the user PER set
with a instruction-fetch PER set over the whole address space for ptrace
single stepping. The inferior process will be stopped after each instruction
with an instruction fetch event. Any other events that may have occurred
concurrently are not reported (e.g. storage alteration event) because the
control bits for them are not set. The solution is to merge the PER control
bits of the user PER set with the PER_EVENT_IFETCH control bit for
PTRACE_SINGLESTEP.

Cc: stable@kernel.org
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/ptrace.c

index ef86ad2439868ffd4889b56f378f19e5c1f11968..ae0e14b8880ca8a8176ea866bc2ac6b622a4e057 100644 (file)
@@ -47,29 +47,31 @@ enum s390_regset {
 
 void update_per_regs(struct task_struct *task)
 {
-       static const struct per_regs per_single_step = {
-               .control = PER_EVENT_IFETCH,
-               .start = 0,
-               .end = PSW_ADDR_INSN,
-       };
        struct pt_regs *regs = task_pt_regs(task);
        struct thread_struct *thread = &task->thread;
-       const struct per_regs *new;
-       struct per_regs old;
-
-       /* TIF_SINGLE_STEP overrides the user specified PER registers. */
-       new = test_tsk_thread_flag(task, TIF_SINGLE_STEP) ?
-               &per_single_step : &thread->per_user;
+       struct per_regs old, new;
+
+       /* Copy user specified PER registers */
+       new.control = thread->per_user.control;
+       new.start = thread->per_user.start;
+       new.end = thread->per_user.end;
+
+       /* merge TIF_SINGLE_STEP into user specified PER registers. */
+       if (test_tsk_thread_flag(task, TIF_SINGLE_STEP)) {
+               new.control |= PER_EVENT_IFETCH;
+               new.start = 0;
+               new.end = PSW_ADDR_INSN;
+       }
 
        /* Take care of the PER enablement bit in the PSW. */
-       if (!(new->control & PER_EVENT_MASK)) {
+       if (!(new.control & PER_EVENT_MASK)) {
                regs->psw.mask &= ~PSW_MASK_PER;
                return;
        }
        regs->psw.mask |= PSW_MASK_PER;
        __ctl_store(old, 9, 11);
-       if (memcmp(new, &old, sizeof(struct per_regs)) != 0)
-               __ctl_load(*new, 9, 11);
+       if (memcmp(&new, &old, sizeof(struct per_regs)) != 0)
+               __ctl_load(new, 9, 11);
 }
 
 void user_enable_single_step(struct task_struct *task)