[PATCH 141] kill suppress_sigtrap()

2009-12-05 Thread Oleg Nesterov
You are right, thanks, suppress_sigtrap() is no longer needed.

Surprisingly, it even has the comment which explains why it was needed before,
and since the recent changes SIGTRAP from tracehook_report_syscall_exit()
pathes is just not possible with utrace.

This should also fix the compilation on s390.

---

 kernel/ptrace-utrace.c |   19 +--
 1 file changed, 1 insertion(+), 18 deletions(-)

--- UTRACE-PTRACE/kernel/ptrace-utrace.c~141_KILL_SUPPRESS_SIGTRAP  
2009-12-04 16:19:17.0 +0100
+++ UTRACE-PTRACE/kernel/ptrace-utrace.c2009-12-05 16:16:15.0 
+0100
@@ -324,16 +324,6 @@ static void ptrace_clone_attach(struct t
set_tsk_thread_flag(child, TIF_SIGPENDING);
 }
 
-/*
- * Prevents sending SIGTRAP after tracehook_report_syscall_exit().
- * Called when we are going to emulate the stop before SYSCALL_EXIT.
- */
-static void suppress_sigtrap(struct task_struct *task)
-{
-   if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
-   user_disable_single_step(task);
-}
-
 static u32 ptrace_report_clone(enum utrace_resume_action action,
   struct utrace_engine *engine,
   struct task_struct *parent,
@@ -369,8 +359,6 @@ static u32 ptrace_report_clone(enum utra
if (!event)
return UTRACE_RESUME;
 
-   suppress_sigtrap(parent);
-
set_stop_code(ctx, event);
ctx-eventmsg = child-pid;
/*
@@ -411,11 +399,8 @@ static u32 ptrace_report_syscall_entry(u
 
set_syscall_code(ctx);
 
-   if (unlikely(ctx-options  PTRACE_O_SYSEMU)) {
-   suppress_sigtrap(task);
+   if (unlikely(ctx-options  PTRACE_O_SYSEMU))
return UTRACE_SYSCALL_ABORT | UTRACE_REPORT;
-   }
-
/*
 * Stop now to report.  We will get another callback after
 * we resume, with the UTRACE_SYSCALL_RESUMED flag set.
@@ -465,9 +450,7 @@ static u32 ptrace_report_exec(enum utrac
return UTRACE_RESUME;
}
 
-   suppress_sigtrap(task);
set_stop_code(ctx, PTRACE_EVENT_EXEC);
-
return UTRACE_STOP;
 }
 



[PATCH 142] fix __must_check warnings

2009-12-05 Thread Oleg Nesterov
Fix __must_check warnings. The change in ptrace_wake_up() just fools
the compiler, we really don't care if utrace_control() fails or returns
something like -EINPROGRESS. But we could add a clever WARN_ON(err..)
perhaps.

---

 kernel/ptrace-utrace.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- UTRACE-PTRACE/kernel/ptrace-utrace.c~142_MUST_CHECK 2009-12-05 
16:16:15.0 +0100
+++ UTRACE-PTRACE/kernel/ptrace-utrace.c2009-12-05 16:48:48.0 
+0100
@@ -216,7 +216,7 @@ static int ptrace_attach_task(struct tas
return 0;
 }
 
-static void ptrace_wake_up(struct task_struct *tracee,
+static int ptrace_wake_up(struct task_struct *tracee,
struct utrace_engine *engine,
enum utrace_resume_action action,
bool force_wakeup)
@@ -236,7 +236,8 @@ static void ptrace_wake_up(struct task_s
 
if (action != UTRACE_REPORT)
ptrace_context(engine)-stop_code = 0;
-   utrace_control(tracee, engine, action);
+
+   return utrace_control(tracee, engine, action);
 }
 
 static void ptrace_detach_task(struct task_struct *tracee, int sig)
@@ -556,7 +557,8 @@ static u32 ptrace_report_signal(u32 acti
 * Make sure the subsequent UTRACE_SIGNAL_REPORT clears
 * -siginfo before return from get_signal_to_deliver().
 */
-   utrace_control(task, engine, UTRACE_INTERRUPT);
+   if (utrace_control(task, engine, UTRACE_INTERRUPT))
+   WARN_ON(1);
 
ctx-signr = info-si_signo;
ctx-stop_code = (PTRACE_EVENT_SIGNAL  8) | ctx-signr;



Re: [PATCH] utrace: don't set -ops = utrace_detached_ops lockless

2009-12-05 Thread CAI Qian

 I was going to try again, but noticed you already recompiled and
 booted the kernel. I see ./test is running and there is nothing bad
 in dmesg ;)

Yes, it looks good so far. Ptrace tests also does not show any regression. I 
kicked off a few tests on other platform, so hopefully have more information 
shortly.



Re: [PATCH] utrace: don't set -ops = utrace_detached_ops lockless

2009-12-05 Thread caiqian

 Yes, it looks good so far. Ptrace tests also does not show any
 regression.

I said this too early. Looks like step-jump-count started to fail now.

step-jump-cont: step-jump-cont.c:244: main: Assertion `0' failed.
/bin/sh: line 5: 28212 Aborted ${dir}$tst
FAIL: step-jump-cont

You can login the same machine.

# cd /mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests/tests
# make check



Re: [PATCH v2] ptrace-tests: fix step-fork.c on powerpc for ptrace-utrace

2009-12-05 Thread Oleg Nesterov
Jan, this fixes step-fork.c on powerpc.

Without this patch it just hangs, see

http://marc.info/?t=12592474861

On 12/01, Veaceslav Falico wrote:

 Instead of using fork(), call syscall(__NR_fork) in step-fork.c
 to avoid looping on powerpc arch in libc.
 
 Signed-off-by: Veaceslav Falico vfal...@redhat.com
 ---
 
 --- a/ptrace-tests/tests/step-fork.c  2009-12-01 17:17:14.0 +0100
 +++ b/ptrace-tests/tests/step-fork.c  2009-12-01 18:35:15.0 +0100
 @@ -29,6 +29,7 @@
  #include unistd.h
  #include sys/wait.h
  #include string.h
 +#include sys/syscall.h
  #include signal.h
  
  #ifndef PTRACE_SINGLESTEP
 @@ -78,7 +79,12 @@ main (int argc, char **argv)
   sigprocmask (SIG_BLOCK, mask, NULL);
   ptrace (PTRACE_TRACEME);
   raise (SIGUSR1);
 - if (fork () == 0)
 +
 + /*
 +  * Can't use fork() directly because on powerpc it loops inside libc 
 under
 +  * PTRACE_SINGLESTEP. See 
 http://marc.info/?l=linux-kernelm=125927241130695
 +  */
 + if (syscall(__NR_fork) == 0)
 {
   read (-1, NULL, 0);
   _exit (22);



step-into-handler.c compilation failure on ppc64

2009-12-05 Thread caiqian
# make check
...
gcc -DPACKAGE_NAME=\ptrace\ regression\ test\ suite\ 
-DPACKAGE_TARNAME=\ptrace-tests\ -DPACKAGE_VERSION=\0.1\ 
-DPACKAGE_STRING=\ptrace\ regression\ test\ suite\ 0.1\ 
-DPACKAGE_BUGREPORT=\utrace-de...@redhat.com\ -DPACKAGE=\ptrace-tests\ 
-DVERSION=\0.1\ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 
-DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 
-D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 
-I.-std=gnu99 -Wall -Werror -g -O2 -MT step-into-handler.o -MD -MP -MF 
.deps/step-into-handler.Tpo -c -o step-into-handler.o step-into-handler.c
cc1: warnings being treated as errors
step-into-handler.c: In function ‘handler_alrm_get’:
step-into-handler.c:116: error: dereferencing type-punned pointer will break 
strict-aliasing rules
make[1]: *** [step-into-handler.o] Error 1
make[1]: Leaving directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests/tests'
make: *** [check] Error 2

There could be a better fix. This patch only add -fno-strict-aliasing to ignore 
the warning.--- tests/Makefile.in.orig	2009-12-05 12:07:27.726259155 -0500
+++ tests/Makefile.in	2009-12-05 12:07:47.107196650 -0500
@@ -547,7 +547,7 @@
 	   user-area-padding			\
 	   reparent-zombie-clone
 
-AM_CFLAGS = -std=gnu99 -Wall -Werror
+AM_CFLAGS = -std=gnu99 -Wall -Werror -fno-strict-aliasing
 x86_64_ia32_gs_LDFLAGS = -lpthread
 late_ptrace_may_attach_check_LDFLAGS = -lpthread
 ppc_dabr_race_LDFLAGS = -lpthread


Re: step-into-handler.c compilation failure on ppc64

2009-12-05 Thread Roland McGrath
How about this?

--- step-into-handler.c 10 Dec 2008 04:42:43 -0800  1.8
+++ step-into-handler.c 05 Dec 2009 09:18:54 -0800  
@@ -35,6 +35,7 @@
 #include sys/time.h
 #include string.h
 #include stddef.h
+#include stdint.h
 
 #if defined __x86_64__
 #define REGISTER_IP regs.rip
@@ -113,11 +114,11 @@ handler_alrm_get (void)
 {
 #if defined __powerpc64__
   /* ppc64 `handler_alrm' resolves to the function descriptor.  */
-  return *(void **) handler_alrm;
+  return *(void **) (uintptr_t) handler_alrm;
 /* __s390x__ defines both the symbols.  */
 #elif defined __s390__  !defined __s390x__
   /* s390 bit 31 is zero here but I am not sure if it cannot be arbitrary.  */
-  return (void *) (0x7fff  (unsigned long) handler_alrm);
+  return (void *) (0x7fff  (uintptr_t) handler_alrm);
 #else
   return handler_alrm;
 #endif



Re: [PATCH] utrace: don't set -ops = utrace_detached_ops lockless

2009-12-05 Thread Oleg Nesterov
On 12/05, caiq...@redhat.com wrote:

  Yes, it looks good so far. Ptrace tests also does not show any
  regression.

 I said this too early. Looks like step-jump-count started to fail now.

 step-jump-cont: step-jump-cont.c:244: main: Assertion `0' failed.
 /bin/sh: line 5: 28212 Aborted ${dir}$tst
 FAIL: step-jump-cont

Hmm. This is very, very strange. I don't know what this test-case
actuallly does, but I can't see how this patch can make any difference.

 You can login the same machine.

Yes, will do tomorrow.

Thanks.

Oleg.



Re: step-into-handler.c compilation failure on ppc64

2009-12-05 Thread CAI Qian

 How about this?

Thanks. Fixed.



ptrace tests failed to compile on i686

2009-12-05 Thread CAI Qian
+ make check
make[1]: Entering directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests'
Making check in tests
make[2]: Entering directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests/tests'
gcc -m64 -DPACKAGE_NAME=\ptrace\ regression\ test\ suite\ 
-DPACKAGE_TARNAME=\ptrace-tests\ -DPACKAGE_VERSION=\0.1\ 
-DPACKAGE_STRING=\ptrace\ regression\ test\ suite\ 0.1\ 
-DPACKAGE_BUGREPORT=\utrace-de...@redhat.com\ -DPACKAGE=\ptrace-tests\ 
-DVERSION=\0.1\ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 
-DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 
-D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 
-D_FILE_OFFSET_BITS=64 -I.   \
  -std=gnu99 -Wall -Werror -g -O2 -o erestartsys-debuggee 
erestartsys-debuggee.c
erestartsys-debuggee.c:1: sorry, unimplemented: 64-bit mode not compiled in
make[2]: *** [erestartsys-debuggee] Error 1
make[2]: Leaving directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests'
+ '[' i386 = x86_64 ']'
+ '[' i386 = ppc64 ']'
+ tee -a /tmp/tmp.yicBDv
+ echo '* run the crasher.'
* run the crasher.
+ tee -a /tmp/tmp.yicBDv
+ make xcheck
make[1]: Entering directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests'
make[2]: Entering directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests'
Making check in tests
make[3]: Entering directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests/tests'
gcc -m64 -DPACKAGE_NAME=\ptrace\ regression\ test\ suite\ 
-DPACKAGE_TARNAME=\ptrace-tests\ -DPACKAGE_VERSION=\0.1\ 
-DPACKAGE_STRING=\ptrace\ regression\ test\ suite\ 0.1\ 
-DPACKAGE_BUGREPORT=\utrace-de...@redhat.com\ -DPACKAGE=\ptrace-tests\ 
-DVERSION=\0.1\ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 
-DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -D__EXTENSIONS__=1 
-D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1 -D_TANDEM_SOURCE=1 
-D_FILE_OFFSET_BITS=64 -I.   \
  -std=gnu99 -Wall -Werror -g -O2 -o erestartsys-debuggee 
erestartsys-debuggee.c
erestartsys-debuggee.c:1: sorry, unimplemented: 64-bit mode not compiled in
make[3]: *** [erestartsys-debuggee] Error 1
make[3]: Leaving directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests/tests'
make[2]: *** [check-recursive] Error 1
make[1]: *** [xcheck] Error 2
make[2]: Leaving directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests'
make[1]: Leaving directory 
`/mnt/tests/kernel/misc/ptrace-testsuite/ptrace-tests'



Re: ptrace tests failed to compile on i686

2009-12-05 Thread CAI Qian
OK, I think I should not use ./configure --with-biarch on i686. Sorry for the 
noise.