All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2009-11-10  9:38 liubo
  2009-11-11  1:28 ` liubo
  2009-11-11  4:33 ` Mike Frysinger
  0 siblings, 2 replies; 34+ messages in thread
From: liubo @ 2009-11-10  9:38 UTC (permalink / raw)
  To: ltp-list

1) rt_sigaction
    "sigaction" has the structure:
 
 struct sigaction {
         __sighandler_t sa_handler;
         unsigned long sa_flags;
  #ifdef SA_RESTORER
          __sigrestore_t sa_restorer;
  #endif
          sigset_t sa_mask;               /* mask last for extensibility */
 };

    However, on arch x86_64, if we directly get to call rt_sigaction,
the argument "sa_restorer" will not be fulfilled, and this will lead
 to segment fault.
    on arch x86_64, if sa_restorer is not set, kernel will lead to segment fault. 
In other arch, if sa_restorer is not set, kernel can do the correct work.
    To avoid this segment fault, we use glibc function
"int sigaction(...);" instead, which can fulfill the argument "sa_restorer".

2) rt_sigprocmask
    This failure contains two aspects,
the first is the segment fault as described in 1),
the second is that testcase uses a unknown signal 33 for test,
and this will lead sigaction cannot bind signal 33 to the action.

    So, we attempt to use a known signal instead, such as 34.

This patch fixed these failures.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |    4 ++++
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   12 ++++++++----
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |    4 ++++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 27af970..1522ac4 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -154,7 +154,11 @@ set_handler(int sig, int sig_to_mask, int mask_flags)
                 sa.sa_flags = mask_flags;
                 sigemptyset(&sa.sa_mask);
                 sigaddset(&sa.sa_mask, sig_to_mask);
+		#ifndef __x86_64__
                 TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
+		#else
+		TEST(sigaction(sig, &sa, &oldaction));
+		#endif
         if (TEST_RETURN == 0) {
                 return 0;
         } else {
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..31258e9 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -154,7 +154,7 @@ int main(int ac, char **av) {
                         	cleanup();
 				tst_exit();
 			}
-			TEST(sigaddset(&set, 33));
+			TEST(sigaddset(&set, 34));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
@@ -163,7 +163,11 @@ int main(int ac, char **av) {
 			
 			/* call rt_sigaction() */
 			act.sa_handler = sig_handler;
-                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
+			#ifndef __x86_64__
+                        TEST(syscall(__NR_rt_sigaction, 34, &act, &oact, 8));
+			#else
+			TEST(sigaction(34, &act, &oact));
+			#endif
 			if(TEST_RETURN != 0){
 				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
@@ -178,7 +182,7 @@ int main(int ac, char **av) {
 			}
 			
 			else {
-				TEST(kill(getpid(), 33));
+				TEST(kill(getpid(), 34));
 				if(TEST_RETURN != 0){
 					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         		cleanup();
@@ -198,7 +202,7 @@ int main(int ac, char **av) {
                         			cleanup();
 						tst_exit();
 					}
-					TEST(sigismember(&oset, 33));
+					TEST(sigismember(&oset, 34));
 					if(TEST_RETURN == 0 ){
 						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         			cleanup();
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..6132622 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -142,7 +142,11 @@ int main(int ac, char **av) {
 			struct sigaction act, oact;
 		        act.sa_handler = sig_handler;
 			
+			#ifndef __x86_64__
 			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
+			#else
+			TEST(sigaction(SIGALRM, &act, &oact));
+			#endif
 			if(TEST_RETURN == -1){
 		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
 				cleanup();
-- 
1.6.2.2

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-10  9:38 [LTP] [PATCH] syscalls: fix some failure on arch X86_64 liubo
@ 2009-11-11  1:28 ` liubo
  2009-11-11  4:14   ` Garrett Cooper
  2009-11-11  4:33 ` Mike Frysinger
  1 sibling, 1 reply; 34+ messages in thread
From: liubo @ 2009-11-11  1:28 UTC (permalink / raw)
  To: ltp-list, maknayak

Hi,
On 11/10/2009 05:38 PM, liubo wrote:
> 1) rt_sigaction
>     "sigaction" has the structure:
>  
>  struct sigaction {
>          __sighandler_t sa_handler;
>          unsigned long sa_flags;
>   #ifdef SA_RESTORER
>           __sigrestore_t sa_restorer;
>   #endif
>           sigset_t sa_mask;               /* mask last for extensibility */
>  };
>
>     However, on arch x86_64, if we directly get to call rt_sigaction,
> the argument "sa_restorer" will not be fulfilled, and this will lead
>  to segment fault.
>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment fault. 
> In other arch, if sa_restorer is not set, kernel can do the correct work.
>     To avoid this segment fault, we use glibc function
> "int sigaction(...);" instead, which can fulfill the argument "sa_restorer".
>
> 2) rt_sigprocmask
>     This failure contains two aspects,
> the first is the segment fault as described in 1),
> the second is that testcase uses a unknown signal 33 for test,
> and this will lead sigaction cannot bind signal 33 to the action.
>
>     So, we attempt to use a known signal instead, such as 34.
>
>   

  I am sure signal 32 and 33 cannot be used in rt_sigprocmask test
  on arch x86_64, but I'm not sure which signal else should be used
  here, Is there anyone can provide suggestions?

> This patch fixed these failures.
>
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
>
> ---
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |    4 ++++
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   12 ++++++++----
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |    4 ++++
>  3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index 27af970..1522ac4 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -154,7 +154,11 @@ set_handler(int sig, int sig_to_mask, int mask_flags)
>                  sa.sa_flags = mask_flags;
>                  sigemptyset(&sa.sa_mask);
>                  sigaddset(&sa.sa_mask, sig_to_mask);
> +		#ifndef __x86_64__
>                  TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> +		#else
> +		TEST(sigaction(sig, &sa, &oldaction));
> +		#endif
>          if (TEST_RETURN == 0) {
>                  return 0;
>          } else {
> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> index 6398a28..31258e9 100644
> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> @@ -154,7 +154,7 @@ int main(int ac, char **av) {
>                          	cleanup();
>  				tst_exit();
>  			}
> -			TEST(sigaddset(&set, 33));
> +			TEST(sigaddset(&set, 34));
>  			if(TEST_RETURN == -1){
>  				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          	cleanup();
> @@ -163,7 +163,11 @@ int main(int ac, char **av) {
>  			
>  			/* call rt_sigaction() */
>  			act.sa_handler = sig_handler;
> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
> +			#ifndef __x86_64__
> +                        TEST(syscall(__NR_rt_sigaction, 34, &act, &oact, 8));
> +			#else
> +			TEST(sigaction(34, &act, &oact));
> +			#endif
>  			if(TEST_RETURN != 0){
>  				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          	cleanup();
> @@ -178,7 +182,7 @@ int main(int ac, char **av) {
>  			}
>  			
>  			else {
> -				TEST(kill(getpid(), 33));
> +				TEST(kill(getpid(), 34));
>  				if(TEST_RETURN != 0){
>  					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          		cleanup();
> @@ -198,7 +202,7 @@ int main(int ac, char **av) {
>                          			cleanup();
>  						tst_exit();
>  					}
> -					TEST(sigismember(&oset, 33));
> +					TEST(sigismember(&oset, 34));
>  					if(TEST_RETURN == 0 ){
>  						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          			cleanup();
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index 416a7c9..6132622 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -142,7 +142,11 @@ int main(int ac, char **av) {
>  			struct sigaction act, oact;
>  		        act.sa_handler = sig_handler;
>  			
> +			#ifndef __x86_64__
>  			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
> +			#else
> +			TEST(sigaction(SIGALRM, &act, &oact));
> +			#endif
>  			if(TEST_RETURN == -1){
>  		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>  				cleanup();
>   


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-11  1:28 ` liubo
@ 2009-11-11  4:14   ` Garrett Cooper
  2009-11-11  4:30     ` Wei Yongjun
  2009-11-11  5:22     ` liubo
  0 siblings, 2 replies; 34+ messages in thread
From: Garrett Cooper @ 2009-11-11  4:14 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list, maknayak

On Tue, Nov 10, 2009 at 5:28 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
> Hi,
> On 11/10/2009 05:38 PM, liubo wrote:
>> 1) rt_sigaction
>>     "sigaction" has the structure:
>>
>>  struct sigaction {
>>          __sighandler_t sa_handler;
>>          unsigned long sa_flags;
>>   #ifdef SA_RESTORER
>>           __sigrestore_t sa_restorer;
>>   #endif
>>           sigset_t sa_mask;               /* mask last for extensibility */
>>  };

Not true... from glibc 2.9 / gentoo-sources-2.6.30-r4:

#ifdef __i386__
/* Here we must cater to libcs that poke about in kernel headers.  */

struct sigaction {
        union {
          __sighandler_t _sa_handler;
          void (*_sa_sigaction)(int, struct siginfo *, void *);
        } _u;
        sigset_t sa_mask;
        unsigned long sa_flags;
        void (*sa_restorer)(void);
};

/* ... */

#else

struct sigaction {
        __sighandler_t sa_handler;
        unsigned long sa_flags;
        __sigrestore_t sa_restorer;
        sigset_t sa_mask;               /* mask last for extensibility */
};

#endif

What do the manpages say is required for rt_sigaction to function on
your machine? Mine just says:

SYNOPSIS
       #include <signal.h>

       int sigaction(int signum, const struct sigaction *act,
                     struct sigaction *oldact);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE

>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>  to segment fault.
>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment fault.
>> In other arch, if sa_restorer is not set, kernel can do the correct work.
>>     To avoid this segment fault, we use glibc function
>> "int sigaction(...);" instead, which can fulfill the argument "sa_restorer".
>>
>> 2) rt_sigprocmask
>>     This failure contains two aspects,
>> the first is the segment fault as described in 1),
>> the second is that testcase uses a unknown signal 33 for test,
>> and this will lead sigaction cannot bind signal 33 to the action.
>>
>>     So, we attempt to use a known signal instead, such as 34.
>>
>>
>
>  I am sure signal 32 and 33 cannot be used in rt_sigprocmask test
>  on arch x86_64, but I'm not sure which signal else should be used
>  here, Is there anyone can provide suggestions?

RT signals are all signals above SIGRTMIN (typically 32+, but not
always), up to SIGRTMAX (usually 64, but on mips it's 128). So... why
is setting the signal number to anywhere between SIGRTMIN and SIGRTMAX
unacceptable?

Thanks,
-Garrett

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-11  4:14   ` Garrett Cooper
@ 2009-11-11  4:30     ` Wei Yongjun
  2009-11-11  5:22     ` liubo
  1 sibling, 0 replies; 34+ messages in thread
From: Wei Yongjun @ 2009-11-11  4:30 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, maknayak


Garrett Cooper wrote:
> On Tue, Nov 10, 2009 at 5:28 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> Hi,
>> On 11/10/2009 05:38 PM, liubo wrote:
>>     
>>> 1) rt_sigaction
>>>     "sigaction" has the structure:
>>>
>>>  struct sigaction {
>>>          __sighandler_t sa_handler;
>>>          unsigned long sa_flags;
>>>   #ifdef SA_RESTORER
>>>           __sigrestore_t sa_restorer;
>>>   #endif
>>>           sigset_t sa_mask;               /* mask last for extensibility */
>>>  };
>>>       
>
> Not true... from glibc 2.9 / gentoo-sources-2.6.30-r4:
>
> #ifdef __i386__
> /* Here we must cater to libcs that poke about in kernel headers.  */
>
> struct sigaction {
>         union {
>           __sighandler_t _sa_handler;
>           void (*_sa_sigaction)(int, struct siginfo *, void *);
>         } _u;
>         sigset_t sa_mask;
>         unsigned long sa_flags;
>         void (*sa_restorer)(void);
> };
>
> /* ... */
>
> #else
>
> struct sigaction {
>         __sighandler_t sa_handler;
>         unsigned long sa_flags;
>         __sigrestore_t sa_restorer;
>         sigset_t sa_mask;               /* mask last for extensibility */
> };
>
> #endif
>
> What do the manpages say is required for rt_sigaction to function on
> your machine? Mine just says:
>
> SYNOPSIS
>        #include <signal.h>
>
>        int sigaction(int signum, const struct sigaction *act,
>                      struct sigaction *oldact);
>
>    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
>
>        sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
>
>   
>>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>>  to segment fault.
>>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment fault.
>>> In other arch, if sa_restorer is not set, kernel can do the correct work.
>>>     To avoid this segment fault, we use glibc function
>>> "int sigaction(...);" instead, which can fulfill the argument "sa_restorer".
>>>
>>> 2) rt_sigprocmask
>>>     This failure contains two aspects,
>>> the first is the segment fault as described in 1),
>>> the second is that testcase uses a unknown signal 33 for test,
>>> and this will lead sigaction cannot bind signal 33 to the action.
>>>
>>>     So, we attempt to use a known signal instead, such as 34.
>>>
>>>
>>>       
>>  I am sure signal 32 and 33 cannot be used in rt_sigprocmask test
>>  on arch x86_64, but I'm not sure which signal else should be used
>>  here, Is there anyone can provide suggestions?
>>     
>
> RT signals are all signals above SIGRTMIN (typically 32+, but not
> always), up to SIGRTMAX (usually 64, but on mips it's 128). So... why
> is setting the signal number to anywhere between SIGRTMIN and SIGRTMAX
> unacceptable?
>   

Not sure why signal 32 and 33 are not accepted by sigaction() on
x86_64, the acceptable signal from 34 to SIGRTMAX, maybe it's the
glibc's BUG? since I had not found the source code of x86_64
sigaction(), I can not check this. It is very strange.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-10  9:38 [LTP] [PATCH] syscalls: fix some failure on arch X86_64 liubo
  2009-11-11  1:28 ` liubo
@ 2009-11-11  4:33 ` Mike Frysinger
  2009-11-11  5:03   ` Wei Yongjun
  1 sibling, 1 reply; 34+ messages in thread
From: Mike Frysinger @ 2009-11-11  4:33 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1: Type: Text/Plain, Size: 1466 bytes --]

On Tuesday 10 November 2009 04:38:30 liubo wrote:
> 1) rt_sigaction
>     "sigaction" has the structure:
> 
>  struct sigaction {
>          __sighandler_t sa_handler;
>          unsigned long sa_flags;
>   #ifdef SA_RESTORER
>           __sigrestore_t sa_restorer;
>   #endif
>           sigset_t sa_mask;               /* mask last for extensibility */
>  };
> 
>     However, on arch x86_64, if we directly get to call rt_sigaction,
> the argument "sa_restorer" will not be fulfilled, and this will lead
>  to segment fault.
>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>  work. To avoid this segment fault, we use glibc function
> "int sigaction(...);" instead, which can fulfill the argument
>  "sa_restorer".

which defeats the purpose of the test.  there is no guarantee that the C 
library sigaction function is implemented via the __NR_rt_sigaction syscall.

> 2) rt_sigprocmask
>     This failure contains two aspects,
> the first is the segment fault as described in 1),
> the second is that testcase uses a unknown signal 33 for test,
> and this will lead sigaction cannot bind signal 33 to the action.
> 
>     So, we attempt to use a known signal instead, such as 34.

which is just as bogus and unportable.  if the test needs a real time signal, 
it should leverage the sigrtmin...sigrtmax defines.
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-11  4:33 ` Mike Frysinger
@ 2009-11-11  5:03   ` Wei Yongjun
  2009-11-16  8:13     ` Subrata Modak
  0 siblings, 1 reply; 34+ messages in thread
From: Wei Yongjun @ 2009-11-11  5:03 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list



Mike Frysinger wrote:
> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>   
>> 1) rt_sigaction
>>     "sigaction" has the structure:
>>
>>  struct sigaction {
>>          __sighandler_t sa_handler;
>>          unsigned long sa_flags;
>>   #ifdef SA_RESTORER
>>           __sigrestore_t sa_restorer;
>>   #endif
>>           sigset_t sa_mask;               /* mask last for extensibility */
>>  };
>>
>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>  to segment fault.
>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>  work. To avoid this segment fault, we use glibc function
>> "int sigaction(...);" instead, which can fulfill the argument
>>  "sa_restorer".
>>     
>
> which defeats the purpose of the test.  there is no guarantee that the C 
> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>   

In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
directly, we must fill the sa_restorer and set the RESTORER flag to
sa_mask. If we do not set the sa_restorer, kill will always cause
segment fault.

>   
>> 2) rt_sigprocmask
>>     This failure contains two aspects,
>> the first is the segment fault as described in 1),
>> the second is that testcase uses a unknown signal 33 for test,
>> and this will lead sigaction cannot bind signal 33 to the action.
>>
>>     So, we attempt to use a known signal instead, such as 34.
>>     
>
> which is just as bogus and unportable.  if the test needs a real time signal, 
> it should leverage the sigrtmin...sigrtmax defines.
> -mike
>   
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>   

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-11  4:14   ` Garrett Cooper
  2009-11-11  4:30     ` Wei Yongjun
@ 2009-11-11  5:22     ` liubo
  1 sibling, 0 replies; 34+ messages in thread
From: liubo @ 2009-11-11  5:22 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, maknayak


[-- Attachment #1.1: Type: text/plain, Size: 3507 bytes --]

On 11/11/2009 12:14 PM, Garrett Cooper wrote:
> On Tue, Nov 10, 2009 at 5:28 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> Hi,
>> On 11/10/2009 05:38 PM, liubo wrote:
>>     
>>> 1) rt_sigaction
>>>     "sigaction" has the structure:
>>>
>>>  struct sigaction {
>>>          __sighandler_t sa_handler;
>>>          unsigned long sa_flags;
>>>   #ifdef SA_RESTORER
>>>           __sigrestore_t sa_restorer;
>>>   #endif
>>>           sigset_t sa_mask;               /* mask last for extensibility */
>>>  };
>>>       
>
> Not true... from glibc 2.9 / gentoo-sources-2.6.30-r4:
>
> #ifdef __i386__
> /* Here we must cater to libcs that poke about in kernel headers.  */
>
> struct sigaction {
>         union {
>           __sighandler_t _sa_handler;
>           void (*_sa_sigaction)(int, struct siginfo *, void *);
>         } _u;
>         sigset_t sa_mask;
>         unsigned long sa_flags;
>         void (*sa_restorer)(void);
> };
>
> /* ... */
>
> #else
>
> struct sigaction {
>         __sighandler_t sa_handler;
>         unsigned long sa_flags;
>         __sigrestore_t sa_restorer;
>         sigset_t sa_mask;               /* mask last for extensibility */
> };
>
> #endif
>
> What do the manpages say is required for rt_sigaction to function on
> your machine? Mine just says:
>
> SYNOPSIS
>        #include <signal.h>
>
>        int sigaction(int signum, const struct sigaction *act,
>                      struct sigaction *oldact);
>
>    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
>
>        sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
>
>   

On my machine,

man sigaction
===========
NAME
       sigaction - examine and change a signal action

SYNOPSIS
       #include <signal.h>

       int sigaction(int signum, const struct sigaction *act,
                     struct sigaction *oldact);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
===========
The same as you.

BTW, I got the sigaction from kernel code instead of glibc.

And I use "strace" to investigate, it shows that function
sigaction do call rt_sigaction on my x86_64 arch.


>>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>>  to segment fault.
>>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment fault.
>>> In other arch, if sa_restorer is not set, kernel can do the correct work.
>>>     To avoid this segment fault, we use glibc function
>>> "int sigaction(...);" instead, which can fulfill the argument "sa_restorer".
>>>
>>> 2) rt_sigprocmask
>>>     This failure contains two aspects,
>>> the first is the segment fault as described in 1),
>>> the second is that testcase uses a unknown signal 33 for test,
>>> and this will lead sigaction cannot bind signal 33 to the action.
>>>
>>>     So, we attempt to use a known signal instead, such as 34.
>>>
>>>
>>>       
>>  I am sure signal 32 and 33 cannot be used in rt_sigprocmask test
>>  on arch x86_64, but I'm not sure which signal else should be used
>>  here, Is there anyone can provide suggestions?
>>     
>
> RT signals are all signals above SIGRTMIN (typically 32+, but not
> always), up to SIGRTMAX (usually 64, but on mips it's 128). So... why
> is setting the signal number to anywhere between SIGRTMIN and SIGRTMAX
> unacceptable?
>
> Thanks,
> -Garrett
>
>
>   


[-- Attachment #1.2: Type: text/html, Size: 4769 bytes --]

[-- Attachment #2: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-11  5:03   ` Wei Yongjun
@ 2009-11-16  8:13     ` Subrata Modak
  2009-11-16  8:53       ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Subrata Modak @ 2009-11-16  8:13 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list, Mike Frysinger

Liubo,

Are you sending an updated patch post this discussion ?

Regards--
Subrata

On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote: 
> 
> Mike Frysinger wrote:
> > On Tuesday 10 November 2009 04:38:30 liubo wrote:
> >   
> >> 1) rt_sigaction
> >>     "sigaction" has the structure:
> >>
> >>  struct sigaction {
> >>          __sighandler_t sa_handler;
> >>          unsigned long sa_flags;
> >>   #ifdef SA_RESTORER
> >>           __sigrestore_t sa_restorer;
> >>   #endif
> >>           sigset_t sa_mask;               /* mask last for extensibility */
> >>  };
> >>
> >>     However, on arch x86_64, if we directly get to call rt_sigaction,
> >> the argument "sa_restorer" will not be fulfilled, and this will lead
> >>  to segment fault.
> >>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
> >>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
> >>  work. To avoid this segment fault, we use glibc function
> >> "int sigaction(...);" instead, which can fulfill the argument
> >>  "sa_restorer".
> >>     
> >
> > which defeats the purpose of the test.  there is no guarantee that the C 
> > library sigaction function is implemented via the __NR_rt_sigaction syscall.
> >   
> 
> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
> directly, we must fill the sa_restorer and set the RESTORER flag to
> sa_mask. If we do not set the sa_restorer, kill will always cause
> segment fault.
> 
> >   
> >> 2) rt_sigprocmask
> >>     This failure contains two aspects,
> >> the first is the segment fault as described in 1),
> >> the second is that testcase uses a unknown signal 33 for test,
> >> and this will lead sigaction cannot bind signal 33 to the action.
> >>
> >>     So, we attempt to use a known signal instead, such as 34.
> >>     
> >
> > which is just as bogus and unportable.  if the test needs a real time signal, 
> > it should leverage the sigrtmin...sigrtmax defines.
> > -mike
> >   
> > ------------------------------------------------------------------------
> >
> > ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> > trial. Simplify your report design, integration and deployment - and focus on 
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Ltp-list mailing list
> > Ltp-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/ltp-list
> >   
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-16  8:13     ` Subrata Modak
@ 2009-11-16  8:53       ` liubo
  2009-11-26 11:11         ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2009-11-16  8:53 UTC (permalink / raw)
  To: subrata; +Cc: ltp-list, Mike Frysinger


[-- Attachment #1.1: Type: text/plain, Size: 3489 bytes --]

Hi, Subrata,
On 11/16/2009 04:13 PM, Subrata Modak wrote:
> Liubo,
>
> Are you sending an updated patch post this discussion ?
>
>   
Yes, I'll resend a updated patch about these rt_sigs.

Regards--
Liubo

> Regards--
> Subrata
>
> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote: 
>   
>> Mike Frysinger wrote:
>>     
>>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>>   
>>>       
>>>> 1) rt_sigaction
>>>>     "sigaction" has the structure:
>>>>
>>>>  struct sigaction {
>>>>          __sighandler_t sa_handler;
>>>>          unsigned long sa_flags;
>>>>   #ifdef SA_RESTORER
>>>>           __sigrestore_t sa_restorer;
>>>>   #endif
>>>>           sigset_t sa_mask;               /* mask last for extensibility */
>>>>  };
>>>>
>>>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>>>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>>>  to segment fault.
>>>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>>>  work. To avoid this segment fault, we use glibc function
>>>> "int sigaction(...);" instead, which can fulfill the argument
>>>>  "sa_restorer".
>>>>     
>>>>         
>>> which defeats the purpose of the test.  there is no guarantee that the C 
>>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>>   
>>>       
>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>> directly, we must fill the sa_restorer and set the RESTORER flag to
>> sa_mask. If we do not set the sa_restorer, kill will always cause
>> segment fault.
>>
>>     
>>>   
>>>       
>>>> 2) rt_sigprocmask
>>>>     This failure contains two aspects,
>>>> the first is the segment fault as described in 1),
>>>> the second is that testcase uses a unknown signal 33 for test,
>>>> and this will lead sigaction cannot bind signal 33 to the action.
>>>>
>>>>     So, we attempt to use a known signal instead, such as 34.
>>>>     
>>>>         
>>> which is just as bogus and unportable.  if the test needs a real time signal, 
>>> it should leverage the sigrtmin...sigrtmax defines.
>>> -mike
>>>   
>>> ------------------------------------------------------------------------
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
>>> trial. Simplify your report design, integration and deployment - and focus on 
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Ltp-list mailing list
>>> Ltp-list@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>>>   
>>>       
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
>> trial. Simplify your report design, integration and deployment - and focus on 
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Ltp-list mailing list
>> Ltp-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>>     
>
>
>
>   


[-- Attachment #1.2: Type: text/html, Size: 4652 bytes --]

[-- Attachment #2: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-16  8:53       ` liubo
@ 2009-11-26 11:11         ` Garrett Cooper
  2009-11-27  5:33           ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2009-11-26 11:11 UTC (permalink / raw)
  To: liubo; +Cc: Mike Frysinger, ltp-list

On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
> Hi, Subrata,
> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>
> Liubo,
>
> Are you sending an updated patch post this discussion ?
>
>
>
> Yes, I'll resend a updated patch about these rt_sigs.
>
> Regards--
> Liubo
>
> Regards--
> Subrata
>
> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>
>
> Mike Frysinger wrote:
>
>
> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>
>
>
> 1) rt_sigaction
>     "sigaction" has the structure:
>
>  struct sigaction {
>          __sighandler_t sa_handler;
>          unsigned long sa_flags;
>   #ifdef SA_RESTORER
>           __sigrestore_t sa_restorer;
>   #endif
>           sigset_t sa_mask;               /* mask last for extensibility */
>  };
>
>     However, on arch x86_64, if we directly get to call rt_sigaction,
> the argument "sa_restorer" will not be fulfilled, and this will lead
>  to segment fault.
>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>  work. To avoid this segment fault, we use glibc function
> "int sigaction(...);" instead, which can fulfill the argument
>  "sa_restorer".
>
>
>
> which defeats the purpose of the test.  there is no guarantee that the C
> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>
>
>
> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
> directly, we must fill the sa_restorer and set the RESTORER flag to
> sa_mask. If we do not set the sa_restorer, kill will always cause
> segment fault.
>
>
>
>
>
>
> 2) rt_sigprocmask
>     This failure contains two aspects,
> the first is the segment fault as described in 1),
> the second is that testcase uses a unknown signal 33 for test,
> and this will lead sigaction cannot bind signal 33 to the action.
>
>     So, we attempt to use a known signal instead, such as 34.
>
>
>
> which is just as bogus and unportable.  if the test needs a real time
> signal,
> it should leverage the sigrtmin...sigrtmax defines.
> -mike

I see what you mean about this testcase segfaulting now.

I've done some exploring, and while sigaction does map to rt_sigaction
on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.

Furthermore, the problem is actually being caused by the fact that
we're not even calling sigaddset properly!

gcooper@orangebox
/scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
./rt_sigaction01
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...
(gdb) c
The program is not being run.
(gdb) r
Starting program:
/scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
thread:20
[Thread debugging using libthread_db enabled]
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument
rt_sigaction01    0  TINFO  :  sigaddset(..) failed
rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
TEST_ERRNO=EINVAL(22): Invalid argument

So, the test needs fixing, anyhow. After I fixed it, the test still
segfaulted >:( --

gcooper@orangebox
/scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
./rt_sigaction01
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...
(gdb) r
Starting program:
/scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
thread:20
[Thread debugging using libthread_db enabled]
rt_sigaction01    0  TINFO  :  signal: 34
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
[New Thread 0x7fdd451d66f0 (LWP 31927)]

Program received signal SIG34, Real-time event 34.
[Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
0x00007fdd448944f7 in kill () from /lib/libc.so.6
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00007fdd448944f7 in kill () from /lib/libc.so.6

So I tried to do some digging. glibc 2.8-20080602 does the following
for alpha, i386, and sysv:

      result = INLINE_SYSCALL (rt_sigaction, 4,
                               sig, act ? __ptrvalue (&kact) : NULL,
                               oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);

The kernel code for rt_sigaction in kernel/signal.c is as follows:

#ifdef __ARCH_WANT_SYS_RT_SIGACTION
SYSCALL_DEFINE4(rt_sigaction, int, sig,
                const struct sigaction __user *, act,
                struct sigaction __user *, oact,
                size_t, sigsetsize)
{
        struct k_sigaction new_sa, old_sa;
        int ret = -EINVAL;

        /* XXX: Don't preclude handling different sized sigset_t's.  */
        if (sigsetsize != sizeof(sigset_t))
                goto out;

        if (act) {
                if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
                        return -EFAULT;
        }

        ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);

        if (!ret && oact) {
                if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
                        return -EFAULT;
        }
out:
        return ret;
}

This just blows my mind because rt_sigaction is just calling
do_sigaction, which is the same code as sigaction AFAICT, apart from
the fact that rt_sigaction completely disregards sa_restorer on some
architectures because it's obsolete, and requires the end-user to
specify a signal mask set (here's mips' version, which wasn't the same
as i386's version -- i386 had the old sa_restorer code):

SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
        struct sigaction __user *, oact)
{
        struct k_sigaction new_ka, old_ka;
        int ret;
        int err = 0;

        if (act) {
                old_sigset_t mask;

                if (!access_ok(VERIFY_READ, act, sizeof(*act)))
                        return -EFAULT;
                err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
                err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
                err |= __get_user(mask, &act->sa_mask.sig[0]);
                if (err)
                        return -EFAULT;

                siginitset(&new_ka.sa.sa_mask, mask);
        }

        ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);

        if (!ret && oact) {
                if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
                        return -EFAULT;
                err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
                err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
                err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
                err |= __put_user(0, &oact->sa_mask.sig[1]);
                err |= __put_user(0, &oact->sa_mask.sig[2]);
                err |= __put_user(0, &oact->sa_mask.sig[3]);
                if (err)
                        return -EFAULT;
        }

        return ret;
}

I dunno -- maybe someone else can read the kernel code better than me,
but it looks like there's zero real value to the rt_sigaction
testcases, because it can be covered by sigaction...

Thanks,
-Garrett

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-26 11:11         ` Garrett Cooper
@ 2009-11-27  5:33           ` liubo
  2009-11-27  6:49             ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2009-11-27  5:33 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: Mike Frysinger, ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 12575 bytes --]

Hi, Garrett
On 11/26/2009 07:11 PM, Garrett Cooper wrote:
> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> Hi, Subrata,
>> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>>
>> Liubo,
>>
>> Are you sending an updated patch post this discussion ?
>>
>>
>>
>> Yes, I'll resend a updated patch about these rt_sigs.
>>
>> Regards--
>> Liubo
>>
>> Regards--
>> Subrata
>>
>> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>>
>>
>> Mike Frysinger wrote:
>>
>>
>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>
>>
>>
>> 1) rt_sigaction
>>     "sigaction" has the structure:
>>
>>  struct sigaction {
>>          __sighandler_t sa_handler;
>>          unsigned long sa_flags;
>>   #ifdef SA_RESTORER
>>           __sigrestore_t sa_restorer;
>>   #endif
>>           sigset_t sa_mask;               /* mask last for extensibility */
>>  };
>>
>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>  to segment fault.
>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>  work. To avoid this segment fault, we use glibc function
>> "int sigaction(...);" instead, which can fulfill the argument
>>  "sa_restorer".
>>
>>
>>
>> which defeats the purpose of the test.  there is no guarantee that the C
>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>
>>
>>
>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>> directly, we must fill the sa_restorer and set the RESTORER flag to
>> sa_mask. If we do not set the sa_restorer, kill will always cause
>> segment fault.
>>
>>
>>
>>
>>
>>
>> 2) rt_sigprocmask
>>     This failure contains two aspects,
>> the first is the segment fault as described in 1),
>> the second is that testcase uses a unknown signal 33 for test,
>> and this will lead sigaction cannot bind signal 33 to the action.
>>
>>     So, we attempt to use a known signal instead, such as 34.
>>
>>
>>
>> which is just as bogus and unportable.  if the test needs a real time
>> signal,
>> it should leverage the sigrtmin...sigrtmax defines.
>> -mike
>>     
>
> I see what you mean about this testcase segfaulting now.
>
> I've done some exploring, and while sigaction does map to rt_sigaction
> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>
> Furthermore, the problem is actually being caused by the fact that
> we're not even calling sigaddset properly!
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) c
> The program is not being run.
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
>
> So, the test needs fixing, anyhow. After I fixed it, the test still
> segfaulted >:( --
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01    0  TINFO  :  signal: 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>
> Program received signal SIG34, Real-time event 34.
> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
> (gdb) c
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>
> So I tried to do some digging. glibc 2.8-20080602 does the following
> for alpha, i386, and sysv:
>
>       result = INLINE_SYSCALL (rt_sigaction, 4,
>                                sig, act ? __ptrvalue (&kact) : NULL,
>                                oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
>
> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>
> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>                 const struct sigaction __user *, act,
>                 struct sigaction __user *, oact,
>                 size_t, sigsetsize)
> {
>         struct k_sigaction new_sa, old_sa;
>         int ret = -EINVAL;
>
>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>         if (sigsetsize != sizeof(sigset_t))
>                 goto out;
>
>         if (act) {
>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>                         return -EFAULT;
>         }
>
>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
>
>         if (!ret && oact) {
>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>                         return -EFAULT;
>         }
> out:
>         return ret;
> }
>
> This just blows my mind because rt_sigaction is just calling
> do_sigaction, which is the same code as sigaction AFAICT, apart from
> the fact that rt_sigaction completely disregards sa_restorer on some
> architectures because it's obsolete, and requires the end-user to
> specify a signal mask set (here's mips' version, which wasn't the same
> as i386's version -- i386 had the old sa_restorer code):
>
> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>         struct sigaction __user *, oact)
> {
>         struct k_sigaction new_ka, old_ka;
>         int ret;
>         int err = 0;
>
>         if (act) {
>                 old_sigset_t mask;
>
>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>                         return -EFAULT;
>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>                 if (err)
>                         return -EFAULT;
>
>                 siginitset(&new_ka.sa.sa_mask, mask);
>         }
>
>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
>
>         if (!ret && oact) {
>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>                         return -EFAULT;
>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>                 err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>                 if (err)
>                         return -EFAULT;
>         }
>
>         return ret;
> }
>
> I dunno -- maybe someone else can read the kernel code better than me,
> but it looks like there's zero real value to the rt_sigaction
> testcases, because it can be covered by sigaction...
>
>   

    We just tell guys who use these testcases on arch x86_64 that
    "Syscall rt_sigaction cannot be called directly on arch x86_64.",
    can we?
   
> Thanks,
> -Garrett
>
>
>   


[-- Attachment #1.2: Type: text/html, Size: 12958 bytes --]

[-- Attachment #2: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-27  5:33           ` liubo
@ 2009-11-27  6:49             ` Garrett Cooper
  2009-11-27  8:50               ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2009-11-27  6:49 UTC (permalink / raw)
  To: liubo; +Cc: Mike Frysinger, ltp-list

On Thu, Nov 26, 2009 at 9:33 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
> Hi, Garrett
> On 11/26/2009 07:11 PM, Garrett Cooper wrote:
>
> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>
>
> Hi, Subrata,
> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>
> Liubo,
>
> Are you sending an updated patch post this discussion ?
>
>
>
> Yes, I'll resend a updated patch about these rt_sigs.
>
> Regards--
> Liubo
>
> Regards--
> Subrata
>
> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>
>
> Mike Frysinger wrote:
>
>
> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>
>
>
> 1) rt_sigaction
>     "sigaction" has the structure:
>
>  struct sigaction {
>          __sighandler_t sa_handler;
>          unsigned long sa_flags;
>   #ifdef SA_RESTORER
>           __sigrestore_t sa_restorer;
>   #endif
>           sigset_t sa_mask;               /* mask last for extensibility */
>  };
>
>     However, on arch x86_64, if we directly get to call rt_sigaction,
> the argument "sa_restorer" will not be fulfilled, and this will lead
>  to segment fault.
>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>  work. To avoid this segment fault, we use glibc function
> "int sigaction(...);" instead, which can fulfill the argument
>  "sa_restorer".
>
>
>
> which defeats the purpose of the test.  there is no guarantee that the C
> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>
>
>
> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
> directly, we must fill the sa_restorer and set the RESTORER flag to
> sa_mask. If we do not set the sa_restorer, kill will always cause
> segment fault.
>
>
>
>
>
>
> 2) rt_sigprocmask
>     This failure contains two aspects,
> the first is the segment fault as described in 1),
> the second is that testcase uses a unknown signal 33 for test,
> and this will lead sigaction cannot bind signal 33 to the action.
>
>     So, we attempt to use a known signal instead, such as 34.
>
>
>
> which is just as bogus and unportable.  if the test needs a real time
> signal,
> it should leverage the sigrtmin...sigrtmax defines.
> -mike
>
>
> I see what you mean about this testcase segfaulting now.
>
> I've done some exploring, and while sigaction does map to rt_sigaction
> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>
> Furthermore, the problem is actually being caused by the fact that
> we're not even calling sigaddset properly!
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) c
> The program is not being run.
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
>
> So, the test needs fixing, anyhow. After I fixed it, the test still
> segfaulted >:( --
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01    0  TINFO  :  signal: 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>
> Program received signal SIG34, Real-time event 34.
> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
> (gdb) c
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>
> So I tried to do some digging. glibc 2.8-20080602 does the following
> for alpha, i386, and sysv:
>
>       result = INLINE_SYSCALL (rt_sigaction, 4,
>                                sig, act ? __ptrvalue (&kact) : NULL,
>                                oact ? __ptrvalue (&koact) : NULL, _NSIG /
> 8);
>
> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>
> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>                 const struct sigaction __user *, act,
>                 struct sigaction __user *, oact,
>                 size_t, sigsetsize)
> {
>         struct k_sigaction new_sa, old_sa;
>         int ret = -EINVAL;
>
>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>         if (sigsetsize != sizeof(sigset_t))
>                 goto out;
>
>         if (act) {
>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>                         return -EFAULT;
>         }
>
>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa :
> NULL);
>
>         if (!ret && oact) {
>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>                         return -EFAULT;
>         }
> out:
>         return ret;
> }
>
> This just blows my mind because rt_sigaction is just calling
> do_sigaction, which is the same code as sigaction AFAICT, apart from
> the fact that rt_sigaction completely disregards sa_restorer on some
> architectures because it's obsolete, and requires the end-user to
> specify a signal mask set (here's mips' version, which wasn't the same
> as i386's version -- i386 had the old sa_restorer code):
>
> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>         struct sigaction __user *, oact)
> {
>         struct k_sigaction new_ka, old_ka;
>         int ret;
>         int err = 0;
>
>         if (act) {
>                 old_sigset_t mask;
>
>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>                         return -EFAULT;
>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>                 if (err)
>                         return -EFAULT;
>
>                 siginitset(&new_ka.sa.sa_mask, mask);
>         }
>
>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka :
> NULL);
>
>         if (!ret && oact) {
>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>                         return -EFAULT;
>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>                 err |= __put_user(old_ka.sa.sa_mask.sig[0],
> oact->sa_mask.sig);
>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>                 if (err)
>                         return -EFAULT;
>         }
>
>         return ret;
> }
>
> I dunno -- maybe someone else can read the kernel code better than me,
> but it looks like there's zero real value to the rt_sigaction
> testcases, because it can be covered by sigaction...
>
>
>
>     We just tell guys who use these testcases on arch x86_64 that
>     "Syscall rt_sigaction cannot be called directly on arch x86_64.",
>     can we?

    It's not just x86_64 -- it's also ia64, and this may change
depending on the version of glibc and linux sources, so... this really
isn't a viable solution IMO.
    Does anyone have any better suggestions, apart from just using a
preprocessor macro that would execute rt_sig* via their non-rt
equivalents in ltp_signal.h?
Thanks,
-Garrett

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-27  6:49             ` Garrett Cooper
@ 2009-11-27  8:50               ` Garrett Cooper
  2009-11-27 10:07                 ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2009-11-27  8:50 UTC (permalink / raw)
  To: liubo; +Cc: Mike Frysinger, ltp-list

On Thu, Nov 26, 2009 at 10:49 PM, Garrett Cooper <yanegomi@gmail.com> wrote:
> On Thu, Nov 26, 2009 at 9:33 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>> Hi, Garrett
>> On 11/26/2009 07:11 PM, Garrett Cooper wrote:
>>
>> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>
>>
>> Hi, Subrata,
>> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>>
>> Liubo,
>>
>> Are you sending an updated patch post this discussion ?
>>
>>
>>
>> Yes, I'll resend a updated patch about these rt_sigs.
>>
>> Regards--
>> Liubo
>>
>> Regards--
>> Subrata
>>
>> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>>
>>
>> Mike Frysinger wrote:
>>
>>
>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>
>>
>>
>> 1) rt_sigaction
>>     "sigaction" has the structure:
>>
>>  struct sigaction {
>>          __sighandler_t sa_handler;
>>          unsigned long sa_flags;
>>   #ifdef SA_RESTORER
>>           __sigrestore_t sa_restorer;
>>   #endif
>>           sigset_t sa_mask;               /* mask last for extensibility */
>>  };
>>
>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>  to segment fault.
>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>  work. To avoid this segment fault, we use glibc function
>> "int sigaction(...);" instead, which can fulfill the argument
>>  "sa_restorer".
>>
>>
>>
>> which defeats the purpose of the test.  there is no guarantee that the C
>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>
>>
>>
>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>> directly, we must fill the sa_restorer and set the RESTORER flag to
>> sa_mask. If we do not set the sa_restorer, kill will always cause
>> segment fault.
>>
>>
>>
>>
>>
>>
>> 2) rt_sigprocmask
>>     This failure contains two aspects,
>> the first is the segment fault as described in 1),
>> the second is that testcase uses a unknown signal 33 for test,
>> and this will lead sigaction cannot bind signal 33 to the action.
>>
>>     So, we attempt to use a known signal instead, such as 34.
>>
>>
>>
>> which is just as bogus and unportable.  if the test needs a real time
>> signal,
>> it should leverage the sigrtmin...sigrtmax defines.
>> -mike
>>
>>
>> I see what you mean about this testcase segfaulting now.
>>
>> I've done some exploring, and while sigaction does map to rt_sigaction
>> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>>
>> Furthermore, the problem is actually being caused by the fact that
>> we're not even calling sigaddset properly!
>>
>> gcooper@orangebox
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>> ./rt_sigaction01
>> GNU gdb 6.8
>> Copyright (C) 2008 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-pc-linux-gnu"...
>> (gdb) c
>> The program is not being run.
>> (gdb) r
>> Starting program:
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>> thread:20
>> [Thread debugging using libthread_db enabled]
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>>
>> So, the test needs fixing, anyhow. After I fixed it, the test still
>> segfaulted >:( --
>>
>> gcooper@orangebox
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>> ./rt_sigaction01
>> GNU gdb 6.8
>> Copyright (C) 2008 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-pc-linux-gnu"...
>> (gdb) r
>> Starting program:
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>> thread:20
>> [Thread debugging using libthread_db enabled]
>> rt_sigaction01    0  TINFO  :  signal: 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>>
>> Program received signal SIG34, Real-time event 34.
>> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>> (gdb) c
>> Continuing.
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>>
>> So I tried to do some digging. glibc 2.8-20080602 does the following
>> for alpha, i386, and sysv:
>>
>>       result = INLINE_SYSCALL (rt_sigaction, 4,
>>                                sig, act ? __ptrvalue (&kact) : NULL,
>>                                oact ? __ptrvalue (&koact) : NULL, _NSIG /
>> 8);
>>
>> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>>
>> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
>> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>>                 const struct sigaction __user *, act,
>>                 struct sigaction __user *, oact,
>>                 size_t, sigsetsize)
>> {
>>         struct k_sigaction new_sa, old_sa;
>>         int ret = -EINVAL;
>>
>>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>>         if (sigsetsize != sizeof(sigset_t))
>>                 goto out;
>>
>>         if (act) {
>>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>>                         return -EFAULT;
>>         }
>>
>>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa :
>> NULL);
>>
>>         if (!ret && oact) {
>>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>>                         return -EFAULT;
>>         }
>> out:
>>         return ret;
>> }
>>
>> This just blows my mind because rt_sigaction is just calling
>> do_sigaction, which is the same code as sigaction AFAICT, apart from
>> the fact that rt_sigaction completely disregards sa_restorer on some
>> architectures because it's obsolete, and requires the end-user to
>> specify a signal mask set (here's mips' version, which wasn't the same
>> as i386's version -- i386 had the old sa_restorer code):
>>
>> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>>         struct sigaction __user *, oact)
>> {
>>         struct k_sigaction new_ka, old_ka;
>>         int ret;
>>         int err = 0;
>>
>>         if (act) {
>>                 old_sigset_t mask;
>>
>>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>>                         return -EFAULT;
>>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>>                 if (err)
>>                         return -EFAULT;
>>
>>                 siginitset(&new_ka.sa.sa_mask, mask);
>>         }
>>
>>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka :
>> NULL);
>>
>>         if (!ret && oact) {
>>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>>                         return -EFAULT;
>>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>>                 err |= __put_user(old_ka.sa.sa_mask.sig[0],
>> oact->sa_mask.sig);
>>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>>                 if (err)
>>                         return -EFAULT;
>>         }
>>
>>         return ret;
>> }
>>
>> I dunno -- maybe someone else can read the kernel code better than me,
>> but it looks like there's zero real value to the rt_sigaction
>> testcases, because it can be covered by sigaction...
>>
>>
>>
>>     We just tell guys who use these testcases on arch x86_64 that
>>     "Syscall rt_sigaction cannot be called directly on arch x86_64.",
>>     can we?
>
>    It's not just x86_64 -- it's also ia64, and this may change
> depending on the version of glibc and linux sources, so... this really
> isn't a viable solution IMO.
>    Does anyone have any better suggestions, apart from just using a
> preprocessor macro that would execute rt_sig* via their non-rt
> equivalents in ltp_signal.h?

AHA! I think I discovered the kernel bug. rt_sigaction on x86_64
assumes that you're working in 32-bit space:

gcooper@orangebox /usr/src/linux $ grep -r rt_sigaction /usr/src/linux/arch/x86*
/usr/src/linux/arch/x86/ia32/sys_ia32.c:asmlinkage long
sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
Binary file /usr/src/linux/arch/x86/ia32/sys_ia32.o matches
Binary file /usr/src/linux/arch/x86/ia32/built-in.o matches
/usr/src/linux/arch/x86/ia32/ia32entry.S:       .quad sys32_rt_sigaction
Binary file /usr/src/linux/arch/x86/ia32/ia32entry.o matches
Binary file /usr/src/linux/arch/x86/kernel/syscall_64.o matches
Binary file /usr/src/linux/arch/x86/kernel/built-in.o matches
/usr/src/linux/arch/x86/kernel/syscall_table_32.S:      .long sys_rt_sigaction
/usr/src/linux/arch/x86/include/asm/unistd_32.h:#define
__NR_rt_sigaction       174
/usr/src/linux/arch/x86/include/asm/unistd_64.h:#define
__NR_rt_sigaction                       13
/usr/src/linux/arch/x86/include/asm/unistd_64.h:__SYSCALL(__NR_rt_sigaction,
sys_rt_sigaction)
/usr/src/linux/arch/x86/include/asm/sys_ia32.h:asmlinkage long
sys32_rt_sigaction(int, struct sigaction32 __user *,

Watch (compiled with -m32):

rt_sigaction01    0  TINFO  :  signal: 34
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
rt_sigaction01    0  TINFO  :  signal: 35
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
rt_sigaction01    0  TINFO  :  signal: 36
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
rt_sigaction01    0  TINFO  :  signal: 37
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
rt_sigaction01    0  TINFO  :  signal: 38
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
rt_sigaction01    0  TINFO  :  signal: 39
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
rt_sigaction01    0  TINFO  :  signal: 40
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
rt_sigaction01    0  TINFO  :  signal: 41
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
rt_sigaction01    0  TINFO  :  signal: 42
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
rt_sigaction01    0  TINFO  :  signal: 43
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
rt_sigaction01    0  TINFO  :  signal: 44
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
rt_sigaction01    0  TINFO  :  signal: 45
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
rt_sigaction01    0  TINFO  :  signal: 46
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
rt_sigaction01    0  TINFO  :  signal: 47
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
rt_sigaction01    0  TINFO  :  signal: 48
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
rt_sigaction01    0  TINFO  :  signal: 49
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
rt_sigaction01    0  TINFO  :  signal: 50
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
rt_sigaction01    0  TINFO  :  signal: 51
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
rt_sigaction01    0  TINFO  :  signal: 52
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
rt_sigaction01    0  TINFO  :  signal: 53
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
rt_sigaction01    0  TINFO  :  signal: 54
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
rt_sigaction01    0  TINFO  :  signal: 55
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
rt_sigaction01    0  TINFO  :  signal: 56
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
rt_sigaction01    0  TINFO  :  signal: 57
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
rt_sigaction01    0  TINFO  :  signal: 58
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
rt_sigaction01    0  TINFO  :  signal: 59
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
rt_sigaction01    0  TINFO  :  signal: 60
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
rt_sigaction01    0  TINFO  :  signal: 61
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
rt_sigaction01    0  TINFO  :  signal: 62
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
rt_sigaction01    0  TINFO  :  signal: 63
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
rt_sigaction01    0  TINFO  :  signal: 64
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64

So from what I can tell, the sucker isn't properly translating
something in 64-bit space, and instead of properly trapping the issue,
it's segfaulting and dying -_-.

Ultimately the problem from what I can see is that bi-arch (32-bit on
64-bit kernel) 64-bit rt_sig* support is broken. I don't know about
straight, non-bi-arch 64-bit rt_sig* support...

If someone could verify this with a little more kernel experience, or
someone could direct me on how the issue could be trapped in gdb so I
could inspect the registers and ensure the traps are or aren't being
done properly, that would be helpful.

Thanks!
-Garrett

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-27  8:50               ` Garrett Cooper
@ 2009-11-27 10:07                 ` liubo
  2009-11-27 22:18                   ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2009-11-27 10:07 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: Mike Frysinger, ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 39381 bytes --]

Hi, Garrett

On 11/27/2009 04:50 PM, Garrett Cooper wrote:
> On Thu, Nov 26, 2009 at 10:49 PM, Garrett Cooper <yanegomi@gmail.com> wrote:
>   
>> On Thu, Nov 26, 2009 at 9:33 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>     
>>> Hi, Garrett
>>> On 11/26/2009 07:11 PM, Garrett Cooper wrote:
>>>
>>> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>>
>>>
>>> Hi, Subrata,
>>> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>>>
>>> Liubo,
>>>
>>> Are you sending an updated patch post this discussion ?
>>>
>>>
>>>
>>> Yes, I'll resend a updated patch about these rt_sigs.
>>>
>>> Regards--
>>> Liubo
>>>
>>> Regards--
>>> Subrata
>>>
>>> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>>>
>>>
>>> Mike Frysinger wrote:
>>>
>>>
>>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>>
>>>
>>>
>>> 1) rt_sigaction
>>>     "sigaction" has the structure:
>>>
>>>  struct sigaction {
>>>          __sighandler_t sa_handler;
>>>          unsigned long sa_flags;
>>>   #ifdef SA_RESTORER
>>>           __sigrestore_t sa_restorer;
>>>   #endif
>>>           sigset_t sa_mask;               /* mask last for extensibility */
>>>  };
>>>
>>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>>  to segment fault.
>>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>>  work. To avoid this segment fault, we use glibc function
>>> "int sigaction(...);" instead, which can fulfill the argument
>>>  "sa_restorer".
>>>
>>>
>>>
>>> which defeats the purpose of the test.  there is no guarantee that the C
>>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>>
>>>
>>>
>>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>>> directly, we must fill the sa_restorer and set the RESTORER flag to
>>> sa_mask. If we do not set the sa_restorer, kill will always cause
>>> segment fault.
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2) rt_sigprocmask
>>>     This failure contains two aspects,
>>> the first is the segment fault as described in 1),
>>> the second is that testcase uses a unknown signal 33 for test,
>>> and this will lead sigaction cannot bind signal 33 to the action.
>>>
>>>     So, we attempt to use a known signal instead, such as 34.
>>>
>>>
>>>
>>> which is just as bogus and unportable.  if the test needs a real time
>>> signal,
>>> it should leverage the sigrtmin...sigrtmax defines.
>>> -mike
>>>
>>>
>>> I see what you mean about this testcase segfaulting now.
>>>
>>> I've done some exploring, and while sigaction does map to rt_sigaction
>>> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>>>
>>> Furthermore, the problem is actually being caused by the fact that
>>> we're not even calling sigaddset properly!
>>>
>>> gcooper@orangebox
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>>> ./rt_sigaction01
>>> GNU gdb 6.8
>>> Copyright (C) 2008 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "x86_64-pc-linux-gnu"...
>>> (gdb) c
>>> The program is not being run.
>>> (gdb) r
>>> Starting program:
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>>> thread:20
>>> [Thread debugging using libthread_db enabled]
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>>
>>> So, the test needs fixing, anyhow. After I fixed it, the test still
>>> segfaulted >:( --
>>>
>>> gcooper@orangebox
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>>> ./rt_sigaction01
>>> GNU gdb 6.8
>>> Copyright (C) 2008 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "x86_64-pc-linux-gnu"...
>>> (gdb) r
>>> Starting program:
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>>> thread:20
>>> [Thread debugging using libthread_db enabled]
>>> rt_sigaction01    0  TINFO  :  signal: 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>>>
>>> Program received signal SIG34, Real-time event 34.
>>> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
>>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>>> (gdb) c
>>> Continuing.
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>>>
>>> So I tried to do some digging. glibc 2.8-20080602 does the following
>>> for alpha, i386, and sysv:
>>>
>>>       result = INLINE_SYSCALL (rt_sigaction, 4,
>>>                                sig, act ? __ptrvalue (&kact) : NULL,
>>>                                oact ? __ptrvalue (&koact) : NULL, _NSIG /
>>> 8);
>>>
>>> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>>>
>>> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
>>> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>>>                 const struct sigaction __user *, act,
>>>                 struct sigaction __user *, oact,
>>>                 size_t, sigsetsize)
>>> {
>>>         struct k_sigaction new_sa, old_sa;
>>>         int ret = -EINVAL;
>>>
>>>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>>>         if (sigsetsize != sizeof(sigset_t))
>>>                 goto out;
>>>
>>>         if (act) {
>>>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>>>                         return -EFAULT;
>>>         }
>>>
>>>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa :
>>> NULL);
>>>
>>>         if (!ret && oact) {
>>>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>>>                         return -EFAULT;
>>>         }
>>> out:
>>>         return ret;
>>> }
>>>
>>> This just blows my mind because rt_sigaction is just calling
>>> do_sigaction, which is the same code as sigaction AFAICT, apart from
>>> the fact that rt_sigaction completely disregards sa_restorer on some
>>> architectures because it's obsolete, and requires the end-user to
>>> specify a signal mask set (here's mips' version, which wasn't the same
>>> as i386's version -- i386 had the old sa_restorer code):
>>>
>>> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>>>         struct sigaction __user *, oact)
>>> {
>>>         struct k_sigaction new_ka, old_ka;
>>>         int ret;
>>>         int err = 0;
>>>
>>>         if (act) {
>>>                 old_sigset_t mask;
>>>
>>>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>>>                         return -EFAULT;
>>>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>>>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>>>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>>>                 if (err)
>>>                         return -EFAULT;
>>>
>>>                 siginitset(&new_ka.sa.sa_mask, mask);
>>>         }
>>>
>>>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka :
>>> NULL);
>>>
>>>         if (!ret && oact) {
>>>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>>>                         return -EFAULT;
>>>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>>>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>>>                 err |= __put_user(old_ka.sa.sa_mask.sig[0],
>>> oact->sa_mask.sig);
>>>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>>>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>>>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>>>                 if (err)
>>>                         return -EFAULT;
>>>         }
>>>
>>>         return ret;
>>> }
>>>
>>> I dunno -- maybe someone else can read the kernel code better than me,
>>> but it looks like there's zero real value to the rt_sigaction
>>> testcases, because it can be covered by sigaction...
>>>
>>>
>>>
>>>     We just tell guys who use these testcases on arch x86_64 that
>>>     "Syscall rt_sigaction cannot be called directly on arch x86_64.",
>>>     can we?
>>>       
>>    It's not just x86_64 -- it's also ia64, and this may change
>> depending on the version of glibc and linux sources, so... this really
>> isn't a viable solution IMO.
>>    Does anyone have any better suggestions, apart from just using a
>> preprocessor macro that would execute rt_sig* via their non-rt
>> equivalents in ltp_signal.h?
>>     
>
> AHA! I think I discovered the kernel bug. rt_sigaction on x86_64
> assumes that you're working in 32-bit space:
>
> gcooper@orangebox /usr/src/linux $ grep -r rt_sigaction /usr/src/linux/arch/x86*
> /usr/src/linux/arch/x86/ia32/sys_ia32.c:asmlinkage long
> sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
> Binary file /usr/src/linux/arch/x86/ia32/sys_ia32.o matches
> Binary file /usr/src/linux/arch/x86/ia32/built-in.o matches
> /usr/src/linux/arch/x86/ia32/ia32entry.S:       .quad sys32_rt_sigaction
> Binary file /usr/src/linux/arch/x86/ia32/ia32entry.o matches
> Binary file /usr/src/linux/arch/x86/kernel/syscall_64.o matches
> Binary file /usr/src/linux/arch/x86/kernel/built-in.o matches
> /usr/src/linux/arch/x86/kernel/syscall_table_32.S:      .long sys_rt_sigaction
> /usr/src/linux/arch/x86/include/asm/unistd_32.h:#define
> __NR_rt_sigaction       174
> /usr/src/linux/arch/x86/include/asm/unistd_64.h:#define
> __NR_rt_sigaction                       13
> /usr/src/linux/arch/x86/include/asm/unistd_64.h:__SYSCALL(__NR_rt_sigaction,
> sys_rt_sigaction)
> /usr/src/linux/arch/x86/include/asm/sys_ia32.h:asmlinkage long
> sys32_rt_sigaction(int, struct sigaction32 __user *,
>
> Watch (compiled with -m32):
>
> rt_sigaction01    0  TINFO  :  signal: 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  signal: 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  signal: 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  signal: 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  signal: 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  signal: 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  signal: 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  signal: 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  signal: 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  signal: 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  signal: 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  signal: 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  signal: 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  signal: 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  signal: 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  signal: 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  signal: 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  signal: 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  signal: 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  signal: 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  signal: 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  signal: 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  signal: 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  signal: 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  signal: 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  signal: 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  signal: 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  signal: 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  signal: 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  signal: 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  signal: 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>
> So from what I can tell, the sucker isn't properly translating
> something in 64-bit space, and instead of properly trapping the issue,
> it's segfaulting and dying -_-.
>
> Ultimately the problem from what I can see is that bi-arch (32-bit on
> 64-bit kernel) 64-bit rt_sig* support is broken. I don't know about
> straight, non-bi-arch 64-bit rt_sig* support...
>
> If someone could verify this with a little more kernel experience, or
> someone could direct me on how the issue could be trapped in gdb so I
> could inspect the registers and ensure the traps are or aren't being
> done properly, that would be helpful.
>
>   

Although I had figured this, I think your solution is just a compromise,
isn't it?
Change 64-bit rt_sigaction to 32-bit rt_sigaction to pass the testcase.
Let's try to use 64bit rt_sigaction to pass it. ^_^

Thanks~
Liubo

> Thanks!
> -Garrett
>
>
>   


[-- Attachment #1.2: Type: text/html, Size: 42111 bytes --]

[-- Attachment #2: Type: text/plain, Size: 354 bytes --]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-27 10:07                 ` liubo
@ 2009-11-27 22:18                   ` Garrett Cooper
  2009-11-29  1:22                     ` Wei Yongjun
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2009-11-27 22:18 UTC (permalink / raw)
  To: liubo; +Cc: Mike Frysinger, ltp-list

On Fri, Nov 27, 2009 at 2:07 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
> Hi, Garrett
>
> On 11/27/2009 04:50 PM, Garrett Cooper wrote:
>
> On Thu, Nov 26, 2009 at 10:49 PM, Garrett Cooper <yanegomi@gmail.com> wrote:
>
>
> On Thu, Nov 26, 2009 at 9:33 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>
>
> Hi, Garrett
> On 11/26/2009 07:11 PM, Garrett Cooper wrote:
>
> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>
>
> Hi, Subrata,
> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>
> Liubo,
>
> Are you sending an updated patch post this discussion ?
>
>
>
> Yes, I'll resend a updated patch about these rt_sigs.
>
> Regards--
> Liubo
>
> Regards--
> Subrata
>
> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>
>
> Mike Frysinger wrote:
>
>
> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>
>
>
> 1) rt_sigaction
>     "sigaction" has the structure:
>
>  struct sigaction {
>          __sighandler_t sa_handler;
>          unsigned long sa_flags;
>   #ifdef SA_RESTORER
>           __sigrestore_t sa_restorer;
>   #endif
>           sigset_t sa_mask;               /* mask last for extensibility */
>  };
>
>     However, on arch x86_64, if we directly get to call rt_sigaction,
> the argument "sa_restorer" will not be fulfilled, and this will lead
>  to segment fault.
>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>  work. To avoid this segment fault, we use glibc function
> "int sigaction(...);" instead, which can fulfill the argument
>  "sa_restorer".
>
>
>
> which defeats the purpose of the test.  there is no guarantee that the C
> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>
>
>
> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
> directly, we must fill the sa_restorer and set the RESTORER flag to
> sa_mask. If we do not set the sa_restorer, kill will always cause
> segment fault.
>
>
>
>
>
>
> 2) rt_sigprocmask
>     This failure contains two aspects,
> the first is the segment fault as described in 1),
> the second is that testcase uses a unknown signal 33 for test,
> and this will lead sigaction cannot bind signal 33 to the action.
>
>     So, we attempt to use a known signal instead, such as 34.
>
>
>
> which is just as bogus and unportable.  if the test needs a real time
> signal,
> it should leverage the sigrtmin...sigrtmax defines.
> -mike
>
>
> I see what you mean about this testcase segfaulting now.
>
> I've done some exploring, and while sigaction does map to rt_sigaction
> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>
> Furthermore, the problem is actually being caused by the fact that
> we're not even calling sigaddset properly!
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) c
> The program is not being run.
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
>
> So, the test needs fixing, anyhow. After I fixed it, the test still
> segfaulted >:( --
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01    0  TINFO  :  signal: 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>
> Program received signal SIG34, Real-time event 34.
> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
> (gdb) c
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>
> So I tried to do some digging. glibc 2.8-20080602 does the following
> for alpha, i386, and sysv:
>
>       result = INLINE_SYSCALL (rt_sigaction, 4,
>                                sig, act ? __ptrvalue (&kact) : NULL,
>                                oact ? __ptrvalue (&koact) : NULL, _NSIG /
> 8);
>
> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>
> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>                 const struct sigaction __user *, act,
>                 struct sigaction __user *, oact,
>                 size_t, sigsetsize)
> {
>         struct k_sigaction new_sa, old_sa;
>         int ret = -EINVAL;
>
>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>         if (sigsetsize != sizeof(sigset_t))
>                 goto out;
>
>         if (act) {
>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>                         return -EFAULT;
>         }
>
>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa :
> NULL);
>
>         if (!ret && oact) {
>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>                         return -EFAULT;
>         }
> out:
>         return ret;
> }
>
> This just blows my mind because rt_sigaction is just calling
> do_sigaction, which is the same code as sigaction AFAICT, apart from
> the fact that rt_sigaction completely disregards sa_restorer on some
> architectures because it's obsolete, and requires the end-user to
> specify a signal mask set (here's mips' version, which wasn't the same
> as i386's version -- i386 had the old sa_restorer code):
>
> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>         struct sigaction __user *, oact)
> {
>         struct k_sigaction new_ka, old_ka;
>         int ret;
>         int err = 0;
>
>         if (act) {
>                 old_sigset_t mask;
>
>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>                         return -EFAULT;
>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>                 if (err)
>                         return -EFAULT;
>
>                 siginitset(&new_ka.sa.sa_mask, mask);
>         }
>
>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka :
> NULL);
>
>         if (!ret && oact) {
>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>                         return -EFAULT;
>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>                 err |= __put_user(old_ka.sa.sa_mask.sig[0],
> oact->sa_mask.sig);
>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>                 if (err)
>                         return -EFAULT;
>         }
>
>         return ret;
> }
>
> I dunno -- maybe someone else can read the kernel code better than me,
> but it looks like there's zero real value to the rt_sigaction
> testcases, because it can be covered by sigaction...
>
>
>
>     We just tell guys who use these testcases on arch x86_64 that
>     "Syscall rt_sigaction cannot be called directly on arch x86_64.",
>     can we?
>
>
>    It's not just x86_64 -- it's also ia64, and this may change
> depending on the version of glibc and linux sources, so... this really
> isn't a viable solution IMO.
>    Does anyone have any better suggestions, apart from just using a
> preprocessor macro that would execute rt_sig* via their non-rt
> equivalents in ltp_signal.h?
>
>
> AHA! I think I discovered the kernel bug. rt_sigaction on x86_64
> assumes that you're working in 32-bit space:
>
> gcooper@orangebox /usr/src/linux $ grep -r rt_sigaction
> /usr/src/linux/arch/x86*
> /usr/src/linux/arch/x86/ia32/sys_ia32.c:asmlinkage long
> sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
> Binary file /usr/src/linux/arch/x86/ia32/sys_ia32.o matches
> Binary file /usr/src/linux/arch/x86/ia32/built-in.o matches
> /usr/src/linux/arch/x86/ia32/ia32entry.S:       .quad sys32_rt_sigaction
> Binary file /usr/src/linux/arch/x86/ia32/ia32entry.o matches
> Binary file /usr/src/linux/arch/x86/kernel/syscall_64.o matches
> Binary file /usr/src/linux/arch/x86/kernel/built-in.o matches
> /usr/src/linux/arch/x86/kernel/syscall_table_32.S:      .long
> sys_rt_sigaction
> /usr/src/linux/arch/x86/include/asm/unistd_32.h:#define
> __NR_rt_sigaction       174
> /usr/src/linux/arch/x86/include/asm/unistd_64.h:#define
> __NR_rt_sigaction                       13
> /usr/src/linux/arch/x86/include/asm/unistd_64.h:__SYSCALL(__NR_rt_sigaction,
> sys_rt_sigaction)
> /usr/src/linux/arch/x86/include/asm/sys_ia32.h:asmlinkage long
> sys32_rt_sigaction(int, struct sigaction32 __user *,
>
> Watch (compiled with -m32):
>
> rt_sigaction01    0  TINFO  :  signal: 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
> rt_sigaction01    0  TINFO  :  signal: 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
> rt_sigaction01    0  TINFO  :  signal: 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
> rt_sigaction01    0  TINFO  :  signal: 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
> rt_sigaction01    0  TINFO  :  signal: 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
> rt_sigaction01    0  TINFO  :  signal: 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
> rt_sigaction01    0  TINFO  :  signal: 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
> rt_sigaction01    0  TINFO  :  signal: 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
> rt_sigaction01    0  TINFO  :  signal: 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
> rt_sigaction01    0  TINFO  :  signal: 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
> rt_sigaction01    0  TINFO  :  signal: 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
> rt_sigaction01    0  TINFO  :  signal: 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
> rt_sigaction01    0  TINFO  :  signal: 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
> rt_sigaction01    0  TINFO  :  signal: 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
> rt_sigaction01    0  TINFO  :  signal: 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
> rt_sigaction01    0  TINFO  :  signal: 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
> rt_sigaction01    0  TINFO  :  signal: 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
> rt_sigaction01    0  TINFO  :  signal: 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
> rt_sigaction01    0  TINFO  :  signal: 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
> rt_sigaction01    0  TINFO  :  signal: 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
> rt_sigaction01    0  TINFO  :  signal: 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
> rt_sigaction01    0  TINFO  :  signal: 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
> rt_sigaction01    0  TINFO  :  signal: 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
> rt_sigaction01    0  TINFO  :  signal: 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
> rt_sigaction01    0  TINFO  :  signal: 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
> rt_sigaction01    0  TINFO  :  signal: 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
> rt_sigaction01    0  TINFO  :  signal: 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
> rt_sigaction01    0  TINFO  :  signal: 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
> rt_sigaction01    0  TINFO  :  signal: 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
> rt_sigaction01    0  TINFO  :  signal: 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
> rt_sigaction01    0  TINFO  :  signal: 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>
> So from what I can tell, the sucker isn't properly translating
> something in 64-bit space, and instead of properly trapping the issue,
> it's segfaulting and dying -_-.
>
> Ultimately the problem from what I can see is that bi-arch (32-bit on
> 64-bit kernel) 64-bit rt_sig* support is broken. I don't know about
> straight, non-bi-arch 64-bit rt_sig* support...
>
> If someone could verify this with a little more kernel experience, or
> someone could direct me on how the issue could be trapped in gdb so I
> could inspect the registers and ensure the traps are or aren't being
> done properly, that would be helpful.
>
>
>
> Although I had figured this, I think your solution is just a compromise,
> isn't it?
> Change 64-bit rt_sigaction to 32-bit rt_sigaction to pass the testcase.
> Let's try to use 64bit rt_sigaction to pass it. ^_^

Luibo,
    It isn't really a compromise -- it's an observation of what I
consider broken functionality in the 32-bit <-> 64-bit translation
layers in the kernel ;)... 32-bit and 64-bit rt_sigaction should
function equivalently, but they don't today.
Thanks,
-Garrett

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-27 22:18                   ` Garrett Cooper
@ 2009-11-29  1:22                     ` Wei Yongjun
  2009-12-01  0:00                       ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: Wei Yongjun @ 2009-11-29  1:22 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: Mike Frysinger, ltp-list



Garrett Cooper wrote:
> On Fri, Nov 27, 2009 at 2:07 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> Hi, Garrett
>>
>> On 11/27/2009 04:50 PM, Garrett Cooper wrote:
>>
>> On Thu, Nov 26, 2009 at 10:49 PM, Garrett Cooper <yanegomi@gmail.com> wrote:
>>
>>
>> On Thu, Nov 26, 2009 at 9:33 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>
>>
>> Hi, Garrett
>> On 11/26/2009 07:11 PM, Garrett Cooper wrote:
>>
>> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>
>>
>> Hi, Subrata,
>> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>>
>> Liubo,
>>
>> Are you sending an updated patch post this discussion ?
>>
>>
>>
>> Yes, I'll resend a updated patch about these rt_sigs.
>>
>> Regards--
>> Liubo
>>
>> Regards--
>> Subrata
>>
>> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>>
>>
>> Mike Frysinger wrote:
>>
>>
>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>
>>
>>
>> 1) rt_sigaction
>>     "sigaction" has the structure:
>>
>>  struct sigaction {
>>          __sighandler_t sa_handler;
>>          unsigned long sa_flags;
>>   #ifdef SA_RESTORER
>>           __sigrestore_t sa_restorer;
>>   #endif
>>           sigset_t sa_mask;               /* mask last for extensibility */
>>  };
>>
>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>  to segment fault.
>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>  work. To avoid this segment fault, we use glibc function
>> "int sigaction(...);" instead, which can fulfill the argument
>>  "sa_restorer".
>>
>>
>>
>> which defeats the purpose of the test.  there is no guarantee that the C
>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>
>>
>>
>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>> directly, we must fill the sa_restorer and set the RESTORER flag to
>> sa_mask. If we do not set the sa_restorer, kill will always cause
>> segment fault.
>>
>>
>>
>>
>>
>>
>> 2) rt_sigprocmask
>>     This failure contains two aspects,
>> the first is the segment fault as described in 1),
>> the second is that testcase uses a unknown signal 33 for test,
>> and this will lead sigaction cannot bind signal 33 to the action.
>>
>>     So, we attempt to use a known signal instead, such as 34.
>>
>>
>>
>> which is just as bogus and unportable.  if the test needs a real time
>> signal,
>> it should leverage the sigrtmin...sigrtmax defines.
>> -mike
>>
>>
>> I see what you mean about this testcase segfaulting now.
>>
>> I've done some exploring, and while sigaction does map to rt_sigaction
>> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>>
>> Furthermore, the problem is actually being caused by the fact that
>> we're not even calling sigaddset properly!
>>
>> gcooper@orangebox
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>> ./rt_sigaction01
>> GNU gdb 6.8
>> Copyright (C) 2008 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-pc-linux-gnu"...
>> (gdb) c
>> The program is not being run.
>> (gdb) r
>> Starting program:
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>> thread:20
>> [Thread debugging using libthread_db enabled]
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
>> TEST_ERRNO=EINVAL(22): Invalid argument
>>
>> So, the test needs fixing, anyhow. After I fixed it, the test still
>> segfaulted >:( --
>>
>> gcooper@orangebox
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>> ./rt_sigaction01
>> GNU gdb 6.8
>> Copyright (C) 2008 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-pc-linux-gnu"...
>> (gdb) r
>> Starting program:
>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>> thread:20
>> [Thread debugging using libthread_db enabled]
>> rt_sigaction01    0  TINFO  :  signal: 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>>
>> Program received signal SIG34, Real-time event 34.
>> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>> (gdb) c
>> Continuing.
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>>
>> So I tried to do some digging. glibc 2.8-20080602 does the following
>> for alpha, i386, and sysv:
>>
>>       result = INLINE_SYSCALL (rt_sigaction, 4,
>>                                sig, act ? __ptrvalue (&kact) : NULL,
>>                                oact ? __ptrvalue (&koact) : NULL, _NSIG /
>> 8);
>>
>> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>>
>> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
>> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>>                 const struct sigaction __user *, act,
>>                 struct sigaction __user *, oact,
>>                 size_t, sigsetsize)
>> {
>>         struct k_sigaction new_sa, old_sa;
>>         int ret = -EINVAL;
>>
>>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>>         if (sigsetsize != sizeof(sigset_t))
>>                 goto out;
>>
>>         if (act) {
>>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>>                         return -EFAULT;
>>         }
>>
>>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa :
>> NULL);
>>
>>         if (!ret && oact) {
>>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>>                         return -EFAULT;
>>         }
>> out:
>>         return ret;
>> }
>>
>> This just blows my mind because rt_sigaction is just calling
>> do_sigaction, which is the same code as sigaction AFAICT, apart from
>> the fact that rt_sigaction completely disregards sa_restorer on some
>> architectures because it's obsolete, and requires the end-user to
>> specify a signal mask set (here's mips' version, which wasn't the same
>> as i386's version -- i386 had the old sa_restorer code):
>>
>> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>>         struct sigaction __user *, oact)
>> {
>>         struct k_sigaction new_ka, old_ka;
>>         int ret;
>>         int err = 0;
>>
>>         if (act) {
>>                 old_sigset_t mask;
>>
>>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>>                         return -EFAULT;
>>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>>                 if (err)
>>                         return -EFAULT;
>>
>>                 siginitset(&new_ka.sa.sa_mask, mask);
>>         }
>>
>>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka :
>> NULL);
>>
>>         if (!ret && oact) {
>>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>>                         return -EFAULT;
>>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>>                 err |= __put_user(old_ka.sa.sa_mask.sig[0],
>> oact->sa_mask.sig);
>>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>>                 if (err)
>>                         return -EFAULT;
>>         }
>>
>>         return ret;
>> }
>>
>> I dunno -- maybe someone else can read the kernel code better than me,
>> but it looks like there's zero real value to the rt_sigaction
>> testcases, because it can be covered by sigaction...
>>
>>
>>
>>     We just tell guys who use these testcases on arch x86_64 that
>>     "Syscall rt_sigaction cannot be called directly on arch x86_64.",
>>     can we?
>>
>>
>>    It's not just x86_64 -- it's also ia64, and this may change
>> depending on the version of glibc and linux sources, so... this really
>> isn't a viable solution IMO.
>>    Does anyone have any better suggestions, apart from just using a
>> preprocessor macro that would execute rt_sig* via their non-rt
>> equivalents in ltp_signal.h?
>>
>>
>> AHA! I think I discovered the kernel bug. rt_sigaction on x86_64
>> assumes that you're working in 32-bit space:
>>
>> gcooper@orangebox /usr/src/linux $ grep -r rt_sigaction
>> /usr/src/linux/arch/x86*
>> /usr/src/linux/arch/x86/ia32/sys_ia32.c:asmlinkage long
>> sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
>> Binary file /usr/src/linux/arch/x86/ia32/sys_ia32.o matches
>> Binary file /usr/src/linux/arch/x86/ia32/built-in.o matches
>> /usr/src/linux/arch/x86/ia32/ia32entry.S:       .quad sys32_rt_sigaction
>> Binary file /usr/src/linux/arch/x86/ia32/ia32entry.o matches
>> Binary file /usr/src/linux/arch/x86/kernel/syscall_64.o matches
>> Binary file /usr/src/linux/arch/x86/kernel/built-in.o matches
>> /usr/src/linux/arch/x86/kernel/syscall_table_32.S:      .long
>> sys_rt_sigaction
>> /usr/src/linux/arch/x86/include/asm/unistd_32.h:#define
>> __NR_rt_sigaction       174
>> /usr/src/linux/arch/x86/include/asm/unistd_64.h:#define
>> __NR_rt_sigaction                       13
>> /usr/src/linux/arch/x86/include/asm/unistd_64.h:__SYSCALL(__NR_rt_sigaction,
>> sys_rt_sigaction)
>> /usr/src/linux/arch/x86/include/asm/sys_ia32.h:asmlinkage long
>> sys32_rt_sigaction(int, struct sigaction32 __user *,
>>
>> Watch (compiled with -m32):
>>
>> rt_sigaction01    0  TINFO  :  signal: 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>> rt_sigaction01    0  TINFO  :  signal: 35
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>> rt_sigaction01    0  TINFO  :  signal: 36
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>> rt_sigaction01    0  TINFO  :  signal: 37
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>> rt_sigaction01    0  TINFO  :  signal: 38
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>> rt_sigaction01    0  TINFO  :  signal: 39
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>> rt_sigaction01    0  TINFO  :  signal: 40
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>> rt_sigaction01    0  TINFO  :  signal: 41
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>> rt_sigaction01    0  TINFO  :  signal: 42
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>> rt_sigaction01    0  TINFO  :  signal: 43
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>> rt_sigaction01    0  TINFO  :  signal: 44
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>> rt_sigaction01    0  TINFO  :  signal: 45
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>> rt_sigaction01    0  TINFO  :  signal: 46
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>> rt_sigaction01    0  TINFO  :  signal: 47
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>> rt_sigaction01    0  TINFO  :  signal: 48
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>> rt_sigaction01    0  TINFO  :  signal: 49
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>> rt_sigaction01    0  TINFO  :  signal: 50
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>> rt_sigaction01    0  TINFO  :  signal: 51
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>> rt_sigaction01    0  TINFO  :  signal: 52
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>> rt_sigaction01    0  TINFO  :  signal: 53
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>> rt_sigaction01    0  TINFO  :  signal: 54
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>> rt_sigaction01    0  TINFO  :  signal: 55
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>> rt_sigaction01    0  TINFO  :  signal: 56
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>> rt_sigaction01    0  TINFO  :  signal: 57
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>> rt_sigaction01    0  TINFO  :  signal: 58
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>> rt_sigaction01    0  TINFO  :  signal: 59
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>> rt_sigaction01    0  TINFO  :  signal: 60
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>> rt_sigaction01    0  TINFO  :  signal: 61
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>> rt_sigaction01    0  TINFO  :  signal: 62
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>> rt_sigaction01    0  TINFO  :  signal: 63
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>> rt_sigaction01    0  TINFO  :  signal: 64
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>>
>> So from what I can tell, the sucker isn't properly translating
>> something in 64-bit space, and instead of properly trapping the issue,
>> it's segfaulting and dying -_-.
>>
>> Ultimately the problem from what I can see is that bi-arch (32-bit on
>> 64-bit kernel) 64-bit rt_sig* support is broken. I don't know about
>> straight, non-bi-arch 64-bit rt_sig* support...
>>
>> If someone could verify this with a little more kernel experience, or
>> someone could direct me on how the issue could be trapped in gdb so I
>> could inspect the registers and ensure the traps are or aren't being
>> done properly, that would be helpful.
>>
>>
>>
>> Although I had figured this, I think your solution is just a compromise,
>> isn't it?
>> Change 64-bit rt_sigaction to 32-bit rt_sigaction to pass the testcase.
>> Let's try to use 64bit rt_sigaction to pass it. ^_^
>>     
>
> Luibo,
>     It isn't really a compromise -- it's an observation of what I
> consider broken functionality in the 32-bit <-> 64-bit translation
> layers in the kernel ;)... 32-bit and 64-bit rt_sigaction should
> function equivalently, but they don't today.
> Thanks,
> -Garrett
>
>   

There is other issue in x86_64. see the following kernel source
code from file arch/x86/kernel/signal.c:

 412 #else /* !CONFIG_X86_32 */
 413 static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 414                             sigset_t *set, struct pt_regs *regs)
 415 {
     ......
 430 
 431         put_user_try {
 432                 /* Create the ucontext.  */
 433                 if (cpu_has_xsave)
 434                         put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
 435                 else
 436                         put_user_ex(0, &frame->uc.uc_flags);
 437                 put_user_ex(0, &frame->uc.uc_link);
 438                 put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
 439                 put_user_ex(sas_ss_flags(regs->sp),
 440                             &frame->uc.uc_stack.ss_flags);
 441                 put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
 442                 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
 443                 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
 444 
 445                 /* Set up to return from userspace.  If provided, use a stub
 446                    already in userspace.  */
 447                 /* x86-64 should always use SA_RESTORER. */
 448                 if (ka->sa.sa_flags & SA_RESTORER) {
 449                         put_user_ex(ka->sa.sa_restorer, &frame->pretcode);
 450                 } else {
 451                         /* could use a vstub here */
 452                         err |= -EFAULT;
 453                 }
 454         } put_user_catch(err);
 455 
             ......
 476         return 0;
 477 }
 478 #endif /* CONFIG_X86_32 */


Line 448~453 said that x86-64 should always use SA_RESTORER flag ans set the
sa_restorer, otherwise kernel will return EFAULT.

In test rt_sigaction01.c, it used rt_sigaction syscall directly without the
SA_RESTORER flag and null sa_restorer handler, so the test cases for x86_64
will aways fail. In Liu's fix, he used sigaction() instead of rt_sigaction
syscall. sigaction() will fill the SA_RESTORER flag and sa_restorer handler,
so he can pass the test case in x86_64.

Fill the SA_RESTORER flag and sa_restorer handler is the point I think.





 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-11-29  1:22                     ` Wei Yongjun
@ 2009-12-01  0:00                       ` Garrett Cooper
  2009-12-09  7:29                         ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2009-12-01  0:00 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Mike Frysinger, ltp-list

On Sat, Nov 28, 2009 at 5:22 PM, Wei Yongjun <yjwei@cn.fujitsu.com> wrote:
>
>
> Garrett Cooper wrote:
>> On Fri, Nov 27, 2009 at 2:07 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>
>>> Hi, Garrett
>>>
>>> On 11/27/2009 04:50 PM, Garrett Cooper wrote:
>>>
>>> On Thu, Nov 26, 2009 at 10:49 PM, Garrett Cooper <yanegomi@gmail.com> wrote:
>>>
>>>
>>> On Thu, Nov 26, 2009 at 9:33 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>>
>>>
>>> Hi, Garrett
>>> On 11/26/2009 07:11 PM, Garrett Cooper wrote:
>>>
>>> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>>
>>>
>>> Hi, Subrata,
>>> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>>>
>>> Liubo,
>>>
>>> Are you sending an updated patch post this discussion ?
>>>
>>>
>>>
>>> Yes, I'll resend a updated patch about these rt_sigs.
>>>
>>> Regards--
>>> Liubo
>>>
>>> Regards--
>>> Subrata
>>>
>>> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>>>
>>>
>>> Mike Frysinger wrote:
>>>
>>>
>>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>>
>>>
>>>
>>> 1) rt_sigaction
>>>     "sigaction" has the structure:
>>>
>>>  struct sigaction {
>>>          __sighandler_t sa_handler;
>>>          unsigned long sa_flags;
>>>   #ifdef SA_RESTORER
>>>           __sigrestore_t sa_restorer;
>>>   #endif
>>>           sigset_t sa_mask;               /* mask last for extensibility */
>>>  };
>>>
>>>     However, on arch x86_64, if we directly get to call rt_sigaction,
>>> the argument "sa_restorer" will not be fulfilled, and this will lead
>>>  to segment fault.
>>>     on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>>>  fault. In other arch, if sa_restorer is not set, kernel can do the correct
>>>  work. To avoid this segment fault, we use glibc function
>>> "int sigaction(...);" instead, which can fulfill the argument
>>>  "sa_restorer".
>>>
>>>
>>>
>>> which defeats the purpose of the test.  there is no guarantee that the C
>>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>>
>>>
>>>
>>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>>> directly, we must fill the sa_restorer and set the RESTORER flag to
>>> sa_mask. If we do not set the sa_restorer, kill will always cause
>>> segment fault.
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2) rt_sigprocmask
>>>     This failure contains two aspects,
>>> the first is the segment fault as described in 1),
>>> the second is that testcase uses a unknown signal 33 for test,
>>> and this will lead sigaction cannot bind signal 33 to the action.
>>>
>>>     So, we attempt to use a known signal instead, such as 34.
>>>
>>>
>>>
>>> which is just as bogus and unportable.  if the test needs a real time
>>> signal,
>>> it should leverage the sigrtmin...sigrtmax defines.
>>> -mike
>>>
>>>
>>> I see what you mean about this testcase segfaulting now.
>>>
>>> I've done some exploring, and while sigaction does map to rt_sigaction
>>> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>>>
>>> Furthermore, the problem is actually being caused by the fact that
>>> we're not even calling sigaddset properly!
>>>
>>> gcooper@orangebox
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>>> ./rt_sigaction01
>>> GNU gdb 6.8
>>> Copyright (C) 2008 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "x86_64-pc-linux-gnu"...
>>> (gdb) c
>>> The program is not being run.
>>> (gdb) r
>>> Starting program:
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>>> thread:20
>>> [Thread debugging using libthread_db enabled]
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    1  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    2  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    3  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    4  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    5  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    6  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    7  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    8  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01    9  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   10  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   11  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   12  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   13  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   14  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   15  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   16  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   17  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   18  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   19  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   20  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   21  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   22  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   23  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   24  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   25  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   26  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   27  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   28  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   29  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>> rt_sigaction01    0  TINFO  :  sigaddset(..) failed
>>> rt_sigaction01   30  TFAIL  :  rt_sigaction01 failed:
>>> TEST_ERRNO=EINVAL(22): Invalid argument
>>>
>>> So, the test needs fixing, anyhow. After I fixed it, the test still
>>> segfaulted >:( --
>>>
>>> gcooper@orangebox
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
>>> ./rt_sigaction01
>>> GNU gdb 6.8
>>> Copyright (C) 2008 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "x86_64-pc-linux-gnu"...
>>> (gdb) r
>>> Starting program:
>>> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
>>> thread:20
>>> [Thread debugging using libthread_db enabled]
>>> rt_sigaction01    0  TINFO  :  signal: 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>>>
>>> Program received signal SIG34, Real-time event 34.
>>> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
>>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>>> (gdb) c
>>> Continuing.
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>>>
>>> So I tried to do some digging. glibc 2.8-20080602 does the following
>>> for alpha, i386, and sysv:
>>>
>>>       result = INLINE_SYSCALL (rt_sigaction, 4,
>>>                                sig, act ? __ptrvalue (&kact) : NULL,
>>>                                oact ? __ptrvalue (&koact) : NULL, _NSIG /
>>> 8);
>>>
>>> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>>>
>>> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
>>> SYSCALL_DEFINE4(rt_sigaction, int, sig,
>>>                 const struct sigaction __user *, act,
>>>                 struct sigaction __user *, oact,
>>>                 size_t, sigsetsize)
>>> {
>>>         struct k_sigaction new_sa, old_sa;
>>>         int ret = -EINVAL;
>>>
>>>         /* XXX: Don't preclude handling different sized sigset_t's.  */
>>>         if (sigsetsize != sizeof(sigset_t))
>>>                 goto out;
>>>
>>>         if (act) {
>>>                 if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
>>>                         return -EFAULT;
>>>         }
>>>
>>>         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa :
>>> NULL);
>>>
>>>         if (!ret && oact) {
>>>                 if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
>>>                         return -EFAULT;
>>>         }
>>> out:
>>>         return ret;
>>> }
>>>
>>> This just blows my mind because rt_sigaction is just calling
>>> do_sigaction, which is the same code as sigaction AFAICT, apart from
>>> the fact that rt_sigaction completely disregards sa_restorer on some
>>> architectures because it's obsolete, and requires the end-user to
>>> specify a signal mask set (here's mips' version, which wasn't the same
>>> as i386's version -- i386 had the old sa_restorer code):
>>>
>>> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
>>>         struct sigaction __user *, oact)
>>> {
>>>         struct k_sigaction new_ka, old_ka;
>>>         int ret;
>>>         int err = 0;
>>>
>>>         if (act) {
>>>                 old_sigset_t mask;
>>>
>>>                 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
>>>                         return -EFAULT;
>>>                 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
>>>                 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
>>>                 err |= __get_user(mask, &act->sa_mask.sig[0]);
>>>                 if (err)
>>>                         return -EFAULT;
>>>
>>>                 siginitset(&new_ka.sa.sa_mask, mask);
>>>         }
>>>
>>>         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka :
>>> NULL);
>>>
>>>         if (!ret && oact) {
>>>                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
>>>                         return -EFAULT;
>>>                 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
>>>                 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
>>>                 err |= __put_user(old_ka.sa.sa_mask.sig[0],
>>> oact->sa_mask.sig);
>>>                 err |= __put_user(0, &oact->sa_mask.sig[1]);
>>>                 err |= __put_user(0, &oact->sa_mask.sig[2]);
>>>                 err |= __put_user(0, &oact->sa_mask.sig[3]);
>>>                 if (err)
>>>                         return -EFAULT;
>>>         }
>>>
>>>         return ret;
>>> }
>>>
>>> I dunno -- maybe someone else can read the kernel code better than me,
>>> but it looks like there's zero real value to the rt_sigaction
>>> testcases, because it can be covered by sigaction...
>>>
>>>
>>>
>>>     We just tell guys who use these testcases on arch x86_64 that
>>>     "Syscall rt_sigaction cannot be called directly on arch x86_64.",
>>>     can we?
>>>
>>>
>>>    It's not just x86_64 -- it's also ia64, and this may change
>>> depending on the version of glibc and linux sources, so... this really
>>> isn't a viable solution IMO.
>>>    Does anyone have any better suggestions, apart from just using a
>>> preprocessor macro that would execute rt_sig* via their non-rt
>>> equivalents in ltp_signal.h?
>>>
>>>
>>> AHA! I think I discovered the kernel bug. rt_sigaction on x86_64
>>> assumes that you're working in 32-bit space:
>>>
>>> gcooper@orangebox /usr/src/linux $ grep -r rt_sigaction
>>> /usr/src/linux/arch/x86*
>>> /usr/src/linux/arch/x86/ia32/sys_ia32.c:asmlinkage long
>>> sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
>>> Binary file /usr/src/linux/arch/x86/ia32/sys_ia32.o matches
>>> Binary file /usr/src/linux/arch/x86/ia32/built-in.o matches
>>> /usr/src/linux/arch/x86/ia32/ia32entry.S:       .quad sys32_rt_sigaction
>>> Binary file /usr/src/linux/arch/x86/ia32/ia32entry.o matches
>>> Binary file /usr/src/linux/arch/x86/kernel/syscall_64.o matches
>>> Binary file /usr/src/linux/arch/x86/kernel/built-in.o matches
>>> /usr/src/linux/arch/x86/kernel/syscall_table_32.S:      .long
>>> sys_rt_sigaction
>>> /usr/src/linux/arch/x86/include/asm/unistd_32.h:#define
>>> __NR_rt_sigaction       174
>>> /usr/src/linux/arch/x86/include/asm/unistd_64.h:#define
>>> __NR_rt_sigaction                       13
>>> /usr/src/linux/arch/x86/include/asm/unistd_64.h:__SYSCALL(__NR_rt_sigaction,
>>> sys_rt_sigaction)
>>> /usr/src/linux/arch/x86/include/asm/sys_ia32.h:asmlinkage long
>>> sys32_rt_sigaction(int, struct sigaction32 __user *,
>>>
>>> Watch (compiled with -m32):
>>>
>>> rt_sigaction01    0  TINFO  :  signal: 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 34
>>> rt_sigaction01    0  TINFO  :  signal: 35
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 35
>>> rt_sigaction01    0  TINFO  :  signal: 36
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 36
>>> rt_sigaction01    0  TINFO  :  signal: 37
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 37
>>> rt_sigaction01    0  TINFO  :  signal: 38
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 38
>>> rt_sigaction01    0  TINFO  :  signal: 39
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 39
>>> rt_sigaction01    0  TINFO  :  signal: 40
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 40
>>> rt_sigaction01    0  TINFO  :  signal: 41
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 41
>>> rt_sigaction01    0  TINFO  :  signal: 42
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 42
>>> rt_sigaction01    0  TINFO  :  signal: 43
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 43
>>> rt_sigaction01    0  TINFO  :  signal: 44
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 44
>>> rt_sigaction01    0  TINFO  :  signal: 45
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 45
>>> rt_sigaction01    0  TINFO  :  signal: 46
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 46
>>> rt_sigaction01    0  TINFO  :  signal: 47
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 47
>>> rt_sigaction01    0  TINFO  :  signal: 48
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 48
>>> rt_sigaction01    0  TINFO  :  signal: 49
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 49
>>> rt_sigaction01    0  TINFO  :  signal: 50
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 50
>>> rt_sigaction01    0  TINFO  :  signal: 51
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 51
>>> rt_sigaction01    0  TINFO  :  signal: 52
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 52
>>> rt_sigaction01    0  TINFO  :  signal: 53
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 53
>>> rt_sigaction01    0  TINFO  :  signal: 54
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 54
>>> rt_sigaction01    0  TINFO  :  signal: 55
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 55
>>> rt_sigaction01    0  TINFO  :  signal: 56
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 56
>>> rt_sigaction01    0  TINFO  :  signal: 57
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 57
>>> rt_sigaction01    0  TINFO  :  signal: 58
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 58
>>> rt_sigaction01    0  TINFO  :  signal: 59
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 59
>>> rt_sigaction01    0  TINFO  :  signal: 60
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 60
>>> rt_sigaction01    0  TINFO  :  signal: 61
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 61
>>> rt_sigaction01    0  TINFO  :  signal: 62
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 62
>>> rt_sigaction01    0  TINFO  :  signal: 63
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 63
>>> rt_sigaction01    0  TINFO  :  signal: 64
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_RESETHAND|SA_SIGINFO
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>>> rt_sigaction01    0  TINFO  :  sa.sa_flags = SA_NOMASK
>>> rt_sigaction01    0  TINFO  :  Signal Handler Called with signal number 64
>>>
>>> So from what I can tell, the sucker isn't properly translating
>>> something in 64-bit space, and instead of properly trapping the issue,
>>> it's segfaulting and dying -_-.
>>>
>>> Ultimately the problem from what I can see is that bi-arch (32-bit on
>>> 64-bit kernel) 64-bit rt_sig* support is broken. I don't know about
>>> straight, non-bi-arch 64-bit rt_sig* support...
>>>
>>> If someone could verify this with a little more kernel experience, or
>>> someone could direct me on how the issue could be trapped in gdb so I
>>> could inspect the registers and ensure the traps are or aren't being
>>> done properly, that would be helpful.
>>>
>>>
>>>
>>> Although I had figured this, I think your solution is just a compromise,
>>> isn't it?
>>> Change 64-bit rt_sigaction to 32-bit rt_sigaction to pass the testcase.
>>> Let's try to use 64bit rt_sigaction to pass it. ^_^
>>>
>>
>> Luibo,
>>     It isn't really a compromise -- it's an observation of what I
>> consider broken functionality in the 32-bit <-> 64-bit translation
>> layers in the kernel ;)... 32-bit and 64-bit rt_sigaction should
>> function equivalently, but they don't today.
>> Thanks,
>> -Garrett
>>
>>
>
> There is other issue in x86_64. see the following kernel source
> code from file arch/x86/kernel/signal.c:
>
>  412 #else /* !CONFIG_X86_32 */
>  413 static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
>  414                             sigset_t *set, struct pt_regs *regs)
>  415 {
>     ......
>  430
>  431         put_user_try {
>  432                 /* Create the ucontext.  */
>  433                 if (cpu_has_xsave)
>  434                         put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
>  435                 else
>  436                         put_user_ex(0, &frame->uc.uc_flags);
>  437                 put_user_ex(0, &frame->uc.uc_link);
>  438                 put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
>  439                 put_user_ex(sas_ss_flags(regs->sp),
>  440                             &frame->uc.uc_stack.ss_flags);
>  441                 put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
>  442                 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
>  443                 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
>  444
>  445                 /* Set up to return from userspace.  If provided, use a stub
>  446                    already in userspace.  */
>  447                 /* x86-64 should always use SA_RESTORER. */
>  448                 if (ka->sa.sa_flags & SA_RESTORER) {
>  449                         put_user_ex(ka->sa.sa_restorer, &frame->pretcode);
>  450                 } else {
>  451                         /* could use a vstub here */
>  452                         err |= -EFAULT;
>  453                 }
>  454         } put_user_catch(err);
>  455
>             ......
>  476         return 0;
>  477 }
>  478 #endif /* CONFIG_X86_32 */
>
>
> Line 448~453 said that x86-64 should always use SA_RESTORER flag ans set the
> sa_restorer, otherwise kernel will return EFAULT.
>
> In test rt_sigaction01.c, it used rt_sigaction syscall directly without the
> SA_RESTORER flag and null sa_restorer handler, so the test cases for x86_64
> will aways fail. In Liu's fix, he used sigaction() instead of rt_sigaction
> syscall. sigaction() will fill the SA_RESTORER flag and sa_restorer handler,
> so he can pass the test case in x86_64.
>
> Fill the SA_RESTORER flag and sa_restorer handler is the point I think.

Yes. I [mostly] fixed the rt_sigaction01 test a few hours ago. A
summary of the issues with the old version:

1. The test as it was written before verified functionality by
ensuring that coredumps and crashes didn't occur. The new version
either catches the appropriate rt signal and increments, or catches
SIGSEGV and continues. Eventually once all of the issues are worked
out with SIGRTMIN, the known issue TINFO printout needs to be removed
from include/ltp_signal.h
2. If the sa_flags field of a struct sigaction `object' specifies
SA_SIGINFO, you should and must use sa_sigaction instead of
sa_handler, as stated in the manpage, because sa_handler and
sa_sigaction are a union structure on many architectures, or not
present when rt_* not implemented.
3. An autoconf test was added to look for sa_sigaction in struct
sigaction, as it isn't present on all architectures.

So, while this does fix rt_sigaction01, by and large, the following
issues still exist with the rt_sig* syscalls:
1. SIGRTMIN always SIGSEGV's because signal_fault is being called in
arch/x86/kernel/signal.c . I need to put some printk's in the code to
understand why -EFAULT is being thrown, and thus why signal_fault is
being tossed.
2. rt_sigprocmask01 and rt_sigsuspend01 still segfault for the same
reason, as noted in 1.

    Someone in the kernel.org team should generate some kind of
documentation to clarify several points (including architectural
quirks) with the rt_sig* syscalls. This trial and error problem
solving isn't very helpful and there are a fair number of gotchas
involved with implementing a functional set of sigaction-like calls
using rt_sig*.

Thanks,
-Garrett

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-12-01  0:00                       ` Garrett Cooper
@ 2009-12-09  7:29                         ` liubo
  0 siblings, 0 replies; 34+ messages in thread
From: liubo @ 2009-12-09  7:29 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: Mike Frysinger, ltp-list

Hi,
> Yes. I [mostly] fixed the rt_sigaction01 test a few hours ago. A
> summary of the issues with the old version:
>
> 1. The test as it was written before verified functionality by
> ensuring that coredumps and crashes didn't occur. The new version
> either catches the appropriate rt signal and increments, or catches
> SIGSEGV and continues. Eventually once all of the issues are worked
> out with SIGRTMIN, the known issue TINFO printout needs to be removed
> from include/ltp_signal.h
> 2. If the sa_flags field of a struct sigaction `object' specifies
> SA_SIGINFO, you should and must use sa_sigaction instead of
> sa_handler, as stated in the manpage, because sa_handler and
> sa_sigaction are a union structure on many architectures, or not
> present when rt_* not implemented.
> 3. An autoconf test was added to look for sa_sigaction in struct
> sigaction, as it isn't present on all architectures.
>
> So, while this does fix rt_sigaction01, by and large, the following
> issues still exist with the rt_sig* syscalls:
> 1. SIGRTMIN always SIGSEGV's because signal_fault is being called in
> arch/x86/kernel/signal.c . I need to put some printk's in the code to
> understand why -EFAULT is being thrown, and thus why signal_fault is
> being tossed.
> 2. rt_sigprocmask01 and rt_sigsuspend01 still segfault for the same
> reason, as noted in 1.
>
>     Someone in the kernel.org team should generate some kind of
> documentation to clarify several points (including architectural
> quirks) with the rt_sig* syscalls. This trial and error problem
> solving isn't very helpful and there are a fair number of gotchas
> involved with implementing a functional set of sigaction-like calls
> using rt_sig*.
>
> Thanks,
> -Garrett
>
>
>   
I've made a patch to fix this rt_sig problem, but I encounted a trouble.

I figured out that syscall __NR_rt_sigaction doesn't use struct
sigaction, and glibc defines a
struct called kernel_sigaction to fit __NR_rt_sigaction so that glibc
function can pass it.
And the struct sigaction may change in the future.

My trouble is if we define a struct to fit this syscall just as what
glibc does, after the struct
sigaction change, we'll define another struct as well.

Looking forward to any advice about this trouble...


Thanks,
Liubo 

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-26  0:35             ` liubo
@ 2010-02-27  4:12               ` Garrett Cooper
  0 siblings, 0 replies; 34+ messages in thread
From: Garrett Cooper @ 2010-02-27  4:12 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list

On Thu, Feb 25, 2010 at 4:35 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
> On 02/25/2010 06:00 PM, Garrett Cooper wrote:
>
> On Wed, Feb 24, 2010 at 11:26 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>
>
> Hi Garrett,
>
>     I figured that this patch has not been merged into ltp-cvs.
>     Is there some else problems about this patch?
>
>     I tried looking at it this weekend and got sidetracked (hint:
> please provide me with a complete patchable diff, preferably as a file
> attachment).
>
> Sure, see attachment.

    All of these fixes have been merged into mainline ltp-dev.git.
Thank you very much for the help in tackling this issue!
Cheers,
-Garrett

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-25 10:00           ` Garrett Cooper
@ 2010-02-26  0:35             ` liubo
  2010-02-27  4:12               ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-26  0:35 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 522 bytes --]

On 02/25/2010 06:00 PM, Garrett Cooper wrote:
> On Wed, Feb 24, 2010 at 11:26 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> Hi Garrett,
>>
>>     I figured that this patch has not been merged into ltp-cvs.
>>     Is there some else problems about this patch?
>>
>> Thanks,
>> Liubo
>>     
>
>     I tried looking at it this weekend and got sidetracked (hint:
> please provide me with a complete patchable diff, preferably as a file
> attachment).
> Thanks!
> -Garrett
>
>
>   
Sure, see attachment.

Thanks,
Liubo


[-- Attachment #1.2: Type: text/html, Size: 1057 bytes --]

[-- Attachment #2: 0001-rt_sig.patch --]
[-- Type: text/plain, Size: 11981 bytes --]

From 4c61e30a2006726346550d8627465e1b2e4050cf Mon Sep 17 00:00:00 2001
From: mapleapple <mapleapple@localhost.localdomain>
Date: Mon, 22 Feb 2010 17:12:29 +0800
Subject: [PATCH] rt_sig

---
 include/rt_signal.h                                |   60 +++++++++++++++++
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   69 ++++++++++++--------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
 4 files changed, 136 insertions(+), 38 deletions(-)
 create mode 100644 include/rt_signal.h

diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..ea1e7e3
--- /dev/null
+++ b/include/rt_signal.h
@@ -0,0 +1,60 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) 2009 FUJITSU LIMITED                                         */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#ifndef __LTP_SIGNAL_H
+#define __LTP_SIGNAL_H
+
+/* We do not globally define the SA_RESTORER flag so do it here.  */
+#define HAVE_SA_RESTORER
+#define SA_RESTORER 0x04000000
+
+struct kernel_sigaction {
+	__sighandler_t k_sa_handler;
+	unsigned long sa_flags;
+	void (*sa_restorer) (void);
+	sigset_t sa_mask;
+};
+
+void (*restore_rt) (void);
+
+void
+handler_h(void)
+{
+	return;
+}
+
+/* initial restore_rt for x86_64 */
+void
+sig_initial(int sig)
+{
+	struct sigaction act, oact;
+
+	act.sa_handler = (void *)handler_h;
+	sigemptyset(&act.sa_mask);
+	sigaddset(&act.sa_mask, sig);
+	/* copy act.sa_restorer to kernel */
+	sigaction(sig, &act, &oact);
+	/* copy oact.sa_restorer from kernel */
+	sigaction(sig, &act, &oact);
+	restore_rt = oact.sa_restorer;
+}
+#endif
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index ffc5fa2..c8f5d5f 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -55,6 +55,10 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
 /*
  * For all but __mips__:
  *
@@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number of tests in this file.   *
 /*              On success - Exits calling tst_exit(). With '0' return code.  */
 /*                                                                            */
 /******************************************************************************/
-extern void cleanup() {
-        /* Remove tmp dir and all files in it */
-        TEST_CLEANUP;
-        tst_rmdir();
+extern void cleanup() 
+{
+	/* Remove tmp dir and all files in it */
+	TEST_CLEANUP;
+	tst_rmdir();
 
-        /* Exit with appropriate return code. */
-        tst_exit();
+	/* Exit with appropriate return code. */
+	tst_exit();
 }
 
 /* Local  Functions */
@@ -128,11 +133,12 @@ extern void cleanup() {
 /*              On success - returns 0.                                       */
 /*                                                                            */
 /******************************************************************************/
-void setup() {
-        /* Capture signals if any */
-        /* Create temporary directories */
-        TEST_PAUSE;
-        tst_tmpdir();
+void setup() 
+{
+	/* Capture signals if any */
+	/* Create temporary directories */
+	TEST_PAUSE;
+	tst_tmpdir();
 }
 
 int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
@@ -144,22 +150,23 @@ handler(int sig)
         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
         return;
 }
-
 int
-set_handler(int sig, int sig_to_mask, int mask_flags)
+set_handler(int sig, int mask_flags)
 {
-        struct sigaction sa, oldaction;
-
-                sa.sa_sigaction = (void *)handler;
-                sa.sa_flags = mask_flags;
-                sigemptyset(&sa.sa_mask);
-                sigaddset(&sa.sa_mask, sig_to_mask);
-                TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
-        if (TEST_RETURN == 0) {
-                return 0;
-        } else {
-                        return TEST_RETURN;
-        }
+#ifdef __x86_64__
+	struct kernel_sigaction sa, oldaction;
+	mask_flags |= SA_RESTORER;
+	sa.sa_restorer = restore_rt;
+	sa.k_sa_handler = (void *)handler;
+#else
+	struct sigaction sa, oldaction;
+	sa.sa_handler = (void *)handler;
+#endif
+	sa.sa_flags = mask_flags;
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, sig);
+	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
+	return TEST_RETURN;
 }
 
 
@@ -167,6 +174,7 @@ int main(int ac, char **av) {
 	int signal, flag;
         int lc;                 /* loop counter */
         char *msg;              /* message returned from parse_opts */
+	int fc;			/* flag counter */
 	
         /* parse standard options */
         if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
@@ -179,11 +187,16 @@ int main(int ac, char **av) {
         /* Check looping state if -i option given */
         for (lc = 0; TEST_LOOPING(lc); ++lc) {
                 Tst_count = 0;
-                for (testno = 0; testno < TST_TOTAL; ++testno) {
+		fc = sizeof (test_flags) / sizeof (test_flags[0]);
+
+		for (testno = 0; testno < TST_TOTAL; ++testno) {
                 
 			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
-			 	for(flag=0; flag<5;flag++) {
-	                        	 TEST(set_handler(signal, 0, test_flags[flag]));
+#ifdef __x86_64__
+				sig_initial(signal);
+#endif
+				for(flag=0; flag<fc;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
 						 if (TEST_RETURN == 0) {
         					tst_resm(TINFO,"signal: %d ", signal);
         					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..5b292b2 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -62,6 +62,12 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
+#define TEST_SIG SIGRTMIN+1
+
 /* Extern Global Variables */
 extern int Tst_count;           /* counter for tst_xxx routines.         */
 extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
@@ -131,7 +137,16 @@ void sig_handler(int sig)
 }
 
 int main(int ac, char **av) {
-	struct sigaction act, oact;
+#ifdef __x86_64__
+	struct kernel_sigaction act, oact;
+	sig_initial(TEST_SIG);
+	act.sa_flags |= SA_RESTORER;
+        act.sa_restorer = restore_rt;
+        act.k_sa_handler = sig_handler;
+#else
+        struct sigaction act, oact;
+        act.sa_handler = sig_handler;
+#endif
         sigset_t set, oset;
         int lc;                 /* loop counter */
         char *msg;              /* message returned from parse_opts */
@@ -154,22 +169,21 @@ int main(int ac, char **av) {
                         	cleanup();
 				tst_exit();
 			}
-			TEST(sigaddset(&set, 33));
+			TEST(sigaddset(&set, TEST_SIG));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
 				tst_exit();
 			}
-			
+				
 			/* call rt_sigaction() */
-			act.sa_handler = sig_handler;
-                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
+                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
 			if(TEST_RETURN != 0){
 				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
 				tst_exit();
 			}
-			/* call rt_sigprocmask() to block signal#33 */
+			/* call rt_sigprocmask() to block signal#SIGRTMIN */
                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
@@ -178,7 +192,7 @@ int main(int ac, char **av) {
 			}
 			
 			else {
-				TEST(kill(getpid(), 33));
+				TEST(kill(getpid(), TEST_SIG));
 				if(TEST_RETURN != 0){
 					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         		cleanup();
@@ -198,13 +212,13 @@ int main(int ac, char **av) {
                         			cleanup();
 						tst_exit();
 					}
-					TEST(sigismember(&oset, 33));
+					TEST(sigismember(&oset, TEST_SIG));
 					if(TEST_RETURN == 0 ){
 						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         			cleanup();
 						tst_exit();
 					}
-					/* call rt_sigprocmask() to unblock signal#33 */
+					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
 					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
 					if(TEST_RETURN == -1){
 						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -47,6 +47,10 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
 /* Extern Global Variables */
 extern int Tst_count;           /* counter for tst_xxx routines.         */
 extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
@@ -139,9 +143,16 @@ int main(int ac, char **av) {
 				cleanup();
 				tst_exit();
 			}
+#ifdef __x86_64__
+		        struct kernel_sigaction act, oact;
+			sig_initial(SIGALRM);
+			act.sa_flags |= SA_RESTORER;
+			act.sa_restorer = restore_rt;
+			act.k_sa_handler = sig_handler;			
+#else
 			struct sigaction act, oact;
 		        act.sa_handler = sig_handler;
-			
+#endif
 			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
 			if(TEST_RETURN == -1){
 		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
-- 
1.6.2.2


[-- Attachment #3: Type: text/plain, Size: 345 bytes --]

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-25  7:26         ` liubo
@ 2010-02-25 10:00           ` Garrett Cooper
  2010-02-26  0:35             ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2010-02-25 10:00 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list

On Wed, Feb 24, 2010 at 11:26 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
> Hi Garrett,
>
>     I figured that this patch has not been merged into ltp-cvs.
>     Is there some else problems about this patch?
>
> Thanks,
> Liubo

    I tried looking at it this weekend and got sidetracked (hint:
please provide me with a complete patchable diff, preferably as a file
attachment).
Thanks!
-Garrett

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-23  0:59       ` liubo
@ 2010-02-25  7:26         ` liubo
  2010-02-25 10:00           ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-25  7:26 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 17889 bytes --]

Hi Garrett,

    I figured that this patch has not been merged into ltp-cvs.
    Is there some else problems about this patch?

Thanks,
Liubo

On 02/23/2010 08:59 AM, liubo wrote:
> Hi, Garrett,
> My revised patch has been "Acked/Tested-By: Rishikesh K
> Rajak<risrajak@linux.vnet.ibm.com>"
>
> url: http://marc.info/?l=ltp-list&m=126683033423523&w=2
>
> Thanks,
> Liubo
>
> On 02/23/2010 02:05 AM, Garrett Cooper wrote:
>   
>> On Mon, Feb 22, 2010 at 1:08 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>   
>>     
>>> On 02/22/2010 03:56 PM, Garrett Cooper wrote:
>>>
>>> By and large this diff looks really good. My comments...
>>>
>>> On Sun, Feb 21, 2010 at 9:21 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>>
>>>
>>> - rt_sigaction01
>>> On arch x86_64, if we directly get to call syscall
>>> rt_sigaction, there will be "segment fault".
>>> 1) One reason is that we must supply the flag of
>>> "SA_RESTORER" and the correct pointer to the fuction
>>> "restorer", according to the kernel code.
>>> 2) The other reason is that default syscall rt_sigaction
>>> use kernel "sigaction" structure, which is different
>>> with normal "sigaction" structure.
>>>
>>> So,
>>> 1) We manage to find the address of the function
>>> "restorer" by using glibc function "sigaction",
>>> which might be something tricky. Then we add these
>>> arguments to make test run correctly.
>>> 2) We also use kernel "sigaction" structure to fit
>>> realtime syscall __NR_rt_sigaction.
>>>
>>> - rt_sigprocmask01
>>> First, there exsits the same problem as rt_sigaction01.
>>> Second, this testcase uses a unchanged signal number 33,
>>> which may diff among different archs and lead to error
>>> "unknown signal".
>>>
>>> So, we use a macro TEST_SIG which refers to SIGRTMIN
>>> to replace 33.
>>>
>>>
>>> The problem is that SIGRTMIN is actually signal 32, not signal 33, and
>>> here's a problematic comment to ponder over (from bits/signum.h):
>>>
>>> /* These are the hard limits of the kernel.  These values should not be
>>>    used directly at user level.  */
>>> #define __SIGRTMIN      32
>>> #define __SIGRTMAX      (_NSIG - 1)
>>>
>>> I think the proper resolution would be to make the value SIGRTMIN+1.
>>>
>>>
>>>
>>> Hi, Garrett,
>>>
>>> In fact, I'm confused about whether #33 signal is particularly needed here,
>>> in some of my boxes, SIGRTMIN actually refers #34 signal, that is,
>>> #33 is unreachable.
>>>
>>> IMO, any realtime reachable signal can be used to pass the case here, and
>>> I pick SIGRTMIN by define a macro: #define TEST_SIG SIGRTMIN.
>>>
>>> Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your
>>> value.
>>>
>>> If you are free, looking forward to your explaination ...
>>>     
>>>       
>> Several signals between the non-RT and non-reserved RT signals are
>> used by [the now defunct] linuxthreads and nptl. See the following
>> page which refers to a very old school copy of LTP :]...:
>>
>> http://www.redhat.com/archives/phil-list/2003-April/msg00049.html
>>
>>   
>>     
>
> ok , got it.
>   
>>> - rt_sigsuspend01
>>> There exists the same problem as rt_sigaction01.
>>>
>>> This patch fixed these failure.
>>>
>>> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
>>>
>>> ---
>>>  include/rt_signal.h                                |   60
>>> ++++++++++++++++++
>>>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   64
>>> +++++++++++--------
>>>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
>>>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
>>>  4 files changed, 132 insertions(+), 37 deletions(-)
>>>  create mode 100644 include/rt_signal.h
>>>
>>> diff --git a/include/rt_signal.h b/include/rt_signal.h
>>> new file mode 100644
>>> index 0000000..ea1e7e3
>>> --- /dev/null
>>> +++ b/include/rt_signal.h
>>> @@ -0,0 +1,60 @@
>>> +/******************************************************************************/
>>> +/*
>>>    */
>>> +/* Copyright (c) 2009 FUJITSU LIMITED
>>>   */
>>> +/*
>>>    */
>>> +/* This program is free software;  you can redistribute it and/or modify
>>>    */
>>> +/* it under the terms of the GNU General Public License as published by
>>>   */
>>> +/* the Free Software Foundation; either version 2 of the License, or
>>>    */
>>> +/* (at your option) any later version.
>>>    */
>>> +/*
>>>    */
>>> +/* This program is distributed in the hope that it will be useful,
>>>    */
>>> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of
>>>    */
>>> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
>>>    */
>>> +/* the GNU General Public License for more details.
>>>   */
>>> +/*
>>>    */
>>> +/* You should have received a copy of the GNU General Public License
>>>    */
>>> +/* along with this program;  if not, write to the Free Software
>>>   */
>>> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>>>    */
>>> +/*
>>>    */
>>> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>
>>>    */
>>> +/*
>>>    */
>>> +/******************************************************************************/
>>> +
>>> +#ifndef __LTP_SIGNAL_H
>>> +#define __LTP_SIGNAL_H
>>> +
>>> +/* We do not globally define the SA_RESTORER flag so do it here.  */
>>> +#define HAVE_SA_RESTORER
>>> +#define SA_RESTORER 0x04000000
>>> +
>>> +struct kernel_sigaction {
>>> +       __sighandler_t k_sa_handler;
>>> +       unsigned long sa_flags;
>>> +       void (*sa_restorer) (void);
>>> +       sigset_t sa_mask;
>>> +};
>>> +
>>> +void (*restore_rt) (void);
>>> +
>>> +void
>>> +handler_h(void)
>>> +{
>>> +       return;
>>> +}
>>> +
>>> +/* initial restore_rt for x86_64 */
>>> +void
>>> +sig_initial(int sig)
>>> +{
>>> +       struct sigaction act, oact;
>>> +
>>> +       act.sa_handler = (void *)handler_h;
>>> +       sigemptyset(&act.sa_mask);
>>> +       sigaddset(&act.sa_mask, sig);
>>> +       /* copy act.sa_restorer to kernel */
>>> +       sigaction(sig, &act, &oact);
>>> +       /* copy oact.sa_restorer from kernel */
>>> +       sigaction(sig, &act, &oact);
>>> +       restore_rt = oact.sa_restorer;
>>> +}
>>> +#endif
>>> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>>> b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>>> index ffc5fa2..d30f204 100644
>>> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>>> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>>> @@ -55,6 +55,10 @@
>>>  #include "usctest.h"
>>>  #include "linux_syscall_numbers.h"
>>>
>>> +#ifdef __x86_64__
>>> +#include "rt_signal.h"
>>> +#endif
>>> +
>>>  /*
>>>  * For all but __mips__:
>>>  *
>>> @@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number
>>> of tests in this file.   *
>>>  /*              On success - Exits calling tst_exit(). With '0' return
>>> code.  */
>>>  /*
>>>    */
>>>  /******************************************************************************/
>>> -extern void cleanup() {
>>> -        /* Remove tmp dir and all files in it */
>>> -        TEST_CLEANUP;
>>> -        tst_rmdir();
>>> +extern void cleanup()
>>> +{
>>> +       /* Remove tmp dir and all files in it */
>>> +       TEST_CLEANUP;
>>> +       tst_rmdir();
>>>
>>> -        /* Exit with appropriate return code. */
>>> -        tst_exit();
>>> +       /* Exit with appropriate return code. */
>>> +       tst_exit();
>>>  }
>>>
>>>  /* Local  Functions */
>>> @@ -128,11 +133,12 @@ extern void cleanup() {
>>>  /*              On success - returns 0.
>>>   */
>>>  /*
>>>    */
>>>  /******************************************************************************/
>>> -void setup() {
>>> -        /* Capture signals if any */
>>> -        /* Create temporary directories */
>>> -        TEST_PAUSE;
>>> -        tst_tmpdir();
>>> +void setup()
>>> +{
>>> +       /* Capture signals if any */
>>> +       /* Create temporary directories */
>>> +       TEST_PAUSE;
>>> +       tst_tmpdir();
>>>  }
>>>
>>>  int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND,
>>> SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
>>> @@ -144,22 +150,23 @@ handler(int sig)
>>>         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
>>>         return;
>>>  }
>>> -
>>>  int
>>> -set_handler(int sig, int sig_to_mask, int mask_flags)
>>> +set_handler(int sig, int mask_flags)
>>>  {
>>> -        struct sigaction sa, oldaction;
>>> -
>>> -                sa.sa_sigaction = (void *)handler;
>>> -                sa.sa_flags = mask_flags;
>>> -                sigemptyset(&sa.sa_mask);
>>> -                sigaddset(&sa.sa_mask, sig_to_mask);
>>> -                TEST(syscall(__NR_rt_sigaction,sig, &sa,
>>> &oldaction,SIGSETSIZE));
>>> -        if (TEST_RETURN == 0) {
>>> -                return 0;
>>> -        } else {
>>> -                        return TEST_RETURN;
>>> -        }
>>> +#ifdef __x86_64__
>>> +       struct kernel_sigaction sa, oldaction;
>>> +       mask_flags |= SA_RESTORER;
>>> +       sa.sa_restorer = restore_rt;
>>> +       sa.k_sa_handler = (void *)handler;
>>> +#else
>>> +       struct sigaction sa, oldaction;
>>> +       sa.sa_handler = (void *)handler;
>>> +#endif
>>> +       sa.sa_flags = mask_flags;
>>> +       sigemptyset(&sa.sa_mask);
>>> +       sigaddset(&sa.sa_mask, sig);
>>> +       TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
>>> +       return TEST_RETURN;
>>>  }
>>>
>>>
>>> @@ -182,8 +189,11 @@ int main(int ac, char **av) {
>>>                 for (testno = 0; testno < TST_TOTAL; ++testno) {
>>>
>>>                        for (signal = SIGRTMIN; signal <= (SIGRTMAX );
>>> signal++){//signal for 34 to 65
>>> -                               for(flag=0; flag<5;flag++) {
>>> -                                        TEST(set_handler(signal, 0,
>>> test_flags[flag]));
>>> +#ifdef __x86_64__
>>> +                               sig_initial(signal);
>>> +#endif
>>> +                               for(flag=0; flag<5;flag++) {
>>> +                                        TEST(set_handler(signal,
>>> test_flags[flag]));
>>>
>>>
>>> I know this isn't your code change, but since you're here.. a better
>>> way to do this would be:
>>>
>>> sizeof (test_flags) / sizeof (test_flags[0])
>>>
>>> as this is a fixed array buffer.
>>>
>>>
>>> Sure, this can increase codes's portability.
>>>
>>> I'm generating a new version patch.
>>>     
>>>       
>> The less we have to modify code in the future, the better... Cheers!
>>
>>   
>>     
>>>                                                 if (TEST_RETURN == 0) {
>>>                                                tst_resm(TINFO,"signal: %d ",
>>> signal);
>>>                                                tst_resm(TPASS, "rt_sigaction
>>> call succeeded: result = %ld ",TEST_RETURN );
>>> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>>> b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>>> index 6398a28..8bcdc78 100644
>>> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>>> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>>> @@ -62,6 +62,12 @@
>>>  #include "usctest.h"
>>>  #include "linux_syscall_numbers.h"
>>>
>>> +#ifdef __x86_64__
>>> +#include "rt_signal.h"
>>> +#endif
>>> +
>>> +#define TEST_SIG SIGRTMIN
>>> +
>>>  /* Extern Global Variables */
>>>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>>>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>>> @@ -131,7 +137,16 @@ void sig_handler(int sig)
>>>  }
>>>
>>>  int main(int ac, char **av) {
>>> -       struct sigaction act, oact;
>>> +#ifdef __x86_64__
>>> +       struct kernel_sigaction act, oact;
>>> +       sig_initial(TEST_SIG);
>>> +       act.sa_flags |= SA_RESTORER;
>>> +        act.sa_restorer = restore_rt;
>>> +        act.k_sa_handler = sig_handler;
>>> +#else
>>> +        struct sigaction act, oact;
>>> +        act.sa_handler = sig_handler;
>>> +#endif
>>>         sigset_t set, oset;
>>>         int lc;                 /* loop counter */
>>>         char *msg;              /* message returned from parse_opts */
>>> @@ -154,22 +169,21 @@ int main(int ac, char **av) {
>>>                                cleanup();
>>>                                tst_exit();
>>>                        }
>>> -                       TEST(sigaddset(&set, 33));
>>> +                       TEST(sigaddset(&set, TEST_SIG));
>>>                        if(TEST_RETURN == -1){
>>>                                tst_resm(TFAIL,"Call to sigaddset() Failed,
>>> errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>>                                cleanup();
>>>                                tst_exit();
>>>                        }
>>> -
>>> +
>>>                        /* call rt_sigaction() */
>>> -                       act.sa_handler = sig_handler;
>>> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact,
>>> 8));
>>> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act,
>>> &oact, 8));
>>>                        if(TEST_RETURN != 0){
>>>                                tst_resm(TFAIL,"Call to rt_sigaction()
>>> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>>                                cleanup();
>>>                                tst_exit();
>>>                        }
>>> -                       /* call rt_sigprocmask() to block signal#33 */
>>> +                       /* call rt_sigprocmask() to block signal#SIGRTMIN */
>>>                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,
>>> &oset, 8));
>>>                        if(TEST_RETURN == -1){
>>>                                tst_resm(TFAIL,"Call to rt_sigprocmask()****
>>> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>> @@ -178,7 +192,7 @@ int main(int ac, char **av) {
>>>                        }
>>>
>>>                        else {
>>> -                               TEST(kill(getpid(), 33));
>>> +                               TEST(kill(getpid(), TEST_SIG));
>>>                                if(TEST_RETURN != 0){
>>>                                        tst_resm(TFAIL,"Call to kill()
>>> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>>                                        cleanup();
>>> @@ -198,13 +212,13 @@ int main(int ac, char **av) {
>>>                                                cleanup();
>>>                                                tst_exit();
>>>                                        }
>>> -                                       TEST(sigismember(&oset, 33));
>>> +                                       TEST(sigismember(&oset, TEST_SIG));
>>>                                        if(TEST_RETURN == 0 ){
>>>                                                tst_resm(TFAIL,"call
>>> sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>>                                                cleanup();
>>>                                                tst_exit();
>>>                                        }
>>> -                                       /* call rt_sigprocmask() to unblock
>>> signal#33 */
>>> +                                       /* call rt_sigprocmask() to unblock
>>> signal#SIGRTMIN */
>>>                                        TEST(syscall(__NR_rt_sigprocmask,
>>> SIG_UNBLOCK, &set, &oset, 8));
>>>                                        if(TEST_RETURN == -1){
>>>                                                tst_resm(TFAIL,"Call to
>>> rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>>> b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>>> index 416a7c9..84f2967 100644
>>> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>>> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>>> @@ -47,6 +47,10 @@
>>>  #include "usctest.h"
>>>  #include "linux_syscall_numbers.h"
>>>
>>> +#ifdef __x86_64__
>>> +#include "rt_signal.h"
>>> +#endif
>>> +
>>>  /* Extern Global Variables */
>>>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>>>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>>> @@ -139,9 +143,16 @@ int main(int ac, char **av) {
>>>                                cleanup();
>>>                                tst_exit();
>>>                        }
>>> +#ifdef __x86_64__
>>> +                       struct kernel_sigaction act, oact;
>>> +                       sig_initial(SIGALRM);
>>> +                       act.sa_flags |= SA_RESTORER;
>>> +                       act.sa_restorer = restore_rt;
>>> +                       act.k_sa_handler = sig_handler;
>>> +#else
>>>                        struct sigaction act, oact;
>>>                        act.sa_handler = sig_handler;
>>> -
>>> +#endif
>>>                        TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
>>> 8));
>>>                        if(TEST_RETURN == -1){
>>>                                tst_resm(TFAIL,"rt_sigaction() Failed,
>>> errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>> --
>>> 1.6.2.2
>>>
>>>
>>>
>>>
>>>     
>>>       
>>   
>>     
>
>
>   
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>   


[-- Attachment #1.2: Type: text/html, Size: 17869 bytes --]

[-- Attachment #2: Type: text/plain, Size: 345 bytes --]

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-22 18:05     ` Garrett Cooper
@ 2010-02-23  0:59       ` liubo
  2010-02-25  7:26         ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-23  0:59 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 16481 bytes --]

Hi, Garrett,
My revised patch has been "Acked/Tested-By: Rishikesh K
Rajak<risrajak@linux.vnet.ibm.com>"

url: http://marc.info/?l=ltp-list&m=126683033423523&w=2

Thanks,
Liubo

On 02/23/2010 02:05 AM, Garrett Cooper wrote:
> On Mon, Feb 22, 2010 at 1:08 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> On 02/22/2010 03:56 PM, Garrett Cooper wrote:
>>
>> By and large this diff looks really good. My comments...
>>
>> On Sun, Feb 21, 2010 at 9:21 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>
>>
>> - rt_sigaction01
>> On arch x86_64, if we directly get to call syscall
>> rt_sigaction, there will be "segment fault".
>> 1) One reason is that we must supply the flag of
>> "SA_RESTORER" and the correct pointer to the fuction
>> "restorer", according to the kernel code.
>> 2) The other reason is that default syscall rt_sigaction
>> use kernel "sigaction" structure, which is different
>> with normal "sigaction" structure.
>>
>> So,
>> 1) We manage to find the address of the function
>> "restorer" by using glibc function "sigaction",
>> which might be something tricky. Then we add these
>> arguments to make test run correctly.
>> 2) We also use kernel "sigaction" structure to fit
>> realtime syscall __NR_rt_sigaction.
>>
>> - rt_sigprocmask01
>> First, there exsits the same problem as rt_sigaction01.
>> Second, this testcase uses a unchanged signal number 33,
>> which may diff among different archs and lead to error
>> "unknown signal".
>>
>> So, we use a macro TEST_SIG which refers to SIGRTMIN
>> to replace 33.
>>
>>
>> The problem is that SIGRTMIN is actually signal 32, not signal 33, and
>> here's a problematic comment to ponder over (from bits/signum.h):
>>
>> /* These are the hard limits of the kernel.  These values should not be
>>    used directly at user level.  */
>> #define __SIGRTMIN      32
>> #define __SIGRTMAX      (_NSIG - 1)
>>
>> I think the proper resolution would be to make the value SIGRTMIN+1.
>>
>>
>>
>> Hi, Garrett,
>>
>> In fact, I'm confused about whether #33 signal is particularly needed here,
>> in some of my boxes, SIGRTMIN actually refers #34 signal, that is,
>> #33 is unreachable.
>>
>> IMO, any realtime reachable signal can be used to pass the case here, and
>> I pick SIGRTMIN by define a macro: #define TEST_SIG SIGRTMIN.
>>
>> Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your
>> value.
>>
>> If you are free, looking forward to your explaination ...
>>     
>
> Several signals between the non-RT and non-reserved RT signals are
> used by [the now defunct] linuxthreads and nptl. See the following
> page which refers to a very old school copy of LTP :]...:
>
> http://www.redhat.com/archives/phil-list/2003-April/msg00049.html
>
>   

ok , got it.
>> - rt_sigsuspend01
>> There exists the same problem as rt_sigaction01.
>>
>> This patch fixed these failure.
>>
>> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
>>
>> ---
>>  include/rt_signal.h                                |   60
>> ++++++++++++++++++
>>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   64
>> +++++++++++--------
>>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
>>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
>>  4 files changed, 132 insertions(+), 37 deletions(-)
>>  create mode 100644 include/rt_signal.h
>>
>> diff --git a/include/rt_signal.h b/include/rt_signal.h
>> new file mode 100644
>> index 0000000..ea1e7e3
>> --- /dev/null
>> +++ b/include/rt_signal.h
>> @@ -0,0 +1,60 @@
>> +/******************************************************************************/
>> +/*
>>    */
>> +/* Copyright (c) 2009 FUJITSU LIMITED
>>   */
>> +/*
>>    */
>> +/* This program is free software;  you can redistribute it and/or modify
>>    */
>> +/* it under the terms of the GNU General Public License as published by
>>   */
>> +/* the Free Software Foundation; either version 2 of the License, or
>>    */
>> +/* (at your option) any later version.
>>    */
>> +/*
>>    */
>> +/* This program is distributed in the hope that it will be useful,
>>    */
>> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of
>>    */
>> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
>>    */
>> +/* the GNU General Public License for more details.
>>   */
>> +/*
>>    */
>> +/* You should have received a copy of the GNU General Public License
>>    */
>> +/* along with this program;  if not, write to the Free Software
>>   */
>> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>>    */
>> +/*
>>    */
>> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>
>>    */
>> +/*
>>    */
>> +/******************************************************************************/
>> +
>> +#ifndef __LTP_SIGNAL_H
>> +#define __LTP_SIGNAL_H
>> +
>> +/* We do not globally define the SA_RESTORER flag so do it here.  */
>> +#define HAVE_SA_RESTORER
>> +#define SA_RESTORER 0x04000000
>> +
>> +struct kernel_sigaction {
>> +       __sighandler_t k_sa_handler;
>> +       unsigned long sa_flags;
>> +       void (*sa_restorer) (void);
>> +       sigset_t sa_mask;
>> +};
>> +
>> +void (*restore_rt) (void);
>> +
>> +void
>> +handler_h(void)
>> +{
>> +       return;
>> +}
>> +
>> +/* initial restore_rt for x86_64 */
>> +void
>> +sig_initial(int sig)
>> +{
>> +       struct sigaction act, oact;
>> +
>> +       act.sa_handler = (void *)handler_h;
>> +       sigemptyset(&act.sa_mask);
>> +       sigaddset(&act.sa_mask, sig);
>> +       /* copy act.sa_restorer to kernel */
>> +       sigaction(sig, &act, &oact);
>> +       /* copy oact.sa_restorer from kernel */
>> +       sigaction(sig, &act, &oact);
>> +       restore_rt = oact.sa_restorer;
>> +}
>> +#endif
>> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> index ffc5fa2..d30f204 100644
>> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> @@ -55,6 +55,10 @@
>>  #include "usctest.h"
>>  #include "linux_syscall_numbers.h"
>>
>> +#ifdef __x86_64__
>> +#include "rt_signal.h"
>> +#endif
>> +
>>  /*
>>  * For all but __mips__:
>>  *
>> @@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number
>> of tests in this file.   *
>>  /*              On success - Exits calling tst_exit(). With '0' return
>> code.  */
>>  /*
>>    */
>>  /******************************************************************************/
>> -extern void cleanup() {
>> -        /* Remove tmp dir and all files in it */
>> -        TEST_CLEANUP;
>> -        tst_rmdir();
>> +extern void cleanup()
>> +{
>> +       /* Remove tmp dir and all files in it */
>> +       TEST_CLEANUP;
>> +       tst_rmdir();
>>
>> -        /* Exit with appropriate return code. */
>> -        tst_exit();
>> +       /* Exit with appropriate return code. */
>> +       tst_exit();
>>  }
>>
>>  /* Local  Functions */
>> @@ -128,11 +133,12 @@ extern void cleanup() {
>>  /*              On success - returns 0.
>>   */
>>  /*
>>    */
>>  /******************************************************************************/
>> -void setup() {
>> -        /* Capture signals if any */
>> -        /* Create temporary directories */
>> -        TEST_PAUSE;
>> -        tst_tmpdir();
>> +void setup()
>> +{
>> +       /* Capture signals if any */
>> +       /* Create temporary directories */
>> +       TEST_PAUSE;
>> +       tst_tmpdir();
>>  }
>>
>>  int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND,
>> SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
>> @@ -144,22 +150,23 @@ handler(int sig)
>>         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
>>         return;
>>  }
>> -
>>  int
>> -set_handler(int sig, int sig_to_mask, int mask_flags)
>> +set_handler(int sig, int mask_flags)
>>  {
>> -        struct sigaction sa, oldaction;
>> -
>> -                sa.sa_sigaction = (void *)handler;
>> -                sa.sa_flags = mask_flags;
>> -                sigemptyset(&sa.sa_mask);
>> -                sigaddset(&sa.sa_mask, sig_to_mask);
>> -                TEST(syscall(__NR_rt_sigaction,sig, &sa,
>> &oldaction,SIGSETSIZE));
>> -        if (TEST_RETURN == 0) {
>> -                return 0;
>> -        } else {
>> -                        return TEST_RETURN;
>> -        }
>> +#ifdef __x86_64__
>> +       struct kernel_sigaction sa, oldaction;
>> +       mask_flags |= SA_RESTORER;
>> +       sa.sa_restorer = restore_rt;
>> +       sa.k_sa_handler = (void *)handler;
>> +#else
>> +       struct sigaction sa, oldaction;
>> +       sa.sa_handler = (void *)handler;
>> +#endif
>> +       sa.sa_flags = mask_flags;
>> +       sigemptyset(&sa.sa_mask);
>> +       sigaddset(&sa.sa_mask, sig);
>> +       TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
>> +       return TEST_RETURN;
>>  }
>>
>>
>> @@ -182,8 +189,11 @@ int main(int ac, char **av) {
>>                 for (testno = 0; testno < TST_TOTAL; ++testno) {
>>
>>                        for (signal = SIGRTMIN; signal <= (SIGRTMAX );
>> signal++){//signal for 34 to 65
>> -                               for(flag=0; flag<5;flag++) {
>> -                                        TEST(set_handler(signal, 0,
>> test_flags[flag]));
>> +#ifdef __x86_64__
>> +                               sig_initial(signal);
>> +#endif
>> +                               for(flag=0; flag<5;flag++) {
>> +                                        TEST(set_handler(signal,
>> test_flags[flag]));
>>
>>
>> I know this isn't your code change, but since you're here.. a better
>> way to do this would be:
>>
>> sizeof (test_flags) / sizeof (test_flags[0])
>>
>> as this is a fixed array buffer.
>>
>>
>> Sure, this can increase codes's portability.
>>
>> I'm generating a new version patch.
>>     
>
> The less we have to modify code in the future, the better... Cheers!
>
>   
>>                                                 if (TEST_RETURN == 0) {
>>                                                tst_resm(TINFO,"signal: %d ",
>> signal);
>>                                                tst_resm(TPASS, "rt_sigaction
>> call succeeded: result = %ld ",TEST_RETURN );
>> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> index 6398a28..8bcdc78 100644
>> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> @@ -62,6 +62,12 @@
>>  #include "usctest.h"
>>  #include "linux_syscall_numbers.h"
>>
>> +#ifdef __x86_64__
>> +#include "rt_signal.h"
>> +#endif
>> +
>> +#define TEST_SIG SIGRTMIN
>> +
>>  /* Extern Global Variables */
>>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>> @@ -131,7 +137,16 @@ void sig_handler(int sig)
>>  }
>>
>>  int main(int ac, char **av) {
>> -       struct sigaction act, oact;
>> +#ifdef __x86_64__
>> +       struct kernel_sigaction act, oact;
>> +       sig_initial(TEST_SIG);
>> +       act.sa_flags |= SA_RESTORER;
>> +        act.sa_restorer = restore_rt;
>> +        act.k_sa_handler = sig_handler;
>> +#else
>> +        struct sigaction act, oact;
>> +        act.sa_handler = sig_handler;
>> +#endif
>>         sigset_t set, oset;
>>         int lc;                 /* loop counter */
>>         char *msg;              /* message returned from parse_opts */
>> @@ -154,22 +169,21 @@ int main(int ac, char **av) {
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> -                       TEST(sigaddset(&set, 33));
>> +                       TEST(sigaddset(&set, TEST_SIG));
>>                        if(TEST_RETURN == -1){
>>                                tst_resm(TFAIL,"Call to sigaddset() Failed,
>> errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> -
>> +
>>                        /* call rt_sigaction() */
>> -                       act.sa_handler = sig_handler;
>> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact,
>> 8));
>> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act,
>> &oact, 8));
>>                        if(TEST_RETURN != 0){
>>                                tst_resm(TFAIL,"Call to rt_sigaction()
>> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> -                       /* call rt_sigprocmask() to block signal#33 */
>> +                       /* call rt_sigprocmask() to block signal#SIGRTMIN */
>>                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,
>> &oset, 8));
>>                        if(TEST_RETURN == -1){
>>                                tst_resm(TFAIL,"Call to rt_sigprocmask()****
>> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>> @@ -178,7 +192,7 @@ int main(int ac, char **av) {
>>                        }
>>
>>                        else {
>> -                               TEST(kill(getpid(), 33));
>> +                               TEST(kill(getpid(), TEST_SIG));
>>                                if(TEST_RETURN != 0){
>>                                        tst_resm(TFAIL,"Call to kill()
>> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                        cleanup();
>> @@ -198,13 +212,13 @@ int main(int ac, char **av) {
>>                                                cleanup();
>>                                                tst_exit();
>>                                        }
>> -                                       TEST(sigismember(&oset, 33));
>> +                                       TEST(sigismember(&oset, TEST_SIG));
>>                                        if(TEST_RETURN == 0 ){
>>                                                tst_resm(TFAIL,"call
>> sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                                cleanup();
>>                                                tst_exit();
>>                                        }
>> -                                       /* call rt_sigprocmask() to unblock
>> signal#33 */
>> +                                       /* call rt_sigprocmask() to unblock
>> signal#SIGRTMIN */
>>                                        TEST(syscall(__NR_rt_sigprocmask,
>> SIG_UNBLOCK, &set, &oset, 8));
>>                                        if(TEST_RETURN == -1){
>>                                                tst_resm(TFAIL,"Call to
>> rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> index 416a7c9..84f2967 100644
>> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> @@ -47,6 +47,10 @@
>>  #include "usctest.h"
>>  #include "linux_syscall_numbers.h"
>>
>> +#ifdef __x86_64__
>> +#include "rt_signal.h"
>> +#endif
>> +
>>  /* Extern Global Variables */
>>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>> @@ -139,9 +143,16 @@ int main(int ac, char **av) {
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> +#ifdef __x86_64__
>> +                       struct kernel_sigaction act, oact;
>> +                       sig_initial(SIGALRM);
>> +                       act.sa_flags |= SA_RESTORER;
>> +                       act.sa_restorer = restore_rt;
>> +                       act.k_sa_handler = sig_handler;
>> +#else
>>                        struct sigaction act, oact;
>>                        act.sa_handler = sig_handler;
>> -
>> +#endif
>>                        TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
>> 8));
>>                        if(TEST_RETURN == -1){
>>                                tst_resm(TFAIL,"rt_sigaction() Failed,
>> errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>> --
>> 1.6.2.2
>>
>>
>>
>>
>>     
>
>
>   


[-- Attachment #1.2: Type: text/html, Size: 24408 bytes --]

[-- Attachment #2: Type: text/plain, Size: 345 bytes --]

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-22  9:08   ` liubo
@ 2010-02-22 18:05     ` Garrett Cooper
  2010-02-23  0:59       ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2010-02-22 18:05 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list

On Mon, Feb 22, 2010 at 1:08 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
> On 02/22/2010 03:56 PM, Garrett Cooper wrote:
>
> By and large this diff looks really good. My comments...
>
> On Sun, Feb 21, 2010 at 9:21 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>
>
> - rt_sigaction01
> On arch x86_64, if we directly get to call syscall
> rt_sigaction, there will be "segment fault".
> 1) One reason is that we must supply the flag of
> "SA_RESTORER" and the correct pointer to the fuction
> "restorer", according to the kernel code.
> 2) The other reason is that default syscall rt_sigaction
> use kernel "sigaction" structure, which is different
> with normal "sigaction" structure.
>
> So,
> 1) We manage to find the address of the function
> "restorer" by using glibc function "sigaction",
> which might be something tricky. Then we add these
> arguments to make test run correctly.
> 2) We also use kernel "sigaction" structure to fit
> realtime syscall __NR_rt_sigaction.
>
> - rt_sigprocmask01
> First, there exsits the same problem as rt_sigaction01.
> Second, this testcase uses a unchanged signal number 33,
> which may diff among different archs and lead to error
> "unknown signal".
>
> So, we use a macro TEST_SIG which refers to SIGRTMIN
> to replace 33.
>
>
> The problem is that SIGRTMIN is actually signal 32, not signal 33, and
> here's a problematic comment to ponder over (from bits/signum.h):
>
> /* These are the hard limits of the kernel.  These values should not be
>    used directly at user level.  */
> #define __SIGRTMIN      32
> #define __SIGRTMAX      (_NSIG - 1)
>
> I think the proper resolution would be to make the value SIGRTMIN+1.
>
>
>
> Hi, Garrett,
>
> In fact, I'm confused about whether #33 signal is particularly needed here,
> in some of my boxes, SIGRTMIN actually refers #34 signal, that is,
> #33 is unreachable.
>
> IMO, any realtime reachable signal can be used to pass the case here, and
> I pick SIGRTMIN by define a macro: #define TEST_SIG SIGRTMIN.
>
> Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your
> value.
>
> If you are free, looking forward to your explaination ...

Several signals between the non-RT and non-reserved RT signals are
used by [the now defunct] linuxthreads and nptl. See the following
page which refers to a very old school copy of LTP :]...:

http://www.redhat.com/archives/phil-list/2003-April/msg00049.html

> - rt_sigsuspend01
> There exists the same problem as rt_sigaction01.
>
> This patch fixed these failure.
>
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
>
> ---
>  include/rt_signal.h                                |   60
> ++++++++++++++++++
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   64
> +++++++++++--------
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
>  4 files changed, 132 insertions(+), 37 deletions(-)
>  create mode 100644 include/rt_signal.h
>
> diff --git a/include/rt_signal.h b/include/rt_signal.h
> new file mode 100644
> index 0000000..ea1e7e3
> --- /dev/null
> +++ b/include/rt_signal.h
> @@ -0,0 +1,60 @@
> +/******************************************************************************/
> +/*
>    */
> +/* Copyright (c) 2009 FUJITSU LIMITED
>   */
> +/*
>    */
> +/* This program is free software;  you can redistribute it and/or modify
>    */
> +/* it under the terms of the GNU General Public License as published by
>   */
> +/* the Free Software Foundation; either version 2 of the License, or
>    */
> +/* (at your option) any later version.
>    */
> +/*
>    */
> +/* This program is distributed in the hope that it will be useful,
>    */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of
>    */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
>    */
> +/* the GNU General Public License for more details.
>   */
> +/*
>    */
> +/* You should have received a copy of the GNU General Public License
>    */
> +/* along with this program;  if not, write to the Free Software
>   */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>    */
> +/*
>    */
> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>
>    */
> +/*
>    */
> +/******************************************************************************/
> +
> +#ifndef __LTP_SIGNAL_H
> +#define __LTP_SIGNAL_H
> +
> +/* We do not globally define the SA_RESTORER flag so do it here.  */
> +#define HAVE_SA_RESTORER
> +#define SA_RESTORER 0x04000000
> +
> +struct kernel_sigaction {
> +       __sighandler_t k_sa_handler;
> +       unsigned long sa_flags;
> +       void (*sa_restorer) (void);
> +       sigset_t sa_mask;
> +};
> +
> +void (*restore_rt) (void);
> +
> +void
> +handler_h(void)
> +{
> +       return;
> +}
> +
> +/* initial restore_rt for x86_64 */
> +void
> +sig_initial(int sig)
> +{
> +       struct sigaction act, oact;
> +
> +       act.sa_handler = (void *)handler_h;
> +       sigemptyset(&act.sa_mask);
> +       sigaddset(&act.sa_mask, sig);
> +       /* copy act.sa_restorer to kernel */
> +       sigaction(sig, &act, &oact);
> +       /* copy oact.sa_restorer from kernel */
> +       sigaction(sig, &act, &oact);
> +       restore_rt = oact.sa_restorer;
> +}
> +#endif
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index ffc5fa2..d30f204 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -55,6 +55,10 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
>
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
>  /*
>  * For all but __mips__:
>  *
> @@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number
> of tests in this file.   *
>  /*              On success - Exits calling tst_exit(). With '0' return
> code.  */
>  /*
>    */
>  /******************************************************************************/
> -extern void cleanup() {
> -        /* Remove tmp dir and all files in it */
> -        TEST_CLEANUP;
> -        tst_rmdir();
> +extern void cleanup()
> +{
> +       /* Remove tmp dir and all files in it */
> +       TEST_CLEANUP;
> +       tst_rmdir();
>
> -        /* Exit with appropriate return code. */
> -        tst_exit();
> +       /* Exit with appropriate return code. */
> +       tst_exit();
>  }
>
>  /* Local  Functions */
> @@ -128,11 +133,12 @@ extern void cleanup() {
>  /*              On success - returns 0.
>   */
>  /*
>    */
>  /******************************************************************************/
> -void setup() {
> -        /* Capture signals if any */
> -        /* Create temporary directories */
> -        TEST_PAUSE;
> -        tst_tmpdir();
> +void setup()
> +{
> +       /* Capture signals if any */
> +       /* Create temporary directories */
> +       TEST_PAUSE;
> +       tst_tmpdir();
>  }
>
>  int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND,
> SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
> @@ -144,22 +150,23 @@ handler(int sig)
>         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
>         return;
>  }
> -
>  int
> -set_handler(int sig, int sig_to_mask, int mask_flags)
> +set_handler(int sig, int mask_flags)
>  {
> -        struct sigaction sa, oldaction;
> -
> -                sa.sa_sigaction = (void *)handler;
> -                sa.sa_flags = mask_flags;
> -                sigemptyset(&sa.sa_mask);
> -                sigaddset(&sa.sa_mask, sig_to_mask);
> -                TEST(syscall(__NR_rt_sigaction,sig, &sa,
> &oldaction,SIGSETSIZE));
> -        if (TEST_RETURN == 0) {
> -                return 0;
> -        } else {
> -                        return TEST_RETURN;
> -        }
> +#ifdef __x86_64__
> +       struct kernel_sigaction sa, oldaction;
> +       mask_flags |= SA_RESTORER;
> +       sa.sa_restorer = restore_rt;
> +       sa.k_sa_handler = (void *)handler;
> +#else
> +       struct sigaction sa, oldaction;
> +       sa.sa_handler = (void *)handler;
> +#endif
> +       sa.sa_flags = mask_flags;
> +       sigemptyset(&sa.sa_mask);
> +       sigaddset(&sa.sa_mask, sig);
> +       TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> +       return TEST_RETURN;
>  }
>
>
> @@ -182,8 +189,11 @@ int main(int ac, char **av) {
>                 for (testno = 0; testno < TST_TOTAL; ++testno) {
>
>                        for (signal = SIGRTMIN; signal <= (SIGRTMAX );
> signal++){//signal for 34 to 65
> -                               for(flag=0; flag<5;flag++) {
> -                                        TEST(set_handler(signal, 0,
> test_flags[flag]));
> +#ifdef __x86_64__
> +                               sig_initial(signal);
> +#endif
> +                               for(flag=0; flag<5;flag++) {
> +                                        TEST(set_handler(signal,
> test_flags[flag]));
>
>
> I know this isn't your code change, but since you're here.. a better
> way to do this would be:
>
> sizeof (test_flags) / sizeof (test_flags[0])
>
> as this is a fixed array buffer.
>
>
> Sure, this can increase codes's portability.
>
> I'm generating a new version patch.

The less we have to modify code in the future, the better... Cheers!

>                                                 if (TEST_RETURN == 0) {
>                                                tst_resm(TINFO,"signal: %d ",
> signal);
>                                                tst_resm(TPASS, "rt_sigaction
> call succeeded: result = %ld ",TEST_RETURN );
> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> index 6398a28..8bcdc78 100644
> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> @@ -62,6 +62,12 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
>
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +#define TEST_SIG SIGRTMIN
> +
>  /* Extern Global Variables */
>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> @@ -131,7 +137,16 @@ void sig_handler(int sig)
>  }
>
>  int main(int ac, char **av) {
> -       struct sigaction act, oact;
> +#ifdef __x86_64__
> +       struct kernel_sigaction act, oact;
> +       sig_initial(TEST_SIG);
> +       act.sa_flags |= SA_RESTORER;
> +        act.sa_restorer = restore_rt;
> +        act.k_sa_handler = sig_handler;
> +#else
> +        struct sigaction act, oact;
> +        act.sa_handler = sig_handler;
> +#endif
>         sigset_t set, oset;
>         int lc;                 /* loop counter */
>         char *msg;              /* message returned from parse_opts */
> @@ -154,22 +169,21 @@ int main(int ac, char **av) {
>                                cleanup();
>                                tst_exit();
>                        }
> -                       TEST(sigaddset(&set, 33));
> +                       TEST(sigaddset(&set, TEST_SIG));
>                        if(TEST_RETURN == -1){
>                                tst_resm(TFAIL,"Call to sigaddset() Failed,
> errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                cleanup();
>                                tst_exit();
>                        }
> -
> +
>                        /* call rt_sigaction() */
> -                       act.sa_handler = sig_handler;
> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact,
> 8));
> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act,
> &oact, 8));
>                        if(TEST_RETURN != 0){
>                                tst_resm(TFAIL,"Call to rt_sigaction()
> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                cleanup();
>                                tst_exit();
>                        }
> -                       /* call rt_sigprocmask() to block signal#33 */
> +                       /* call rt_sigprocmask() to block signal#SIGRTMIN */
>                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,
> &oset, 8));
>                        if(TEST_RETURN == -1){
>                                tst_resm(TFAIL,"Call to rt_sigprocmask()****
> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> @@ -178,7 +192,7 @@ int main(int ac, char **av) {
>                        }
>
>                        else {
> -                               TEST(kill(getpid(), 33));
> +                               TEST(kill(getpid(), TEST_SIG));
>                                if(TEST_RETURN != 0){
>                                        tst_resm(TFAIL,"Call to kill()
> Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                        cleanup();
> @@ -198,13 +212,13 @@ int main(int ac, char **av) {
>                                                cleanup();
>                                                tst_exit();
>                                        }
> -                                       TEST(sigismember(&oset, 33));
> +                                       TEST(sigismember(&oset, TEST_SIG));
>                                        if(TEST_RETURN == 0 ){
>                                                tst_resm(TFAIL,"call
> sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                                cleanup();
>                                                tst_exit();
>                                        }
> -                                       /* call rt_sigprocmask() to unblock
> signal#33 */
> +                                       /* call rt_sigprocmask() to unblock
> signal#SIGRTMIN */
>                                        TEST(syscall(__NR_rt_sigprocmask,
> SIG_UNBLOCK, &set, &oset, 8));
>                                        if(TEST_RETURN == -1){
>                                                tst_resm(TFAIL,"Call to
> rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index 416a7c9..84f2967 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -47,6 +47,10 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
>
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
>  /* Extern Global Variables */
>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> @@ -139,9 +143,16 @@ int main(int ac, char **av) {
>                                cleanup();
>                                tst_exit();
>                        }
> +#ifdef __x86_64__
> +                       struct kernel_sigaction act, oact;
> +                       sig_initial(SIGALRM);
> +                       act.sa_flags |= SA_RESTORER;
> +                       act.sa_restorer = restore_rt;
> +                       act.k_sa_handler = sig_handler;
> +#else
>                        struct sigaction act, oact;
>                        act.sa_handler = sig_handler;
> -
> +#endif
>                        TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
> 8));
>                        if(TEST_RETURN == -1){
>                                tst_resm(TFAIL,"rt_sigaction() Failed,
> errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> --
> 1.6.2.2
>
>
>
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-22  9:20 liubo
@ 2010-02-22 14:45 ` Rishikesh K Rajak
  0 siblings, 0 replies; 34+ messages in thread
From: Rishikesh K Rajak @ 2010-02-22 14:45 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list

On Mon, Feb 22, 2010 at 05:20:33PM +0800, liubo wrote:

Hi Liu,

> - rt_sigaction01
> On arch x86_64, if we directly get to call syscall 
> rt_sigaction, there will be "segment fault".
> 1) One reason is that we must supply the flag of 
> "SA_RESTORER" and the correct pointer to the fuction 
> "restorer", according to the kernel code.
> 2) The other reason is that default syscall rt_sigaction 
> use kernel "sigaction" structure, which is different 
> with normal "sigaction" structure.
> 
> So, 
> 1) We manage to find the address of the function 
> "restorer" by using glibc function "sigaction", 
> which might be something tricky. Then we add these 
> arguments to make test run correctly.
> 2) We also use kernel "sigaction" structure to fit 
> realtime syscall __NR_rt_sigaction.
> 
> - rt_sigprocmask01
> First, there exsits the same problem as rt_sigaction01.
> Second, this testcase uses a unchanged signal number 33, 
> which may diff among different archs and lead to error
> "unknown signal".
> 
> So, we use a macro TEST_SIG which refers to SIGRTMIN+1 
> to replace 33.
> 
> - rt_sigsuspend01
> There exists the same problem as rt_sigaction01.
> 
> This patch fixed these failure.
> 
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>


Acked/Tested-By: Rishikesh K Rajak<risrajak@linux.vnet.ibm.com>

Before patch:
rt_sigaction01                 FAIL       11   
rt_sigprocmask01               FAIL       11   
rt_sigsuspend01                FAIL       11   

After patch:

mhs21a:/opt/ltp/testcases/bin # ./rt_sigprocmask01
rt_sigprocmask01    1  TPASS  :  rt_sigprocmask() PASSED
mhs21a:/opt/ltp/testcases/bin # ./rt_sigsuspend01
rt_sigsuspend01    1  TPASS  :  rt_sigsuspend PASSED
rt_sigsuspend01    2  TPASS  :  rt_sigsuspend PASSED
rt_sigsuspend01    3  TPASS  :  rt_sigsuspend PASSED
rt_sigsuspend01    4  TPASS  :  rt_sigsuspend PASSED
mhs21a:/opt/ltp/testcases/bin # ./rt_sigprocmask01 
rt_sigprocmask01    1  TPASS  :  rt_sigprocmask() PASSED
mhs21a:/opt/ltp/testcases/bin # 

Thanks
-Rishi
> 
> ---
>  include/rt_signal.h                                |   60 +++++++++++++++++
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   69 ++++++++++++--------
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
>  4 files changed, 136 insertions(+), 38 deletions(-)
>  create mode 100644 include/rt_signal.h
> 
> diff --git a/include/rt_signal.h b/include/rt_signal.h
> new file mode 100644
> index 0000000..ea1e7e3
> --- /dev/null
> +++ b/include/rt_signal.h
> @@ -0,0 +1,60 @@
> +/******************************************************************************/
> +/*                                                                            */
> +/* Copyright (c) 2009 FUJITSU LIMITED                                         */
> +/*                                                                            */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
> +/*                                                                            */
> +/******************************************************************************/
> +
> +#ifndef __LTP_SIGNAL_H
> +#define __LTP_SIGNAL_H
> +
> +/* We do not globally define the SA_RESTORER flag so do it here.  */
> +#define HAVE_SA_RESTORER
> +#define SA_RESTORER 0x04000000
> +
> +struct kernel_sigaction {
> +	__sighandler_t k_sa_handler;
> +	unsigned long sa_flags;
> +	void (*sa_restorer) (void);
> +	sigset_t sa_mask;
> +};
> +
> +void (*restore_rt) (void);
> +
> +void
> +handler_h(void)
> +{
> +	return;
> +}
> +
> +/* initial restore_rt for x86_64 */
> +void
> +sig_initial(int sig)
> +{
> +	struct sigaction act, oact;
> +
> +	act.sa_handler = (void *)handler_h;
> +	sigemptyset(&act.sa_mask);
> +	sigaddset(&act.sa_mask, sig);
> +	/* copy act.sa_restorer to kernel */
> +	sigaction(sig, &act, &oact);
> +	/* copy oact.sa_restorer from kernel */
> +	sigaction(sig, &act, &oact);
> +	restore_rt = oact.sa_restorer;
> +}
> +#endif
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index ffc5fa2..c8f5d5f 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -55,6 +55,10 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> 
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
>  /*
>   * For all but __mips__:
>   *
> @@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number of tests in this file.   *
>  /*              On success - Exits calling tst_exit(). With '0' return code.  */
>  /*                                                                            */
>  /******************************************************************************/
> -extern void cleanup() {
> -        /* Remove tmp dir and all files in it */
> -        TEST_CLEANUP;
> -        tst_rmdir();
> +extern void cleanup() 
> +{
> +	/* Remove tmp dir and all files in it */
> +	TEST_CLEANUP;
> +	tst_rmdir();
> 
> -        /* Exit with appropriate return code. */
> -        tst_exit();
> +	/* Exit with appropriate return code. */
> +	tst_exit();
>  }
> 
>  /* Local  Functions */
> @@ -128,11 +133,12 @@ extern void cleanup() {
>  /*              On success - returns 0.                                       */
>  /*                                                                            */
>  /******************************************************************************/
> -void setup() {
> -        /* Capture signals if any */
> -        /* Create temporary directories */
> -        TEST_PAUSE;
> -        tst_tmpdir();
> +void setup() 
> +{
> +	/* Capture signals if any */
> +	/* Create temporary directories */
> +	TEST_PAUSE;
> +	tst_tmpdir();
>  }
> 
>  int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
> @@ -144,22 +150,23 @@ handler(int sig)
>          tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
>          return;
>  }
> -
>  int
> -set_handler(int sig, int sig_to_mask, int mask_flags)
> +set_handler(int sig, int mask_flags)
>  {
> -        struct sigaction sa, oldaction;
> -
> -                sa.sa_sigaction = (void *)handler;
> -                sa.sa_flags = mask_flags;
> -                sigemptyset(&sa.sa_mask);
> -                sigaddset(&sa.sa_mask, sig_to_mask);
> -                TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> -        if (TEST_RETURN == 0) {
> -                return 0;
> -        } else {
> -                        return TEST_RETURN;
> -        }
> +#ifdef __x86_64__
> +	struct kernel_sigaction sa, oldaction;
> +	mask_flags |= SA_RESTORER;
> +	sa.sa_restorer = restore_rt;
> +	sa.k_sa_handler = (void *)handler;
> +#else
> +	struct sigaction sa, oldaction;
> +	sa.sa_handler = (void *)handler;
> +#endif
> +	sa.sa_flags = mask_flags;
> +	sigemptyset(&sa.sa_mask);
> +	sigaddset(&sa.sa_mask, sig);
> +	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> +	return TEST_RETURN;
>  }
> 
> 
> @@ -167,6 +174,7 @@ int main(int ac, char **av) {
>  	int signal, flag;
>          int lc;                 /* loop counter */
>          char *msg;              /* message returned from parse_opts */
> +	int fc;			/* flag counter */
>  	
>          /* parse standard options */
>          if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> @@ -179,11 +187,16 @@ int main(int ac, char **av) {
>          /* Check looping state if -i option given */
>          for (lc = 0; TEST_LOOPING(lc); ++lc) {
>                  Tst_count = 0;
> -                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +		fc = sizeof (test_flags) / sizeof (test_flags[0]);
> +
> +		for (testno = 0; testno < TST_TOTAL; ++testno) {
>                  
>  			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
> -			 	for(flag=0; flag<5;flag++) {
> -	                        	 TEST(set_handler(signal, 0, test_flags[flag]));
> +#ifdef __x86_64__
> +				sig_initial(signal);
> +#endif
> +				for(flag=0; flag<fc;flag++) {
> +	                        	 TEST(set_handler(signal, test_flags[flag]));
>  						 if (TEST_RETURN == 0) {
>          					tst_resm(TINFO,"signal: %d ", signal);
>          					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> index 6398a28..5b292b2 100644
> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> @@ -62,6 +62,12 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> 
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +#define TEST_SIG SIGRTMIN+1
> +
>  /* Extern Global Variables */
>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> @@ -131,7 +137,16 @@ void sig_handler(int sig)
>  }
> 
>  int main(int ac, char **av) {
> -	struct sigaction act, oact;
> +#ifdef __x86_64__
> +	struct kernel_sigaction act, oact;
> +	sig_initial(TEST_SIG);
> +	act.sa_flags |= SA_RESTORER;
> +        act.sa_restorer = restore_rt;
> +        act.k_sa_handler = sig_handler;
> +#else
> +        struct sigaction act, oact;
> +        act.sa_handler = sig_handler;
> +#endif
>          sigset_t set, oset;
>          int lc;                 /* loop counter */
>          char *msg;              /* message returned from parse_opts */
> @@ -154,22 +169,21 @@ int main(int ac, char **av) {
>                          	cleanup();
>  				tst_exit();
>  			}
> -			TEST(sigaddset(&set, 33));
> +			TEST(sigaddset(&set, TEST_SIG));
>  			if(TEST_RETURN == -1){
>  				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          	cleanup();
>  				tst_exit();
>  			}
> -			
> +				
>  			/* call rt_sigaction() */
> -			act.sa_handler = sig_handler;
> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
>  			if(TEST_RETURN != 0){
>  				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          	cleanup();
>  				tst_exit();
>  			}
> -			/* call rt_sigprocmask() to block signal#33 */
> +			/* call rt_sigprocmask() to block signal#SIGRTMIN */
>                          TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
>  			if(TEST_RETURN == -1){
>  				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> @@ -178,7 +192,7 @@ int main(int ac, char **av) {
>  			}
>  			
>  			else {
> -				TEST(kill(getpid(), 33));
> +				TEST(kill(getpid(), TEST_SIG));
>  				if(TEST_RETURN != 0){
>  					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          		cleanup();
> @@ -198,13 +212,13 @@ int main(int ac, char **av) {
>                          			cleanup();
>  						tst_exit();
>  					}
> -					TEST(sigismember(&oset, 33));
> +					TEST(sigismember(&oset, TEST_SIG));
>  					if(TEST_RETURN == 0 ){
>  						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                          			cleanup();
>  						tst_exit();
>  					}
> -					/* call rt_sigprocmask() to unblock signal#33 */
> +					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
>  					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
>  					if(TEST_RETURN == -1){
>  						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index 416a7c9..84f2967 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -47,6 +47,10 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> 
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
>  /* Extern Global Variables */
>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> @@ -139,9 +143,16 @@ int main(int ac, char **av) {
>  				cleanup();
>  				tst_exit();
>  			}
> +#ifdef __x86_64__
> +		        struct kernel_sigaction act, oact;
> +			sig_initial(SIGALRM);
> +			act.sa_flags |= SA_RESTORER;
> +			act.sa_restorer = restore_rt;
> +			act.k_sa_handler = sig_handler;			
> +#else
>  			struct sigaction act, oact;
>  		        act.sa_handler = sig_handler;
> -			
> +#endif
>  			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
>  			if(TEST_RETURN == -1){
>  		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> -- 
> 1.6.2.2
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list

-- 
Thanks & Regards
Rishi
LTP Maintainer
IBM, LTC, Bangalore
Please join IRC #ltp @ irc.freenode.net

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2010-02-22  9:20 liubo
  2010-02-22 14:45 ` Rishikesh K Rajak
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-22  9:20 UTC (permalink / raw)
  To: ltp-list

- rt_sigaction01
On arch x86_64, if we directly get to call syscall 
rt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of 
"SA_RESTORER" and the correct pointer to the fuction 
"restorer", according to the kernel code.
2) The other reason is that default syscall rt_sigaction 
use kernel "sigaction" structure, which is different 
with normal "sigaction" structure.

So, 
1) We manage to find the address of the function 
"restorer" by using glibc function "sigaction", 
which might be something tricky. Then we add these 
arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit 
realtime syscall __NR_rt_sigaction.

- rt_sigprocmask01
First, there exsits the same problem as rt_sigaction01.
Second, this testcase uses a unchanged signal number 33, 
which may diff among different archs and lead to error
"unknown signal".

So, we use a macro TEST_SIG which refers to SIGRTMIN+1 
to replace 33.

- rt_sigsuspend01
There exists the same problem as rt_sigaction01.

This patch fixed these failure.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 include/rt_signal.h                                |   60 +++++++++++++++++
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   69 ++++++++++++--------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
 4 files changed, 136 insertions(+), 38 deletions(-)
 create mode 100644 include/rt_signal.h

diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..ea1e7e3
--- /dev/null
+++ b/include/rt_signal.h
@@ -0,0 +1,60 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) 2009 FUJITSU LIMITED                                         */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#ifndef __LTP_SIGNAL_H
+#define __LTP_SIGNAL_H
+
+/* We do not globally define the SA_RESTORER flag so do it here.  */
+#define HAVE_SA_RESTORER
+#define SA_RESTORER 0x04000000
+
+struct kernel_sigaction {
+	__sighandler_t k_sa_handler;
+	unsigned long sa_flags;
+	void (*sa_restorer) (void);
+	sigset_t sa_mask;
+};
+
+void (*restore_rt) (void);
+
+void
+handler_h(void)
+{
+	return;
+}
+
+/* initial restore_rt for x86_64 */
+void
+sig_initial(int sig)
+{
+	struct sigaction act, oact;
+
+	act.sa_handler = (void *)handler_h;
+	sigemptyset(&act.sa_mask);
+	sigaddset(&act.sa_mask, sig);
+	/* copy act.sa_restorer to kernel */
+	sigaction(sig, &act, &oact);
+	/* copy oact.sa_restorer from kernel */
+	sigaction(sig, &act, &oact);
+	restore_rt = oact.sa_restorer;
+}
+#endif
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index ffc5fa2..c8f5d5f 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -55,6 +55,10 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
 /*
  * For all but __mips__:
  *
@@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number of tests in this file.   *
 /*              On success - Exits calling tst_exit(). With '0' return code.  */
 /*                                                                            */
 /******************************************************************************/
-extern void cleanup() {
-        /* Remove tmp dir and all files in it */
-        TEST_CLEANUP;
-        tst_rmdir();
+extern void cleanup() 
+{
+	/* Remove tmp dir and all files in it */
+	TEST_CLEANUP;
+	tst_rmdir();
 
-        /* Exit with appropriate return code. */
-        tst_exit();
+	/* Exit with appropriate return code. */
+	tst_exit();
 }
 
 /* Local  Functions */
@@ -128,11 +133,12 @@ extern void cleanup() {
 /*              On success - returns 0.                                       */
 /*                                                                            */
 /******************************************************************************/
-void setup() {
-        /* Capture signals if any */
-        /* Create temporary directories */
-        TEST_PAUSE;
-        tst_tmpdir();
+void setup() 
+{
+	/* Capture signals if any */
+	/* Create temporary directories */
+	TEST_PAUSE;
+	tst_tmpdir();
 }
 
 int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
@@ -144,22 +150,23 @@ handler(int sig)
         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
         return;
 }
-
 int
-set_handler(int sig, int sig_to_mask, int mask_flags)
+set_handler(int sig, int mask_flags)
 {
-        struct sigaction sa, oldaction;
-
-                sa.sa_sigaction = (void *)handler;
-                sa.sa_flags = mask_flags;
-                sigemptyset(&sa.sa_mask);
-                sigaddset(&sa.sa_mask, sig_to_mask);
-                TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
-        if (TEST_RETURN == 0) {
-                return 0;
-        } else {
-                        return TEST_RETURN;
-        }
+#ifdef __x86_64__
+	struct kernel_sigaction sa, oldaction;
+	mask_flags |= SA_RESTORER;
+	sa.sa_restorer = restore_rt;
+	sa.k_sa_handler = (void *)handler;
+#else
+	struct sigaction sa, oldaction;
+	sa.sa_handler = (void *)handler;
+#endif
+	sa.sa_flags = mask_flags;
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, sig);
+	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
+	return TEST_RETURN;
 }
 
 
@@ -167,6 +174,7 @@ int main(int ac, char **av) {
 	int signal, flag;
         int lc;                 /* loop counter */
         char *msg;              /* message returned from parse_opts */
+	int fc;			/* flag counter */
 	
         /* parse standard options */
         if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
@@ -179,11 +187,16 @@ int main(int ac, char **av) {
         /* Check looping state if -i option given */
         for (lc = 0; TEST_LOOPING(lc); ++lc) {
                 Tst_count = 0;
-                for (testno = 0; testno < TST_TOTAL; ++testno) {
+		fc = sizeof (test_flags) / sizeof (test_flags[0]);
+
+		for (testno = 0; testno < TST_TOTAL; ++testno) {
                 
 			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
-			 	for(flag=0; flag<5;flag++) {
-	                        	 TEST(set_handler(signal, 0, test_flags[flag]));
+#ifdef __x86_64__
+				sig_initial(signal);
+#endif
+				for(flag=0; flag<fc;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
 						 if (TEST_RETURN == 0) {
         					tst_resm(TINFO,"signal: %d ", signal);
         					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..5b292b2 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -62,6 +62,12 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
+#define TEST_SIG SIGRTMIN+1
+
 /* Extern Global Variables */
 extern int Tst_count;           /* counter for tst_xxx routines.         */
 extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
@@ -131,7 +137,16 @@ void sig_handler(int sig)
 }
 
 int main(int ac, char **av) {
-	struct sigaction act, oact;
+#ifdef __x86_64__
+	struct kernel_sigaction act, oact;
+	sig_initial(TEST_SIG);
+	act.sa_flags |= SA_RESTORER;
+        act.sa_restorer = restore_rt;
+        act.k_sa_handler = sig_handler;
+#else
+        struct sigaction act, oact;
+        act.sa_handler = sig_handler;
+#endif
         sigset_t set, oset;
         int lc;                 /* loop counter */
         char *msg;              /* message returned from parse_opts */
@@ -154,22 +169,21 @@ int main(int ac, char **av) {
                         	cleanup();
 				tst_exit();
 			}
-			TEST(sigaddset(&set, 33));
+			TEST(sigaddset(&set, TEST_SIG));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
 				tst_exit();
 			}
-			
+				
 			/* call rt_sigaction() */
-			act.sa_handler = sig_handler;
-                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
+                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
 			if(TEST_RETURN != 0){
 				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
 				tst_exit();
 			}
-			/* call rt_sigprocmask() to block signal#33 */
+			/* call rt_sigprocmask() to block signal#SIGRTMIN */
                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
@@ -178,7 +192,7 @@ int main(int ac, char **av) {
 			}
 			
 			else {
-				TEST(kill(getpid(), 33));
+				TEST(kill(getpid(), TEST_SIG));
 				if(TEST_RETURN != 0){
 					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         		cleanup();
@@ -198,13 +212,13 @@ int main(int ac, char **av) {
                         			cleanup();
 						tst_exit();
 					}
-					TEST(sigismember(&oset, 33));
+					TEST(sigismember(&oset, TEST_SIG));
 					if(TEST_RETURN == 0 ){
 						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         			cleanup();
 						tst_exit();
 					}
-					/* call rt_sigprocmask() to unblock signal#33 */
+					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
 					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
 					if(TEST_RETURN == -1){
 						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -47,6 +47,10 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
 /* Extern Global Variables */
 extern int Tst_count;           /* counter for tst_xxx routines.         */
 extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
@@ -139,9 +143,16 @@ int main(int ac, char **av) {
 				cleanup();
 				tst_exit();
 			}
+#ifdef __x86_64__
+		        struct kernel_sigaction act, oact;
+			sig_initial(SIGALRM);
+			act.sa_flags |= SA_RESTORER;
+			act.sa_restorer = restore_rt;
+			act.k_sa_handler = sig_handler;			
+#else
 			struct sigaction act, oact;
 		        act.sa_handler = sig_handler;
-			
+#endif
 			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
 			if(TEST_RETURN == -1){
 		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
-- 
1.6.2.2




------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-22  7:56 ` Garrett Cooper
@ 2010-02-22  9:08   ` liubo
  2010-02-22 18:05     ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-22  9:08 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 16388 bytes --]

On 02/22/2010 03:56 PM, Garrett Cooper wrote:
> By and large this diff looks really good. My comments...
>
> On Sun, Feb 21, 2010 at 9:21 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
>   
>> - rt_sigaction01
>> On arch x86_64, if we directly get to call syscall
>> rt_sigaction, there will be "segment fault".
>> 1) One reason is that we must supply the flag of
>> "SA_RESTORER" and the correct pointer to the fuction
>> "restorer", according to the kernel code.
>> 2) The other reason is that default syscall rt_sigaction
>> use kernel "sigaction" structure, which is different
>> with normal "sigaction" structure.
>>
>> So,
>> 1) We manage to find the address of the function
>> "restorer" by using glibc function "sigaction",
>> which might be something tricky. Then we add these
>> arguments to make test run correctly.
>> 2) We also use kernel "sigaction" structure to fit
>> realtime syscall __NR_rt_sigaction.
>>
>> - rt_sigprocmask01
>> First, there exsits the same problem as rt_sigaction01.
>> Second, this testcase uses a unchanged signal number 33,
>> which may diff among different archs and lead to error
>> "unknown signal".
>>
>> So, we use a macro TEST_SIG which refers to SIGRTMIN
>> to replace 33.
>>     
>
> The problem is that SIGRTMIN is actually signal 32, not signal 33, and
> here's a problematic comment to ponder over (from bits/signum.h):
>
> /* These are the hard limits of the kernel.  These values should not be
>    used directly at user level.  */
> #define __SIGRTMIN      32
> #define __SIGRTMAX      (_NSIG - 1)
>
> I think the proper resolution would be to make the value SIGRTMIN+1.
>
>   
Hi, Garrett,

In fact, I'm confused about whether #33 signal is particularly needed here,
in some of my boxes, SIGRTMIN actually refers #34 signal, that is,
#33 is unreachable.

IMO, any realtime reachable signal can be used to pass the case here, and
I pick SIGRTMIN by define a macro: #define TEST_SIG SIGRTMIN.

Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your
value.

If you are free, looking forward to your explaination ...

>> - rt_sigsuspend01
>> There exists the same problem as rt_sigaction01.
>>
>> This patch fixed these failure.
>>
>> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
>>
>> ---
>>  include/rt_signal.h                                |   60 ++++++++++++++++++
>>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   64 +++++++++++--------
>>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
>>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
>>  4 files changed, 132 insertions(+), 37 deletions(-)
>>  create mode 100644 include/rt_signal.h
>>
>> diff --git a/include/rt_signal.h b/include/rt_signal.h
>> new file mode 100644
>> index 0000000..ea1e7e3
>> --- /dev/null
>> +++ b/include/rt_signal.h
>> @@ -0,0 +1,60 @@
>> +/******************************************************************************/
>> +/*                                                                            */
>> +/* Copyright (c) 2009 FUJITSU LIMITED                                         */
>> +/*                                                                            */
>> +/* This program is free software;  you can redistribute it and/or modify      */
>> +/* it under the terms of the GNU General Public License as published by       */
>> +/* the Free Software Foundation; either version 2 of the License, or          */
>> +/* (at your option) any later version.                                        */
>> +/*                                                                            */
>> +/* This program is distributed in the hope that it will be useful,            */
>> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
>> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
>> +/* the GNU General Public License for more details.                           */
>> +/*                                                                            */
>> +/* You should have received a copy of the GNU General Public License          */
>> +/* along with this program;  if not, write to the Free Software               */
>> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
>> +/*                                                                            */
>> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
>> +/*                                                                            */
>> +/******************************************************************************/
>> +
>> +#ifndef __LTP_SIGNAL_H
>> +#define __LTP_SIGNAL_H
>> +
>> +/* We do not globally define the SA_RESTORER flag so do it here.  */
>> +#define HAVE_SA_RESTORER
>> +#define SA_RESTORER 0x04000000
>> +
>> +struct kernel_sigaction {
>> +       __sighandler_t k_sa_handler;
>> +       unsigned long sa_flags;
>> +       void (*sa_restorer) (void);
>> +       sigset_t sa_mask;
>> +};
>> +
>> +void (*restore_rt) (void);
>> +
>> +void
>> +handler_h(void)
>> +{
>> +       return;
>> +}
>> +
>> +/* initial restore_rt for x86_64 */
>> +void
>> +sig_initial(int sig)
>> +{
>> +       struct sigaction act, oact;
>> +
>> +       act.sa_handler = (void *)handler_h;
>> +       sigemptyset(&act.sa_mask);
>> +       sigaddset(&act.sa_mask, sig);
>> +       /* copy act.sa_restorer to kernel */
>> +       sigaction(sig, &act, &oact);
>> +       /* copy oact.sa_restorer from kernel */
>> +       sigaction(sig, &act, &oact);
>> +       restore_rt = oact.sa_restorer;
>> +}
>> +#endif
>> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> index ffc5fa2..d30f204 100644
>> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
>> @@ -55,6 +55,10 @@
>>  #include "usctest.h"
>>  #include "linux_syscall_numbers.h"
>>
>> +#ifdef __x86_64__
>> +#include "rt_signal.h"
>> +#endif
>> +
>>  /*
>>  * For all but __mips__:
>>  *
>> @@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number of tests in this file.   *
>>  /*              On success - Exits calling tst_exit(). With '0' return code.  */
>>  /*                                                                            */
>>  /******************************************************************************/
>> -extern void cleanup() {
>> -        /* Remove tmp dir and all files in it */
>> -        TEST_CLEANUP;
>> -        tst_rmdir();
>> +extern void cleanup()
>> +{
>> +       /* Remove tmp dir and all files in it */
>> +       TEST_CLEANUP;
>> +       tst_rmdir();
>>
>> -        /* Exit with appropriate return code. */
>> -        tst_exit();
>> +       /* Exit with appropriate return code. */
>> +       tst_exit();
>>  }
>>
>>  /* Local  Functions */
>> @@ -128,11 +133,12 @@ extern void cleanup() {
>>  /*              On success - returns 0.                                       */
>>  /*                                                                            */
>>  /******************************************************************************/
>> -void setup() {
>> -        /* Capture signals if any */
>> -        /* Create temporary directories */
>> -        TEST_PAUSE;
>> -        tst_tmpdir();
>> +void setup()
>> +{
>> +       /* Capture signals if any */
>> +       /* Create temporary directories */
>> +       TEST_PAUSE;
>> +       tst_tmpdir();
>>  }
>>
>>  int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
>> @@ -144,22 +150,23 @@ handler(int sig)
>>         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
>>         return;
>>  }
>> -
>>  int
>> -set_handler(int sig, int sig_to_mask, int mask_flags)
>> +set_handler(int sig, int mask_flags)
>>  {
>> -        struct sigaction sa, oldaction;
>> -
>> -                sa.sa_sigaction = (void *)handler;
>> -                sa.sa_flags = mask_flags;
>> -                sigemptyset(&sa.sa_mask);
>> -                sigaddset(&sa.sa_mask, sig_to_mask);
>> -                TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
>> -        if (TEST_RETURN == 0) {
>> -                return 0;
>> -        } else {
>> -                        return TEST_RETURN;
>> -        }
>> +#ifdef __x86_64__
>> +       struct kernel_sigaction sa, oldaction;
>> +       mask_flags |= SA_RESTORER;
>> +       sa.sa_restorer = restore_rt;
>> +       sa.k_sa_handler = (void *)handler;
>> +#else
>> +       struct sigaction sa, oldaction;
>> +       sa.sa_handler = (void *)handler;
>> +#endif
>> +       sa.sa_flags = mask_flags;
>> +       sigemptyset(&sa.sa_mask);
>> +       sigaddset(&sa.sa_mask, sig);
>> +       TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
>> +       return TEST_RETURN;
>>  }
>>
>>
>> @@ -182,8 +189,11 @@ int main(int ac, char **av) {
>>                 for (testno = 0; testno < TST_TOTAL; ++testno) {
>>
>>                        for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65
>> -                               for(flag=0; flag<5;flag++) {
>> -                                        TEST(set_handler(signal, 0, test_flags[flag]));
>> +#ifdef __x86_64__
>> +                               sig_initial(signal);
>> +#endif
>> +                               for(flag=0; flag<5;flag++) {
>> +                                        TEST(set_handler(signal, test_flags[flag]));
>>     
>
> I know this isn't your code change, but since you're here.. a better
> way to do this would be:
>
> sizeof (test_flags) / sizeof (test_flags[0])
>
> as this is a fixed array buffer.
>   

Sure, this can increase codes's portability.

I'm generating a new version patch.

Thanks,
Liubo

>   
>>                                                 if (TEST_RETURN == 0) {
>>                                                tst_resm(TINFO,"signal: %d ", signal);
>>                                                tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
>> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> index 6398a28..8bcdc78 100644
>> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
>> @@ -62,6 +62,12 @@
>>  #include "usctest.h"
>>  #include "linux_syscall_numbers.h"
>>
>> +#ifdef __x86_64__
>> +#include "rt_signal.h"
>> +#endif
>> +
>> +#define TEST_SIG SIGRTMIN
>> +
>>  /* Extern Global Variables */
>>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>> @@ -131,7 +137,16 @@ void sig_handler(int sig)
>>  }
>>
>>  int main(int ac, char **av) {
>> -       struct sigaction act, oact;
>> +#ifdef __x86_64__
>> +       struct kernel_sigaction act, oact;
>> +       sig_initial(TEST_SIG);
>> +       act.sa_flags |= SA_RESTORER;
>> +        act.sa_restorer = restore_rt;
>> +        act.k_sa_handler = sig_handler;
>> +#else
>> +        struct sigaction act, oact;
>> +        act.sa_handler = sig_handler;
>> +#endif
>>         sigset_t set, oset;
>>         int lc;                 /* loop counter */
>>         char *msg;              /* message returned from parse_opts */
>> @@ -154,22 +169,21 @@ int main(int ac, char **av) {
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> -                       TEST(sigaddset(&set, 33));
>> +                       TEST(sigaddset(&set, TEST_SIG));
>>                        if(TEST_RETURN == -1){
>>                                tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> -
>> +
>>                        /* call rt_sigaction() */
>> -                       act.sa_handler = sig_handler;
>> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
>> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
>>                        if(TEST_RETURN != 0){
>>                                tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> -                       /* call rt_sigprocmask() to block signal#33 */
>> +                       /* call rt_sigprocmask() to block signal#SIGRTMIN */
>>                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
>>                        if(TEST_RETURN == -1){
>>                                tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>> @@ -178,7 +192,7 @@ int main(int ac, char **av) {
>>                        }
>>
>>                        else {
>> -                               TEST(kill(getpid(), 33));
>> +                               TEST(kill(getpid(), TEST_SIG));
>>                                if(TEST_RETURN != 0){
>>                                        tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                        cleanup();
>> @@ -198,13 +212,13 @@ int main(int ac, char **av) {
>>                                                cleanup();
>>                                                tst_exit();
>>                                        }
>> -                                       TEST(sigismember(&oset, 33));
>> +                                       TEST(sigismember(&oset, TEST_SIG));
>>                                        if(TEST_RETURN == 0 ){
>>                                                tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>>                                                cleanup();
>>                                                tst_exit();
>>                                        }
>> -                                       /* call rt_sigprocmask() to unblock signal#33 */
>> +                                       /* call rt_sigprocmask() to unblock signal#SIGRTMIN */
>>                                        TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
>>                                        if(TEST_RETURN == -1){
>>                                                tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> index 416a7c9..84f2967 100644
>> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
>> @@ -47,6 +47,10 @@
>>  #include "usctest.h"
>>  #include "linux_syscall_numbers.h"
>>
>> +#ifdef __x86_64__
>> +#include "rt_signal.h"
>> +#endif
>> +
>>  /* Extern Global Variables */
>>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>> @@ -139,9 +143,16 @@ int main(int ac, char **av) {
>>                                cleanup();
>>                                tst_exit();
>>                        }
>> +#ifdef __x86_64__
>> +                       struct kernel_sigaction act, oact;
>> +                       sig_initial(SIGALRM);
>> +                       act.sa_flags |= SA_RESTORER;
>> +                       act.sa_restorer = restore_rt;
>> +                       act.k_sa_handler = sig_handler;
>> +#else
>>                        struct sigaction act, oact;
>>                        act.sa_handler = sig_handler;
>> -
>> +#endif
>>                        TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
>>                        if(TEST_RETURN == -1){
>>                                tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>> --
>> 1.6.2.2
>>     
>
>
>   


[-- Attachment #1.2: Type: text/html, Size: 26366 bytes --]

[-- Attachment #2: Type: text/plain, Size: 345 bytes --]

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2010-02-22  5:21 liubo
@ 2010-02-22  7:56 ` Garrett Cooper
  2010-02-22  9:08   ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2010-02-22  7:56 UTC (permalink / raw)
  To: liubo; +Cc: ltp-list

By and large this diff looks really good. My comments...

On Sun, Feb 21, 2010 at 9:21 PM, liubo <liubo2009@cn.fujitsu.com> wrote:
> - rt_sigaction01
> On arch x86_64, if we directly get to call syscall
> rt_sigaction, there will be "segment fault".
> 1) One reason is that we must supply the flag of
> "SA_RESTORER" and the correct pointer to the fuction
> "restorer", according to the kernel code.
> 2) The other reason is that default syscall rt_sigaction
> use kernel "sigaction" structure, which is different
> with normal "sigaction" structure.
>
> So,
> 1) We manage to find the address of the function
> "restorer" by using glibc function "sigaction",
> which might be something tricky. Then we add these
> arguments to make test run correctly.
> 2) We also use kernel "sigaction" structure to fit
> realtime syscall __NR_rt_sigaction.
>
> - rt_sigprocmask01
> First, there exsits the same problem as rt_sigaction01.
> Second, this testcase uses a unchanged signal number 33,
> which may diff among different archs and lead to error
> "unknown signal".
>
> So, we use a macro TEST_SIG which refers to SIGRTMIN
> to replace 33.

The problem is that SIGRTMIN is actually signal 32, not signal 33, and
here's a problematic comment to ponder over (from bits/signum.h):

/* These are the hard limits of the kernel.  These values should not be
   used directly at user level.  */
#define __SIGRTMIN      32
#define __SIGRTMAX      (_NSIG - 1)

I think the proper resolution would be to make the value SIGRTMIN+1.

> - rt_sigsuspend01
> There exists the same problem as rt_sigaction01.
>
> This patch fixed these failure.
>
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
>
> ---
>  include/rt_signal.h                                |   60 ++++++++++++++++++
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   64 +++++++++++--------
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
>  4 files changed, 132 insertions(+), 37 deletions(-)
>  create mode 100644 include/rt_signal.h
>
> diff --git a/include/rt_signal.h b/include/rt_signal.h
> new file mode 100644
> index 0000000..ea1e7e3
> --- /dev/null
> +++ b/include/rt_signal.h
> @@ -0,0 +1,60 @@
> +/******************************************************************************/
> +/*                                                                            */
> +/* Copyright (c) 2009 FUJITSU LIMITED                                         */
> +/*                                                                            */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
> +/*                                                                            */
> +/******************************************************************************/
> +
> +#ifndef __LTP_SIGNAL_H
> +#define __LTP_SIGNAL_H
> +
> +/* We do not globally define the SA_RESTORER flag so do it here.  */
> +#define HAVE_SA_RESTORER
> +#define SA_RESTORER 0x04000000
> +
> +struct kernel_sigaction {
> +       __sighandler_t k_sa_handler;
> +       unsigned long sa_flags;
> +       void (*sa_restorer) (void);
> +       sigset_t sa_mask;
> +};
> +
> +void (*restore_rt) (void);
> +
> +void
> +handler_h(void)
> +{
> +       return;
> +}
> +
> +/* initial restore_rt for x86_64 */
> +void
> +sig_initial(int sig)
> +{
> +       struct sigaction act, oact;
> +
> +       act.sa_handler = (void *)handler_h;
> +       sigemptyset(&act.sa_mask);
> +       sigaddset(&act.sa_mask, sig);
> +       /* copy act.sa_restorer to kernel */
> +       sigaction(sig, &act, &oact);
> +       /* copy oact.sa_restorer from kernel */
> +       sigaction(sig, &act, &oact);
> +       restore_rt = oact.sa_restorer;
> +}
> +#endif
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index ffc5fa2..d30f204 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -55,6 +55,10 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
>
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
>  /*
>  * For all but __mips__:
>  *
> @@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number of tests in this file.   *
>  /*              On success - Exits calling tst_exit(). With '0' return code.  */
>  /*                                                                            */
>  /******************************************************************************/
> -extern void cleanup() {
> -        /* Remove tmp dir and all files in it */
> -        TEST_CLEANUP;
> -        tst_rmdir();
> +extern void cleanup()
> +{
> +       /* Remove tmp dir and all files in it */
> +       TEST_CLEANUP;
> +       tst_rmdir();
>
> -        /* Exit with appropriate return code. */
> -        tst_exit();
> +       /* Exit with appropriate return code. */
> +       tst_exit();
>  }
>
>  /* Local  Functions */
> @@ -128,11 +133,12 @@ extern void cleanup() {
>  /*              On success - returns 0.                                       */
>  /*                                                                            */
>  /******************************************************************************/
> -void setup() {
> -        /* Capture signals if any */
> -        /* Create temporary directories */
> -        TEST_PAUSE;
> -        tst_tmpdir();
> +void setup()
> +{
> +       /* Capture signals if any */
> +       /* Create temporary directories */
> +       TEST_PAUSE;
> +       tst_tmpdir();
>  }
>
>  int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
> @@ -144,22 +150,23 @@ handler(int sig)
>         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
>         return;
>  }
> -
>  int
> -set_handler(int sig, int sig_to_mask, int mask_flags)
> +set_handler(int sig, int mask_flags)
>  {
> -        struct sigaction sa, oldaction;
> -
> -                sa.sa_sigaction = (void *)handler;
> -                sa.sa_flags = mask_flags;
> -                sigemptyset(&sa.sa_mask);
> -                sigaddset(&sa.sa_mask, sig_to_mask);
> -                TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> -        if (TEST_RETURN == 0) {
> -                return 0;
> -        } else {
> -                        return TEST_RETURN;
> -        }
> +#ifdef __x86_64__
> +       struct kernel_sigaction sa, oldaction;
> +       mask_flags |= SA_RESTORER;
> +       sa.sa_restorer = restore_rt;
> +       sa.k_sa_handler = (void *)handler;
> +#else
> +       struct sigaction sa, oldaction;
> +       sa.sa_handler = (void *)handler;
> +#endif
> +       sa.sa_flags = mask_flags;
> +       sigemptyset(&sa.sa_mask);
> +       sigaddset(&sa.sa_mask, sig);
> +       TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> +       return TEST_RETURN;
>  }
>
>
> @@ -182,8 +189,11 @@ int main(int ac, char **av) {
>                 for (testno = 0; testno < TST_TOTAL; ++testno) {
>
>                        for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65
> -                               for(flag=0; flag<5;flag++) {
> -                                        TEST(set_handler(signal, 0, test_flags[flag]));
> +#ifdef __x86_64__
> +                               sig_initial(signal);
> +#endif
> +                               for(flag=0; flag<5;flag++) {
> +                                        TEST(set_handler(signal, test_flags[flag]));

I know this isn't your code change, but since you're here.. a better
way to do this would be:

sizeof (test_flags) / sizeof (test_flags[0])

as this is a fixed array buffer.

>                                                 if (TEST_RETURN == 0) {
>                                                tst_resm(TINFO,"signal: %d ", signal);
>                                                tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> index 6398a28..8bcdc78 100644
> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> @@ -62,6 +62,12 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
>
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +#define TEST_SIG SIGRTMIN
> +
>  /* Extern Global Variables */
>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> @@ -131,7 +137,16 @@ void sig_handler(int sig)
>  }
>
>  int main(int ac, char **av) {
> -       struct sigaction act, oact;
> +#ifdef __x86_64__
> +       struct kernel_sigaction act, oact;
> +       sig_initial(TEST_SIG);
> +       act.sa_flags |= SA_RESTORER;
> +        act.sa_restorer = restore_rt;
> +        act.k_sa_handler = sig_handler;
> +#else
> +        struct sigaction act, oact;
> +        act.sa_handler = sig_handler;
> +#endif
>         sigset_t set, oset;
>         int lc;                 /* loop counter */
>         char *msg;              /* message returned from parse_opts */
> @@ -154,22 +169,21 @@ int main(int ac, char **av) {
>                                cleanup();
>                                tst_exit();
>                        }
> -                       TEST(sigaddset(&set, 33));
> +                       TEST(sigaddset(&set, TEST_SIG));
>                        if(TEST_RETURN == -1){
>                                tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                cleanup();
>                                tst_exit();
>                        }
> -
> +
>                        /* call rt_sigaction() */
> -                       act.sa_handler = sig_handler;
> -                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
>                        if(TEST_RETURN != 0){
>                                tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                cleanup();
>                                tst_exit();
>                        }
> -                       /* call rt_sigprocmask() to block signal#33 */
> +                       /* call rt_sigprocmask() to block signal#SIGRTMIN */
>                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
>                        if(TEST_RETURN == -1){
>                                tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> @@ -178,7 +192,7 @@ int main(int ac, char **av) {
>                        }
>
>                        else {
> -                               TEST(kill(getpid(), 33));
> +                               TEST(kill(getpid(), TEST_SIG));
>                                if(TEST_RETURN != 0){
>                                        tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                        cleanup();
> @@ -198,13 +212,13 @@ int main(int ac, char **av) {
>                                                cleanup();
>                                                tst_exit();
>                                        }
> -                                       TEST(sigismember(&oset, 33));
> +                                       TEST(sigismember(&oset, TEST_SIG));
>                                        if(TEST_RETURN == 0 ){
>                                                tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
>                                                cleanup();
>                                                tst_exit();
>                                        }
> -                                       /* call rt_sigprocmask() to unblock signal#33 */
> +                                       /* call rt_sigprocmask() to unblock signal#SIGRTMIN */
>                                        TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
>                                        if(TEST_RETURN == -1){
>                                                tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index 416a7c9..84f2967 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -47,6 +47,10 @@
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
>
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
>  /* Extern Global Variables */
>  extern int Tst_count;           /* counter for tst_xxx routines.         */
>  extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> @@ -139,9 +143,16 @@ int main(int ac, char **av) {
>                                cleanup();
>                                tst_exit();
>                        }
> +#ifdef __x86_64__
> +                       struct kernel_sigaction act, oact;
> +                       sig_initial(SIGALRM);
> +                       act.sa_flags |= SA_RESTORER;
> +                       act.sa_restorer = restore_rt;
> +                       act.k_sa_handler = sig_handler;
> +#else
>                        struct sigaction act, oact;
>                        act.sa_handler = sig_handler;
> -
> +#endif
>                        TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
>                        if(TEST_RETURN == -1){
>                                tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> --
> 1.6.2.2

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2010-02-22  5:21 liubo
  2010-02-22  7:56 ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-22  5:21 UTC (permalink / raw)
  To: ltp-list

- rt_sigaction01
On arch x86_64, if we directly get to call syscall 
rt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of 
"SA_RESTORER" and the correct pointer to the fuction 
"restorer", according to the kernel code.
2) The other reason is that default syscall rt_sigaction 
use kernel "sigaction" structure, which is different 
with normal "sigaction" structure.

So, 
1) We manage to find the address of the function 
"restorer" by using glibc function "sigaction", 
which might be something tricky. Then we add these 
arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit 
realtime syscall __NR_rt_sigaction.

- rt_sigprocmask01
First, there exsits the same problem as rt_sigaction01.
Second, this testcase uses a unchanged signal number 33, 
which may diff among different archs and lead to error
"unknown signal".

So, we use a macro TEST_SIG which refers to SIGRTMIN 
to replace 33.

- rt_sigsuspend01
There exists the same problem as rt_sigaction01.

This patch fixed these failure.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 include/rt_signal.h                                |   60 ++++++++++++++++++
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   64 +++++++++++--------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   32 +++++++---
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 ++++-
 4 files changed, 132 insertions(+), 37 deletions(-)
 create mode 100644 include/rt_signal.h

diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..ea1e7e3
--- /dev/null
+++ b/include/rt_signal.h
@@ -0,0 +1,60 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) 2009 FUJITSU LIMITED                                         */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#ifndef __LTP_SIGNAL_H
+#define __LTP_SIGNAL_H
+
+/* We do not globally define the SA_RESTORER flag so do it here.  */
+#define HAVE_SA_RESTORER
+#define SA_RESTORER 0x04000000
+
+struct kernel_sigaction {
+	__sighandler_t k_sa_handler;
+	unsigned long sa_flags;
+	void (*sa_restorer) (void);
+	sigset_t sa_mask;
+};
+
+void (*restore_rt) (void);
+
+void
+handler_h(void)
+{
+	return;
+}
+
+/* initial restore_rt for x86_64 */
+void
+sig_initial(int sig)
+{
+	struct sigaction act, oact;
+
+	act.sa_handler = (void *)handler_h;
+	sigemptyset(&act.sa_mask);
+	sigaddset(&act.sa_mask, sig);
+	/* copy act.sa_restorer to kernel */
+	sigaction(sig, &act, &oact);
+	/* copy oact.sa_restorer from kernel */
+	sigaction(sig, &act, &oact);
+	restore_rt = oact.sa_restorer;
+}
+#endif
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index ffc5fa2..d30f204 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -55,6 +55,10 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
 /*
  * For all but __mips__:
  *
@@ -101,13 +105,14 @@ int  TST_TOTAL = 1;                   /* total number of tests in this file.   *
 /*              On success - Exits calling tst_exit(). With '0' return code.  */
 /*                                                                            */
 /******************************************************************************/
-extern void cleanup() {
-        /* Remove tmp dir and all files in it */
-        TEST_CLEANUP;
-        tst_rmdir();
+extern void cleanup() 
+{
+	/* Remove tmp dir and all files in it */
+	TEST_CLEANUP;
+	tst_rmdir();
 
-        /* Exit with appropriate return code. */
-        tst_exit();
+	/* Exit with appropriate return code. */
+	tst_exit();
 }
 
 /* Local  Functions */
@@ -128,11 +133,12 @@ extern void cleanup() {
 /*              On success - returns 0.                                       */
 /*                                                                            */
 /******************************************************************************/
-void setup() {
-        /* Capture signals if any */
-        /* Create temporary directories */
-        TEST_PAUSE;
-        tst_tmpdir();
+void setup() 
+{
+	/* Capture signals if any */
+	/* Create temporary directories */
+	TEST_PAUSE;
+	tst_tmpdir();
 }
 
 int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
@@ -144,22 +150,23 @@ handler(int sig)
         tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
         return;
 }
-
 int
-set_handler(int sig, int sig_to_mask, int mask_flags)
+set_handler(int sig, int mask_flags)
 {
-        struct sigaction sa, oldaction;
-
-                sa.sa_sigaction = (void *)handler;
-                sa.sa_flags = mask_flags;
-                sigemptyset(&sa.sa_mask);
-                sigaddset(&sa.sa_mask, sig_to_mask);
-                TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
-        if (TEST_RETURN == 0) {
-                return 0;
-        } else {
-                        return TEST_RETURN;
-        }
+#ifdef __x86_64__
+	struct kernel_sigaction sa, oldaction;
+	mask_flags |= SA_RESTORER;
+	sa.sa_restorer = restore_rt;
+	sa.k_sa_handler = (void *)handler;
+#else
+	struct sigaction sa, oldaction;
+	sa.sa_handler = (void *)handler;
+#endif
+	sa.sa_flags = mask_flags;
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, sig);
+	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
+	return TEST_RETURN;
 }
 
 
@@ -182,8 +189,11 @@ int main(int ac, char **av) {
                 for (testno = 0; testno < TST_TOTAL; ++testno) {
                 
 			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
-			 	for(flag=0; flag<5;flag++) {
-	                        	 TEST(set_handler(signal, 0, test_flags[flag]));
+#ifdef __x86_64__
+				sig_initial(signal);
+#endif
+				for(flag=0; flag<5;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
 						 if (TEST_RETURN == 0) {
         					tst_resm(TINFO,"signal: %d ", signal);
         					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..8bcdc78 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -62,6 +62,12 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
+#define TEST_SIG SIGRTMIN
+
 /* Extern Global Variables */
 extern int Tst_count;           /* counter for tst_xxx routines.         */
 extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
@@ -131,7 +137,16 @@ void sig_handler(int sig)
 }
 
 int main(int ac, char **av) {
-	struct sigaction act, oact;
+#ifdef __x86_64__
+	struct kernel_sigaction act, oact;
+	sig_initial(TEST_SIG);
+	act.sa_flags |= SA_RESTORER;
+        act.sa_restorer = restore_rt;
+        act.k_sa_handler = sig_handler;
+#else
+        struct sigaction act, oact;
+        act.sa_handler = sig_handler;
+#endif
         sigset_t set, oset;
         int lc;                 /* loop counter */
         char *msg;              /* message returned from parse_opts */
@@ -154,22 +169,21 @@ int main(int ac, char **av) {
                         	cleanup();
 				tst_exit();
 			}
-			TEST(sigaddset(&set, 33));
+			TEST(sigaddset(&set, TEST_SIG));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
 				tst_exit();
 			}
-			
+				
 			/* call rt_sigaction() */
-			act.sa_handler = sig_handler;
-                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
+                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
 			if(TEST_RETURN != 0){
 				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
 				tst_exit();
 			}
-			/* call rt_sigprocmask() to block signal#33 */
+			/* call rt_sigprocmask() to block signal#SIGRTMIN */
                         TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
@@ -178,7 +192,7 @@ int main(int ac, char **av) {
 			}
 			
 			else {
-				TEST(kill(getpid(), 33));
+				TEST(kill(getpid(), TEST_SIG));
 				if(TEST_RETURN != 0){
 					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         		cleanup();
@@ -198,13 +212,13 @@ int main(int ac, char **av) {
                         			cleanup();
 						tst_exit();
 					}
-					TEST(sigismember(&oset, 33));
+					TEST(sigismember(&oset, TEST_SIG));
 					if(TEST_RETURN == 0 ){
 						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         			cleanup();
 						tst_exit();
 					}
-					/* call rt_sigprocmask() to unblock signal#33 */
+					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
 					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
 					if(TEST_RETURN == -1){
 						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -47,6 +47,10 @@
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
 /* Extern Global Variables */
 extern int Tst_count;           /* counter for tst_xxx routines.         */
 extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
@@ -139,9 +143,16 @@ int main(int ac, char **av) {
 				cleanup();
 				tst_exit();
 			}
+#ifdef __x86_64__
+		        struct kernel_sigaction act, oact;
+			sig_initial(SIGALRM);
+			act.sa_flags |= SA_RESTORER;
+			act.sa_restorer = restore_rt;
+			act.k_sa_handler = sig_handler;			
+#else
 			struct sigaction act, oact;
 		        act.sa_handler = sig_handler;
-			
+#endif
 			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
 			if(TEST_RETURN == -1){
 		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
-- 
1.6.2.2





------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-12-22  2:51   ` Garrett Cooper
@ 2009-12-22 13:12     ` liubo
  0 siblings, 0 replies; 34+ messages in thread
From: liubo @ 2009-12-22 13:12 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 3029 bytes --]

On 12/22/2009 10:51 AM, Garrett Cooper wrote:
> On Fri, Dec 18, 2009 at 8:03 AM, Subrata Modak
> <subrata@linux.vnet.ibm.com> wrote:
>   
>> Garret,
>>
>> Not sure if you applied this :-(
>>
>> Regards--
>> Subrata
>>
>> On Wed, 2009-12-09 at 15:34 +0800, liubo wrote:
>>     
>>> Here is the patch, which contains lots of adjustments
>>> on style, so it might be a bit huge.
>>>
>>> Testcase 1. rt_sigaction01
>>> On arch x86_64, if we directly get to call syscall
>>> rt_sigaction, there will be "segment fault".
>>> 1) One reason is that we must supply the flag of
>>> "SA_RESTORER" and the correct pointer to the fuction
>>> "restorer", according to the kernel code.
>>> 2) The other reason is that default syscall rt_sigaction
>>> use kernel "sigaction" structure, which is different
>>> with normal "sigaction" structure.
>>>
>>> So,
>>> 1) We manage to find the address of the function
>>> "restorer" by using glibc function "sigaction",
>>> which might be something tricky. Then we add these
>>> arguments to make test run correctly.
>>> 2) We also use kernel "sigaction" structure to fit
>>> realtime syscall __NR_rt_sigaction.
>>>
>>> Testcase 2. rt_sigprocmask01
>>> First, there exsits the same problem as rt_sigaction01.
>>> Second, this testcase uses a unchanged signal number 33,
>>> which may diff among different archs and lead to error
>>> "unknown signal".
>>>
>>> So, we use a macro TEST_SIG which refers to SIGRTMIN
>>> to replace 33.
>>>
>>> Testcase 3. rt_sigsuspend01
>>> There exists the same problem as rt_sigaction01.
>>>
>>> This patch fixed these failure.
>>>       
>
>     No, I didn't commit this because it's long, and I'm not sure if
> it's doing the right thing as per my research over the past couple of
> weeks. These tests are tricky because it requires a particular formula
> of preset variables and structures in order to properly use
> rt_sigaction, and that's where we're running into issues with them on
> x86_64 -- because the syscall implementers decided to remain sort of
> backwards compatible with x86, and that's why it's such a mess to deal
> with.
>     I will look at the diff and pick out which parts are of value, but
> a lot of this diff's contents are basically reverting the changes that
> I made this month.
> Thanks,
> -Garrett
>
>
>   
Hi, Garrett,
    In my patch, I adopted a kind of method which is different from
your previous changes about this.
    I try to find the address of "restore_rt" which is needed by
syscall rt_sigaction, and I managed to get this address by
tracing glibc function "sigaction".
    After doing these, I also found rt_sigaction's "sigaction" struct is
different from normal "sigaction" struct, so when copy from normal
"sigaction" struct to rt_sigaction's kernel "sigaction" struct, some
kind of segmental fault will ocurr to us.
    So, I did some changes to revert your previous changes and directly
adopted the function "restore_rt" and kernel "sigaction" struct to fix
these bugs.
    Hope these are helpful to you.

Thanks,
-Liu Bo

[-- Attachment #1.2: Type: text/html, Size: 3605 bytes --]

[-- Attachment #2: Type: text/plain, Size: 390 bytes --]

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-12-18 16:03 ` Subrata Modak
@ 2009-12-22  2:51   ` Garrett Cooper
  2009-12-22 13:12     ` liubo
  0 siblings, 1 reply; 34+ messages in thread
From: Garrett Cooper @ 2009-12-22  2:51 UTC (permalink / raw)
  To: subrata; +Cc: ltp-list

On Fri, Dec 18, 2009 at 8:03 AM, Subrata Modak
<subrata@linux.vnet.ibm.com> wrote:
> Garret,
>
> Not sure if you applied this :-(
>
> Regards--
> Subrata
>
> On Wed, 2009-12-09 at 15:34 +0800, liubo wrote:
>> Here is the patch, which contains lots of adjustments
>> on style, so it might be a bit huge.
>>
>> Testcase 1. rt_sigaction01
>> On arch x86_64, if we directly get to call syscall
>> rt_sigaction, there will be "segment fault".
>> 1) One reason is that we must supply the flag of
>> "SA_RESTORER" and the correct pointer to the fuction
>> "restorer", according to the kernel code.
>> 2) The other reason is that default syscall rt_sigaction
>> use kernel "sigaction" structure, which is different
>> with normal "sigaction" structure.
>>
>> So,
>> 1) We manage to find the address of the function
>> "restorer" by using glibc function "sigaction",
>> which might be something tricky. Then we add these
>> arguments to make test run correctly.
>> 2) We also use kernel "sigaction" structure to fit
>> realtime syscall __NR_rt_sigaction.
>>
>> Testcase 2. rt_sigprocmask01
>> First, there exsits the same problem as rt_sigaction01.
>> Second, this testcase uses a unchanged signal number 33,
>> which may diff among different archs and lead to error
>> "unknown signal".
>>
>> So, we use a macro TEST_SIG which refers to SIGRTMIN
>> to replace 33.
>>
>> Testcase 3. rt_sigsuspend01
>> There exists the same problem as rt_sigaction01.
>>
>> This patch fixed these failure.

    No, I didn't commit this because it's long, and I'm not sure if
it's doing the right thing as per my research over the past couple of
weeks. These tests are tricky because it requires a particular formula
of preset variables and structures in order to properly use
rt_sigaction, and that's where we're running into issues with them on
x86_64 -- because the syscall implementers decided to remain sort of
backwards compatible with x86, and that's why it's such a mess to deal
with.
    I will look at the diff and pick out which parts are of value, but
a lot of this diff's contents are basically reverting the changes that
I made this month.
Thanks,
-Garrett

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-12-09  7:34 liubo
  2009-12-09 12:14 ` Subrata Modak
@ 2009-12-18 16:03 ` Subrata Modak
  2009-12-22  2:51   ` Garrett Cooper
  1 sibling, 1 reply; 34+ messages in thread
From: Subrata Modak @ 2009-12-18 16:03 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

Garret,

Not sure if you applied this :-(

Regards--
Subrata

On Wed, 2009-12-09 at 15:34 +0800, liubo wrote: 
> Here is the patch, which contains lots of adjustments 
> on style, so it might be a bit huge.
> 
> Testcase 1. rt_sigaction01
> On arch x86_64, if we directly get to call syscall 
> rt_sigaction, there will be "segment fault".
> 1) One reason is that we must supply the flag of 
> "SA_RESTORER" and the correct pointer to the fuction 
> "restorer", according to the kernel code.
> 2) The other reason is that default syscall rt_sigaction 
> use kernel "sigaction" structure, which is different 
> with normal "sigaction" structure.
> 
> So, 
> 1) We manage to find the address of the function 
> "restorer" by using glibc function "sigaction", 
> which might be something tricky. Then we add these 
> arguments to make test run correctly.
> 2) We also use kernel "sigaction" structure to fit 
> realtime syscall __NR_rt_sigaction.
> 
> Testcase 2. rt_sigprocmask01
> First, there exsits the same problem as rt_sigaction01.
> Second, this testcase uses a unchanged signal number 33, 
> which may diff among different archs and lead to error
> "unknown signal".
> 
> So, we use a macro TEST_SIG which refers to SIGRTMIN 
> to replace 33.
> 
> Testcase 3. rt_sigsuspend01
> There exists the same problem as rt_sigaction01.
> 
> This patch fixed these failure.
> 
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
> 
> ---
>  include/ltp_signal.h                               |  152 --------
>  include/rt_signal.h                                |   60 ++++
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |  364 +++++++++-----------
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |  331 ++++++++++--------
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |  168 +++++----
>  5 files changed, 499 insertions(+), 576 deletions(-)
>  delete mode 100644 include/ltp_signal.h
>  create mode 100644 include/rt_signal.h
> 
> diff --git a/include/ltp_signal.h b/include/ltp_signal.h
> deleted file mode 100644
> index 5e9a198..0000000
> --- a/include/ltp_signal.h
> +++ /dev/null
> @@ -1,152 +0,0 @@
> -/*
> - * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of version 2 of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> - *
> - * Further, this software is distributed without any warranty that it is
> - * free of the rightful claim of any third person regarding infringement
> - * or the like.  Any license provided herein, whether implied or
> - * otherwise, applies only to this software file.  Patent licenses, if
> - * any, provided herein do not apply to combinations of this program with
> - * other software, or any other product whatsoever.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write the Free Software Foundation, Inc., 59
> - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
> - *
> - */
> -
> -#ifndef __LTP_SIGNAL_H
> -#define __LTP_SIGNAL_H
> -
> -#include <errno.h>
> -#include <signal.h>
> -#include <stdio.h>
> -#include "config.h"
> -
> -#define SIGSETSIZE (_NSIG / 8)
> -
> -#ifdef LTP_RT_SIG_TEST
> -
> -extern int  expected_signal_number;
> -
> -#if defined(__x86_64__)
> -
> -/*
> - * From asm/signal.h -- this value isn't exported anywhere outside of glibc and
> - * asm/signal.h and is only required for the rt_sig* function family because
> - * sigaction(2), et all, appends this if necessary to
> - * (struct sigaction).sa_flags. HEH.
> - *
> - * I do #undef though, just in case...
> - */
> -#undef SA_RESTORER
> -#define SA_RESTORER	0x04000000
> -
> -/* 
> - * From .../arch/x86/kernel/signal.c:448 --
> - *
> - * x86-64 should always use SA_RESTORER.
> - *
> - * -- thus SA_RESTORER must always be defined along with
> - * (struct sigaction).sa_restorer.
> - */
> -#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa) __sa.sa_flags |= SA_RESTORER; __sa.sa_restorer = dummy_restorer;
> -/* defined(__x86_64) */
> -#else
> -#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa)
> -#endif
> -
> -/*
> - * To help direct sigsegv_sigaction_handler in determining whether or not the
> - * segfault was valid.
> - */
> -extern int  expected_signal_number;
> -
> -/* 
> - * A dummy sa_restorer function, because we have to have it if SA_RESTORER is
> - * required.
> - */
> -inline void
> -dummy_restorer(void) {
> -	tst_resm(TINFO, "%s called", __func__);
> -}
> -
> -/* 
> - * SIGSEGV will be thrown if an overflow occurs, or some other undesired
> - * precondition. Let's catch it so the test will at least proceed and not
> - * completely bomb the heck out.
> - */
> -inline void
> -sigsegv_sigaction_handler(int signum, siginfo_t *siginfo, void *ucontext) {
> -
> -	/*
> -	 * Backwards compatibility is a pain; I think that's what's driving
> -	 * the implicit sa_restorer BS on x86_64, and the reason why mips* and
> -	 * ppc* only has a sigaction handler (not rt_sigaction).
> -	 *
> -	 * GG for backwards compatibility and lack of documentation on an
> -	 * internal syscall...
> -	 */
> -#ifdef __x86_64__
> -	if (expected_signal_number == SIGRTMIN) {
> -		tst_resm(TINFO, "SIGRTMIN segfaults on x86_64 (known issue).");
> -	} else {
> -#endif
> -	tst_brkm(TBROK | TERRNO, NULL,
> -		"Uncaught SIGSEGV; please validate whether or not test meets "
> -		"functional requirements as per do_signal and callees in "
> -		"$KERN_SRC/arch/<arch>/kernel/signal.c is concerned");
> -
> -#ifdef __x86_64__
> -	}
> -#endif
> -}
> -
> -/* 
> - * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a SIGSEGV
> - * at the kernel level because of an -EFAULT was tossed by a caller. What a
> - * PITA :].
> - */
> -inline int
> -setup_sigsegv_sigaction_handler()
> -{
> -	int rc = -1;
> -	struct sigaction sa;
> -	sigset_t sigset;
> -
> -	/* 
> -	 * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a
> -	 * SIGSEGV at the kernel level because of an -EFAULT was tossed by a
> -	 * caller. What a PITA :].
> -	 */
> -	sa.sa_sigaction = (void *)sigsegv_sigaction_handler;
> -	/* We want the handler to persist, so don't do SA_RESETHAND... */
> -	sa.sa_flags = SA_SIGINFO;
> -
> -	if (sigemptyset(&sa.sa_mask) < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup,
> -			"Failed to call sigemptyset for SIGSEGV");
> -	} else if (sigaddset(&sigset, SIGSEGV) < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup,
> -			"Failed to do sigaddset for SIGSEGV");
> -	} else if (sigaction(SIGSEGV, &sa, (struct sigaction *) NULL) < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup,
> -			"Failed to setup sighandler for SIGSEGV");
> -	} else {
> -		rc = 0;
> -	}
> -
> -	return rc;
> -
> -}
> -
> -#endif /* RT_SIG_TEST */
> -
> -#endif
> diff --git a/include/rt_signal.h b/include/rt_signal.h
> new file mode 100644
> index 0000000..be64deb
> --- /dev/null
> +++ b/include/rt_signal.h
> @@ -0,0 +1,60 @@
> +/******************************************************************************/
> +/*                                                                            */
> +/* Copyright (c) 2009 FUJITSU LIMITED                                         */
> +/*                                                                            */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
> +/*                                                                            */
> +/******************************************************************************/
> +
> +#ifndef __LTP_SIGNAL_H
> +#define __LTP_SIGNAL_H
> +
> +/* We do not globally define the SA_RESTORER flag so do it here.  */
> +#define HAVE_SA_RESTORER
> +#define SA_RESTORER 0x04000000
> +
> +struct kernel_sigaction {
> +	__sighandler_t k_sa_handler;
> +	unsigned long sa_flags;
> +	void (*sa_restorer) (void);
> +	sigset_t sa_mask;
> +};
> +
> +void (*restore_rt) (void);
> +
> +void
> +handler_h(void)
> +{
> +	return;
> +}
> +
> +/* initial restore_rt for x86_64 */
> +void
> +sig_initial(int sig)
> +{
> +	struct sigaction act, oact;
> +
> +	act.sa_handler = (void *)handler_h;
> +	sigemptyset(&act.sa_mask);
> +	sigaddset(&act.sa_mask, sig);
> +	/* copy act.sa_restorer to kernel */
> +	sigaction(sig, &act, &oact);
> +	/* copy oact.sa_restorer from kernel */
> +	sigaction(sig, &act, &oact);
> +	restore_rt = oact.sa_restorer;
> +}
> +
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index 6e937d2..d30f204 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -1,266 +1,216 @@
>  /******************************************************************************/
> -/* Copyright (c) Crackerjack Project., 2007				   */
> -/*									    */
> +/* Copyright (c) Crackerjack Project., 2007                                   */
> +/*                                                                            */
>  /* This program is free software;  you can redistribute it and/or modify      */
>  /* it under the terms of the GNU General Public License as published by       */
> -/* the Free Software Foundation; either version 2 of the License, or	  */
> -/* (at your option) any later version.					*/
> -/*									    */
> -/* This program is distributed in the hope that it will be useful,	    */
> -/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	    */
> -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		  */
> -/* the GNU General Public License for more details.			   */
> -/*									    */
> -/* You should have received a copy of the GNU General Public License	  */
> -/* along with this program;  if not, write to the Free Software	       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
>  /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> -/*									    */
> +/*                                                                            */
>  /******************************************************************************/
>  /******************************************************************************/
> -/*									    */
> -/* File:	rt_sigaction01.c					      */
> -/*									    */
> -/* Description: This tests the rt_sigaction() syscall			 */
> +/*                                                                            */
> +/* File:        rt_sigaction01.c                                              */
> +/*                                                                            */
> +/* Description: This tests the rt_sigaction() syscall                         */
>  /*		rt_sigaction alters an action taken by a process on receipt   */
> -/* 		of a particular signal. The action is specified by the	*/
> +/* 		of a particular signal. The action is specified by the        */
>  /*		sigaction structure. The previous action on the signal is     */
> -/*		saved in oact.sigsetsize should indicate the size of a	*/
> -/*		sigset_t type.		       			      */
> -/*									    */
> -/* Usage:  <for command-line>						 */
> -/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]			*/
> -/*      where,  -c n : Run n copies concurrently.			     */
> -/*	      -e   : Turn on errno logging.				 */
> -/*	      -i n : Execute test n times.				  */
> -/*	      -I x : Execute test for x seconds.			    */
> -/*	      -P x : Pause for x seconds between iterations.		*/
> -/*	      -t   : Turn on syscall timing.				*/
> -/*									    */
> -/* Total Tests: 1							     */
> -/*									    */
> -/* Test Name:   rt_sigaction01					     */
> -/* History:     Porting from Crackerjack to LTP is done by		    */
> -/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
> +/*		saved in oact.sigsetsize should indicate the size of a        */
> +/*		sigset_t type.                       			      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   rt_sigaction01                                             */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
>  /******************************************************************************/
> -#define _GNU_SOURCE
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> +#include <signal.h>
>  #include <errno.h>
> -#include <sys/types.h>
> +#include <sys/syscall.h>
>  #include <string.h>
> -#include "config.h"
> 
>  /* Harness Specific Include Files. */
>  #include "test.h"
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> -#define LTP_RT_SIG_TEST
> -#include "ltp_signal.h"
> +
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +/*
> + * For all but __mips__:
> + *
> + * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 2.
> + *
> + * For __mips__:
> + *
> + * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 4.
> + *
> + * See asm/compat.h under the kernel source for more details.
> + *
> + * Multiply that by a fudge factor of 4 and you have your SIGSETSIZE.
> + */
> +#if defined (__mips__)
> +#define SIGSETSIZE 16
> +#else
> +#define SIGSETSIZE 8
> +#endif
> 
>  /* Extern Global Variables */
> -extern int Tst_count;	   /* counter for tst_xxx routines.	 */
> -extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir() */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> 
>  /* Global Variables */
>  char *TCID = "rt_sigaction01";  /* Test program identifier.*/
> -int  expected_signal_number = 0;
> -int  pass_count = 0;
>  int  testno;
> -int  TST_TOTAL = 1;		   /* total number of tests in this file.   */
> -
> -int test_flags[] = {
> -	SA_RESETHAND|SA_SIGINFO,
> -	SA_RESETHAND,
> -	SA_RESETHAND|SA_SIGINFO,
> -	SA_RESETHAND|SA_SIGINFO,
> -	SA_NOMASK
> -};
> -char *test_flags_list[] = {
> -	"SA_RESETHAND|SA_SIGINFO",
> -	"SA_RESETHAND",
> -	"SA_RESETHAND|SA_SIGINFO",
> -	"SA_RESETHAND|SA_SIGINFO",
> -	"SA_NOMASK"
> -};
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> 
>  /* Extern Global Functions */
>  /******************************************************************************/
> -/*									    */
> -/* Function:    cleanup						       */
> -/*									    */
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
>  /* Description: Performs all one time clean up for this test on successful    */
> -/*	      completion,  premature exit or  failure. Closes all temporary */
> -/*	      files, removes all temporary directories exits the test with  */
> -/*	      appropriate return code by calling tst_exit() function.       */
> -/*									    */
> -/* Input:       None.							 */
> -/*									    */
> -/* Output:      None.							 */
> -/*									    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
>  /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> -/*	      On success - Exits calling tst_exit(). With '0' return code.  */
> -/*									    */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
>  /******************************************************************************/
> -static void cleanup() {
> +extern void cleanup() 
> +{
>  	/* Remove tmp dir and all files in it */
>  	TEST_CLEANUP;
>  	tst_rmdir();
> +
> +	/* Exit with appropriate return code. */
> +	tst_exit();
>  }
> 
>  /* Local  Functions */
>  /******************************************************************************/
> -/*									    */
> -/* Function:    setup							 */
> -/*									    */
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
>  /* Description: Performs all one time setup for this test. This function is   */
> -/*	      typically used to capture signals, create temporary dirs      */
> -/*	      and temporary files that may be used in the course of this    */
> -/*	      test.							 */
> -/*									    */
> -/* Input:       None.							 */
> -/*									    */
> -/* Output:      None.							 */
> -/*									    */
> -/* Return:      On failure - Exits by calling cleanup().		      */
> -/*	      On success - returns 0.				       */
> -/*									    */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
>  /******************************************************************************/
> -void
> -setup()
> +void setup() 
>  {
> -	(void) setup_sigsegv_sigaction_handler();
> -	/* Wait for SIGUSR1 if requested */
> -	TEST_PAUSE;
> +	/* Capture signals if any */
>  	/* Create temporary directories */
> +	TEST_PAUSE;
>  	tst_tmpdir();
>  }
> 
> +int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
> +char *test_flags_list[] = {"SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK"};
> +
>  void
>  handler(int sig)
>  {
> -	tst_resm(TINFO, "Signal handler (non-sigaction) called with signal number %d", sig);
> -	pass_count++;
> +        tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
> +        return;
>  }
> -
> -void
> -sigaction_handler(int sig, siginfo_t *siginfo, void *ucontext) {
> -	tst_resm(TINFO, "Signal handler (sigaction) called with signal number %d", sig);
> -	if (sig == expected_signal_number)
> -		pass_count++;
> -}
> -
>  int
>  set_handler(int sig, int mask_flags)
>  {
> -	int rc = -1;
> -	struct sigaction sa;
> -
> -	//memset(&sa, 0, SIGSETSIZE);
> -
> -	sa.sa_flags = mask_flags;
> -
> -	ARCH_SPECIFIC_RT_SIGACTION_SETUP(sa);
> -
> -#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
> -	/*
> -         *  SA_SIGINFO (since Linux 2.2)
> -         *        The  signal  handler  takes  3  arguments, not one.  In this
> -         *        case, sa_sigaction should  be  set  instead  of  sa_handler.
> -         *        This flag is only meaningful when establishing a signal han-
> -         *        dler.
> -         *
> -	 */
> -	if (sa.sa_flags & SA_SIGINFO)
> -		sa.sa_sigaction = (void *) sigaction_handler;
> -	else
> +#ifdef __x86_64__
> +	struct kernel_sigaction sa, oldaction;
> +	mask_flags |= SA_RESTORER;
> +	sa.sa_restorer = restore_rt;
> +	sa.k_sa_handler = (void *)handler;
> +#else
> +	struct sigaction sa, oldaction;
> +	sa.sa_handler = (void *)handler;
>  #endif
> -		sa.sa_handler = (void *) handler;
> -
> -	if (sigemptyset(&sa.sa_mask) < 0) {
> -		tst_resm(TINFO, "sigemptyset(..) failed");
> -	} else if (sigaddset(&sa.sa_mask, sig) < 0) {
> -		tst_resm(TFAIL | TINFO, "sigaddset(..) failed");
> -	} else if (syscall(__NR_rt_sigaction, sig, &sa, (struct sigaction*) NULL, SIGSETSIZE)) {
> -		tst_resm(TFAIL | TERRNO, "rt_sigaction(%d, ..) failed", sig);
> -	} else {
> -		rc = 0;
> -	}
> -	return rc;
> +	sa.sa_flags = mask_flags;
> +	sigemptyset(&sa.sa_mask);
> +	sigaddset(&sa.sa_mask, sig);
> +	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> +	return TEST_RETURN;
>  }
> 
> -int
> -main(int ac, char **av) {
> 
> -	char *msg;	/* message returned from parse_opts */
> -
> -	/* parse standard options */
> -	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> -		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> -		tst_exit();
> -	}
> -
> -	setup();
> -
> -#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
> -	int flag;
> -	int last_pass_count;
> -	int num_tests_per_signal = sizeof(test_flags) / sizeof(*test_flags);
> -	int tests_passed;
> -	int lc;		/* loop counter */
> -
> -	tst_resm(TINFO, "Will run %d tests per signal in set [%d, %d]",
> -			num_tests_per_signal, SIGRTMIN, SIGRTMAX);
> -
> -	/* Check looping state if -i option given */
> -	for (lc = 0; TEST_LOOPING(lc); ++lc) {
> -
> -		Tst_count = 0;
> -
> -		for (testno = 0; testno < TST_TOTAL; ++testno) {
> -
> -			/* 34 (NPTL) or 35 (LinuxThreads) to 65 (or 128 on mips). */
> -			for (expected_signal_number = SIGRTMIN; expected_signal_number <= SIGRTMAX; expected_signal_number++) { 
> -
> -				last_pass_count = pass_count;
> -
> -				tst_resm(TINFO, "signal: %d ", expected_signal_number);
> -
> -			 	for (flag = 0; flag < num_tests_per_signal; flag++) {
> -
> -					if (set_handler(expected_signal_number, test_flags[flag]) == 0) {
> -
> -						tst_resm(TINFO,
> -							"\tsa.sa_flags = %s",
> -							test_flags_list[flag]);
> -
> -						if (kill(getpid(), expected_signal_number) < 0) {
> -							tst_resm(TINFO | TERRNO, "kill failed");
> -						}
> -
> -		       			}
> -
> -				}
> -
> -				tests_passed = ((pass_count - last_pass_count) ==
> -						 num_tests_per_signal);
> -
> -				tst_resm(tests_passed ? TPASS : TFAIL,
> -					"tests %s for signal = %d",
> -					tests_passed ? "passed" : "failed",
> -					expected_signal_number);
> -
> -			}
> -
> -		}
> -
> -	}
> -#else
> -	tst_brkm(TCONF, NULL,
> -			"Your architecture doesn't support this test (no "
> -			"sa_sigaction field in struct sigaction).");
> +int main(int ac, char **av) {
> +	int signal, flag;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +                
> +			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
> +#ifdef __x86_64__
> +				sig_initial(signal);
>  #endif
> +				for(flag=0; flag<5;flag++) {
> +	                        	 TEST(set_handler(signal, test_flags[flag]));
> +						 if (TEST_RETURN == 0) {
> +        					tst_resm(TINFO,"signal: %d ", signal);
> +        					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
> +        					tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]);
> +						kill(getpid(),signal);
> +			                         } else {
> +                 	   				tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +                       				}
> +                			}
> +		 	printf("\n");	
> +        		}
> +
> +
> +
> +                }
> +        }	
>  	cleanup();
> -	tst_exit();
> -
> +        tst_exit();
>  }
> +
> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> index 2e51176..8bcdc78 100644
> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> @@ -1,26 +1,26 @@
>  /******************************************************************************/
> -/* Copyright (c) Crackerjack Project., 2007				      */
> -/*									      */
> +/* Copyright (c) Crackerjack Project., 2007                                   */
> +/*                                                                            */
>  /* This program is free software;  you can redistribute it and/or modify      */
>  /* it under the terms of the GNU General Public License as published by       */
> -/* the Free Software Foundation; either version 2 of the License, or	      */
> -/* (at your option) any later version.					      */
> -/*									      */
> -/* This program is distributed in the hope that it will be useful,	      */
> -/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	      */
> -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		      */
> -/* the GNU General Public License for more details.			      */
> -/*									      */
> -/* You should have received a copy of the GNU General Public License	      */
> -/* along with this program;  if not, write to the Free Software		      */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
>  /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> -/*									      */
> +/*                                                                            */
>  /******************************************************************************/
>  /******************************************************************************/
> -/*									      */
> -/* File:	rt_sigprocmask01.c					      */
> -/*									      */
> -/* Description: This tests the rt_sigprocmask() syscall			      */
> +/*                                                                            */
> +/* File:        rt_sigprocmask01.c                                              */
> +/*                                                                            */
> +/* Description: This tests the rt_sigprocmask() syscall                       */
>  /*		rt_sigprocmask changes the list of currently blocked signals. */
>  /*		The set value stores the signal mask of the pending signals.  */
>  /*		The previous action on the signal is saved in oact. The value */
> @@ -37,170 +37,211 @@
>  /*		SIG_SETMASK						      */
>  /*		    The set of blocked signals is set to the set argument.    */
>  /*		    sigsetsize should indicate the size of a sigset_t type.   */
> -/*									      */
> -/* Usage:  <for command-line>						      */
> -/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]		      */
> -/*      where,  -c n : Run n copies concurrently.			      */
> -/*	      -e   : Turn on errno logging.				      */
> -/*	      -i n : Execute test n times.				      */
> -/*	      -I x : Execute test for x seconds.			      */
> -/*	      -P x : Pause for x seconds between iterations.		      */
> -/*	      -t   : Turn on syscall timing.				      */
> -/*									      */
> -/* Total Tests: 1							      */
> -/*									      */
> -/* Test Name:   rt_sigprocmask01					      */
> -/* History:     Porting from Crackerjack to LTP is done by		      */
> -/*	      Manas Kumar Nayak maknayak@in.ibm.com>			      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   rt_sigprocmask01                                              */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
>  /******************************************************************************/
>  #include <stdio.h>
> +#include <signal.h>
>  #include <errno.h>
> 
>  /* Harness Specific Include Files. */
> -#include "ltp_signal.h"
>  #include "test.h"
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> 
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +#define TEST_SIG SIGRTMIN
> +
>  /* Extern Global Variables */
> -extern int Tst_count;	   /* counter for tst_xxx routines.	 	      */
> -extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir()	      */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> 
>  /* Global Variables */
> -char *TCID = "rt_sigprocmask01";	/* Test program identifier.	      */
> -int  TST_TOTAL = 8;			/* total number of tests in this file.*/
> +char *TCID = "rt_sigprocmask01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 8;                   /* total number of tests in this file.   */
> 
>  /* Extern Global Functions */
>  /******************************************************************************/
> -/*									      */
> -/* Function:    cleanup							      */
> -/*									      */
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
>  /* Description: Performs all one time clean up for this test on successful    */
> -/*	      completion,  premature exit or  failure. Closes all temporary   */
> -/*	      files, removes all temporary directories exits the test with    */
> -/*	      appropriate return code by calling tst_exit() function.	      */
> -/*									      */
> -/* Input:       None.							      */
> -/*									      */
> -/* Output:      None.							      */
> -/*									      */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
>  /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> -/*	      On success - Exits calling tst_exit(). With '0' return code.    */
> -/*									      */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
>  /******************************************************************************/
>  extern void cleanup() {
> -	/* Remove tmp dir and all files in it */
> -	TEST_CLEANUP;
> -	tst_rmdir();
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> 
> -	/* Exit with appropriate return code. */
> -	tst_exit();
> +        /* Exit with appropriate return code. */
> +        tst_exit();
>  }
> 
>  /* Local  Functions */
>  /******************************************************************************/
> -/*									      */
> -/* Function:    setup							      */
> -/*									      */
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
>  /* Description: Performs all one time setup for this test. This function is   */
> -/*	      typically used to capture signals, create temporary dirs	      */
> -/*	      and temporary files that may be used in the course of this      */
> -/*	      test.							      */
> -/*									      */
> -/* Input:       None.							      */
> -/*									      */
> -/* Output:      None.							      */
> -/*									      */
> -/* Return:      On failure - Exits by calling cleanup().		      */
> -/*	      On success - returns 0.					      */
> -/*									      */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
>  /******************************************************************************/
>  void setup() {
> -	/* Capture signals if any */
> -	/* Create temporary directories */
> -	TEST_PAUSE;
> -	tst_tmpdir();
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
>  }
> 
>  int sig_count = 0;
> 
>  void sig_handler(int sig)
>  {
> -	sig_count++;
> +        sig_count++;
>  }
> 
>  int main(int ac, char **av) {
> -	struct sigaction act, oact;
> -	sigset_t set, oset;
> -	int lc;		 /* loop counter */
> -	char *msg;	      /* message returned from parse_opts */
> +#ifdef __x86_64__
> +	struct kernel_sigaction act, oact;
> +	sig_initial(TEST_SIG);
> +	act.sa_flags |= SA_RESTORER;
> +        act.sa_restorer = restore_rt;
> +        act.k_sa_handler = sig_handler;
> +#else
> +        struct sigaction act, oact;
> +        act.sa_handler = sig_handler;
> +#endif
> +        sigset_t set, oset;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
>  	
> -	/* parse standard options */
> -	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> -		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> -		tst_exit();
> -	}
> -
> -	setup();
> -
> -	Tst_count = 0;
> -	TEST(sigemptyset(&set));
> -	if (TEST_RETURN == -1) {
> -		tst_resm(TFAIL | TTERRNO, "sigemptyset() failed");
> -		cleanup();
> -		tst_exit();
> -	}
> -	TEST(sigaddset(&set, SIGRTMIN));
> -	if (TEST_RETURN == -1){
> -		tst_resm(TFAIL | TTERRNO, "sigaddset() failed");
> -		cleanup();
> -		tst_exit();
> -	}
> -	
> -	/* call rt_sigaction() */
> -	act.sa_handler = sig_handler;
> -	TEST(syscall(__NR_rt_sigaction, SIGRTMIN, &act, &oact,
> -		SIGSETSIZE));
> -	if (TEST_RETURN != 0){
> -		tst_resm(TFAIL | TTERRNO,"rt_sigaction() failed");
> -	}
> -	/* call rt_sigprocmask() to block signal # SIGRTMIN */
> -	TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, SIGSETSIZE));
> -	if (TEST_RETURN == -1) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
> -	}
> -	TEST(kill(getpid(), SIGRTMIN));
> -	if (TEST_RETURN != 0){
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "kill() failed");
> -	}
> -	if (sig_count) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup,
> -			"rt_sigprocmask() failed to change the "
> -			"process's signal mask");
> -	}
> -	/* call rt_sigpending() */
> -	TEST(syscall(__NR_rt_sigpending, &oset, SIGSETSIZE));
> -	if (TEST_RETURN == -1) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigpending() failed");
> -	}
> -	TEST(sigismember(&oset, SIGRTMIN));
> -	if (TEST_RETURN == 0) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "sigismember() failed");
> -	}
> -	/* call rt_sigprocmask() to unblock signal#33 */
> -	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, SIGSETSIZE));
> -	if (TEST_RETURN == -1) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
> -	}
> -	if (sig_count) {
> -		tst_resm(TPASS, "rt_sigprocmask() PASSED");
> -	} else {
> -		tst_resm(TFAIL | TTERRNO,
> -			"rt_sigprocmask() "
> -			"functionality failed");
> -	}
> -
> -	cleanup();
> -	tst_exit();
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> 
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			TEST(sigemptyset(&set));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"Call to sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +			TEST(sigaddset(&set, TEST_SIG));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +				
> +			/* call rt_sigaction() */
> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
> +			if(TEST_RETURN != 0){
> +				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +			/* call rt_sigprocmask() to block signal#SIGRTMIN */
> +                        TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +			
> +			else {
> +				TEST(kill(getpid(), TEST_SIG));
> +				if(TEST_RETURN != 0){
> +					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        		cleanup();
> +					tst_exit();
> +					
> +				}
> +				if(sig_count){
> +					tst_resm(TFAIL,"FAIL --- rt_sigprocmask() fail to change the process's signal mask, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        		cleanup();
> +					tst_exit();
> +				}
> +				else {
> +					/* call rt_sigpending() */
> +					TEST(syscall(__NR_rt_sigpending, &oset, 8));
> +					if(TEST_RETURN == -1){
> +						tst_resm(TFAIL,"call rt_sigpending() failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        			cleanup();
> +						tst_exit();
> +					}
> +					TEST(sigismember(&oset, TEST_SIG));
> +					if(TEST_RETURN == 0 ){
> +						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        			cleanup();
> +						tst_exit();
> +					}
> +					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
> +					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
> +					if(TEST_RETURN == -1){
> +						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        			cleanup();
> +						tst_exit();
> +					}
> +					if(sig_count) {
> +						tst_resm(TPASS,"rt_sigprocmask() PASSED");
> +                        			cleanup();
> +						tst_exit();
> +					}
> +		                        else {
> +						tst_resm(TFAIL,"rt_sigprocmask() functionality failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +		                                cleanup();
> +						tst_exit();
> +		                        }
> +
> +				}
> +			}
> +
> +                }
> +	Tst_count++;
> +        }	
> +        tst_exit();
>  }
> +
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index fcb5b0b..84f2967 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -18,12 +18,12 @@
>  /******************************************************************************	*/
>  /******************************************************************************	*/
>  /*                                                                            	*/
> -/* File:        rt_sigsuspend01.c                                           	*/
> +/* File:        rt_sigsuspend01.c                                           	      	*/
>  /*                                                                            	*/
> -/* Description: This tests the rt_sigsuspend() syscall.                      	*/
> +/* Description: This tests the rt_sigsuspend() syscall.                      	      	*/
>  /*		                                                               	*/
>  /* Usage:  <for command-line>                                                 	*/
> -/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     	*/
> +/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     		*/
>  /*      where,  -c n : Run n copies concurrently.                             	*/
>  /*              -e   : Turn on errno logging.                                 	*/
>  /*              -i n : Execute test n times.                                  	*/
> @@ -33,15 +33,11 @@
>  /*                                                                            	*/
>  /* Total Tests: 2                                                             	*/
>  /*                                                                            	*/
> -/* Test Name:   rt_sigsuspend01                                             	*/
> +/* Test Name:   rt_sigsuspend01                                             		*/
>  /* History:     Porting from Crackerjack to LTP is done by                    	*/
>  /*              Manas Kumar Nayak maknayak@in.ibm.com>                        	*/
>  /********************************************************************************/
> 
> -#ifndef _GNU_SOURCE
> -#define _GNU_SOURCE
> -#endif
> -
>  #include <stdio.h>
>  #include <signal.h>
>  #include <errno.h>
> @@ -50,16 +46,19 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> -#include "ltp_signal.h"
> +
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> 
>  /* Extern Global Variables */
> -extern int Tst_count;            /* counter for tst_xxx routines.         */
> -extern char *TESTDIR;            /* temporary dir created by tst_tmpdir() */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> 
>  /* Global Variables */
>  char *TCID = "rt_sigsuspend01";  /* Test program identifier.*/
>  int  testno;
> -int  TST_TOTAL = 4;              /* total number of tests in this file.   */
> +int  TST_TOTAL =4;                   /* total number of tests in this file.   */
> 
>  /* Extern Global Functions */
>  /******************************************************************************/
> @@ -69,20 +68,23 @@ int  TST_TOTAL = 4;              /* total number of tests in this file.   */
>  /* Description: Performs all one time clean up for this test on successful    */
>  /*              completion,  premature exit or  failure. Closes all temporary */
>  /*              files, removes all temporary directories exits the test with  */
> -/*              appropriate return code by calling tst_exit() function.       */
> +/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
>  /*                                                                            */
>  /* Input:       None.                                                         */
>  /*                                                                            */
>  /* Output:      None.                                                         */
>  /*                                                                            */
> -/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> -/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
> +/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
>  /*                                                                            */
>  /******************************************************************************/
> -void cleanup() {
> -	/* Remove tmp dir and all files in it */
> -	TEST_CLEANUP;
> -	tst_rmdir();
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate TEST_RETURNurn code. */
> +        tst_exit();
>  }
> 
>  /* Local  Functions */
> @@ -100,14 +102,14 @@ void cleanup() {
>  /* Output:      None.                                                         */
>  /*                                                                            */
>  /* Return:      On failure - Exits by calling cleanup().                      */
> -/*              On success - Returns 0.					      */
> +/*              On success - TEST_RETURNurns 0.                                       */
>  /*                                                                            */
>  /******************************************************************************/
>  void setup() {
> -/* Capture signals if any */
> -/* Create temporary directories */
> -TEST_PAUSE;
> -tst_tmpdir();
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
>  }
> 
> 
> @@ -120,55 +122,77 @@ void sig_handler(int sig)
>  int main(int ac, char **av) {
>  	
>  	sigset_t set, set1, set2;
> -	char *msg;		/* message returned from parse_opts */
> +	int lc;                 /* loop counter */
> +        char *msg;              /* message TEST_RETURNurned from parse_opts */
>  	
> -	/* parse standard options */
> -	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> -		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> -		tst_exit();
> -	}
> -
> -	setup();
> -
> -	Tst_count = 0;
> -	TEST(sigemptyset(&set));
> -	if (TEST_RETURN == -1){
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "sigemptyset() failed");
> -	}
> -	struct sigaction act, oact;
> -	act.sa_handler = sig_handler;
> -			
> -	TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, SIGSETSIZE));
> -	if (TEST_RETURN == -1){
> -	       	tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigaction() failed");
> -	}
> -	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, SIGSETSIZE));
> -	if (TEST_RETURN == -1){
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
> -		cleanup();
> -		tst_exit();
> -	}
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			TEST(sigemptyset(&set));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +				cleanup();
> +				tst_exit();
> +			}
> +#ifdef __x86_64__
> +		        struct kernel_sigaction act, oact;
> +			sig_initial(SIGALRM);
> +			act.sa_flags |= SA_RESTORER;
> +			act.sa_restorer = restore_rt;
> +			act.k_sa_handler = sig_handler;			
> +#else
> +			struct sigaction act, oact;
> +		        act.sa_handler = sig_handler;
> +#endif
> +			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
> +			if(TEST_RETURN == -1){
> +		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +				cleanup();
> +				tst_exit();
> +			}
> +			TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, 8));
> +			if(TEST_RETURN == -1){
> +		        	tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +				cleanup();
> +				tst_exit();
> +			}
>  			
> -	TEST(alarm(5));
> -	int result;
> -	TEST(result = syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE));
> -	TEST(alarm(0));
> -	if (result == -1 && TEST_ERRNO != EINTR) {
> -		TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2,
> -				SIGSETSIZE));
> -		if (TEST_RETURN == -1) {
> -			tst_resm(TFAIL | TTERRNO, "rt_sigprocmask() failed");
> -		} else if (set1.__val[0] != set2.__val[0]) {
> -			tst_resm(TFAIL | TTERRNO,
> -				"rt_sigsuspend failed to preserve signal mask");
> -	        } else {
> -			tst_resm(TPASS, "rt_sigsuspend PASSED");
> -		}
> -	} else {
> -		tst_resm(TFAIL | TTERRNO, "rt_sigsuspend failed");
> -	}
> -
> +			TEST(alarm(5));
> +		        int result;
> +			TEST(result = syscall(__NR_rt_sigsuspend, &set, 8));
> +		        TEST(alarm(0));
> +			if((result == -1) && (TEST_ERRNO != EINTR)){
> +				TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2, 8));
> +				if(TEST_RETURN == -1){
> +		        		tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +					cleanup();
> +					tst_exit();
> +				} else if(set1.__val[0] != set2.__val[0]){
> +		                        tst_resm(TFAIL," rt_sigsuspend failed to preserve signal mask,errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +					cleanup();
> +					tst_exit();
> +			        } else {
> +		                        tst_resm(TPASS,"rt_sigsuspend PASSED");
> +		                }
> +		        }else{
> +		             tst_resm(TFAIL," rt_sigsuspend failed ,errrno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +	                     cleanup();
> +			     tst_exit();
> +			}
> +		
> +	
> +                }
> +	 }
>  	cleanup();
> -	tst_exit();
> -
> +        tst_exit();
>  }
> +
> -- 
> 1.6.2.2
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Return on Information:
> Google Enterprise Search pays you back
> Get the facts.
> http://p.sf.net/sfu/google-dev2dev
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
  2009-12-09  7:34 liubo
@ 2009-12-09 12:14 ` Subrata Modak
  2009-12-18 16:03 ` Subrata Modak
  1 sibling, 0 replies; 34+ messages in thread
From: Subrata Modak @ 2009-12-09 12:14 UTC (permalink / raw)
  To: Garrett Cooper, Mike Frysinger; +Cc: ltp-list

Garret/Mike,

Please take care of this.

Regards--
Subrata

On Wed, 2009-12-09 at 15:34 +0800, liubo wrote: 
> Here is the patch, which contains lots of adjustments 
> on style, so it might be a bit huge.
> 
> Testcase 1. rt_sigaction01
> On arch x86_64, if we directly get to call syscall 
> rt_sigaction, there will be "segment fault".
> 1) One reason is that we must supply the flag of 
> "SA_RESTORER" and the correct pointer to the fuction 
> "restorer", according to the kernel code.
> 2) The other reason is that default syscall rt_sigaction 
> use kernel "sigaction" structure, which is different 
> with normal "sigaction" structure.
> 
> So, 
> 1) We manage to find the address of the function 
> "restorer" by using glibc function "sigaction", 
> which might be something tricky. Then we add these 
> arguments to make test run correctly.
> 2) We also use kernel "sigaction" structure to fit 
> realtime syscall __NR_rt_sigaction.
> 
> Testcase 2. rt_sigprocmask01
> First, there exsits the same problem as rt_sigaction01.
> Second, this testcase uses a unchanged signal number 33, 
> which may diff among different archs and lead to error
> "unknown signal".
> 
> So, we use a macro TEST_SIG which refers to SIGRTMIN 
> to replace 33.
> 
> Testcase 3. rt_sigsuspend01
> There exists the same problem as rt_sigaction01.
> 
> This patch fixed these failure.
> 
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
> 
> ---
>  include/ltp_signal.h                               |  152 --------
>  include/rt_signal.h                                |   60 ++++
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |  364 +++++++++-----------
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |  331 ++++++++++--------
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |  168 +++++----
>  5 files changed, 499 insertions(+), 576 deletions(-)
>  delete mode 100644 include/ltp_signal.h
>  create mode 100644 include/rt_signal.h
> 
> diff --git a/include/ltp_signal.h b/include/ltp_signal.h
> deleted file mode 100644
> index 5e9a198..0000000
> --- a/include/ltp_signal.h
> +++ /dev/null
> @@ -1,152 +0,0 @@
> -/*
> - * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of version 2 of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> - *
> - * Further, this software is distributed without any warranty that it is
> - * free of the rightful claim of any third person regarding infringement
> - * or the like.  Any license provided herein, whether implied or
> - * otherwise, applies only to this software file.  Patent licenses, if
> - * any, provided herein do not apply to combinations of this program with
> - * other software, or any other product whatsoever.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write the Free Software Foundation, Inc., 59
> - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
> - *
> - */
> -
> -#ifndef __LTP_SIGNAL_H
> -#define __LTP_SIGNAL_H
> -
> -#include <errno.h>
> -#include <signal.h>
> -#include <stdio.h>
> -#include "config.h"
> -
> -#define SIGSETSIZE (_NSIG / 8)
> -
> -#ifdef LTP_RT_SIG_TEST
> -
> -extern int  expected_signal_number;
> -
> -#if defined(__x86_64__)
> -
> -/*
> - * From asm/signal.h -- this value isn't exported anywhere outside of glibc and
> - * asm/signal.h and is only required for the rt_sig* function family because
> - * sigaction(2), et all, appends this if necessary to
> - * (struct sigaction).sa_flags. HEH.
> - *
> - * I do #undef though, just in case...
> - */
> -#undef SA_RESTORER
> -#define SA_RESTORER	0x04000000
> -
> -/* 
> - * From .../arch/x86/kernel/signal.c:448 --
> - *
> - * x86-64 should always use SA_RESTORER.
> - *
> - * -- thus SA_RESTORER must always be defined along with
> - * (struct sigaction).sa_restorer.
> - */
> -#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa) __sa.sa_flags |= SA_RESTORER; __sa.sa_restorer = dummy_restorer;
> -/* defined(__x86_64) */
> -#else
> -#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa)
> -#endif
> -
> -/*
> - * To help direct sigsegv_sigaction_handler in determining whether or not the
> - * segfault was valid.
> - */
> -extern int  expected_signal_number;
> -
> -/* 
> - * A dummy sa_restorer function, because we have to have it if SA_RESTORER is
> - * required.
> - */
> -inline void
> -dummy_restorer(void) {
> -	tst_resm(TINFO, "%s called", __func__);
> -}
> -
> -/* 
> - * SIGSEGV will be thrown if an overflow occurs, or some other undesired
> - * precondition. Let's catch it so the test will at least proceed and not
> - * completely bomb the heck out.
> - */
> -inline void
> -sigsegv_sigaction_handler(int signum, siginfo_t *siginfo, void *ucontext) {
> -
> -	/*
> -	 * Backwards compatibility is a pain; I think that's what's driving
> -	 * the implicit sa_restorer BS on x86_64, and the reason why mips* and
> -	 * ppc* only has a sigaction handler (not rt_sigaction).
> -	 *
> -	 * GG for backwards compatibility and lack of documentation on an
> -	 * internal syscall...
> -	 */
> -#ifdef __x86_64__
> -	if (expected_signal_number == SIGRTMIN) {
> -		tst_resm(TINFO, "SIGRTMIN segfaults on x86_64 (known issue).");
> -	} else {
> -#endif
> -	tst_brkm(TBROK | TERRNO, NULL,
> -		"Uncaught SIGSEGV; please validate whether or not test meets "
> -		"functional requirements as per do_signal and callees in "
> -		"$KERN_SRC/arch/<arch>/kernel/signal.c is concerned");
> -
> -#ifdef __x86_64__
> -	}
> -#endif
> -}
> -
> -/* 
> - * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a SIGSEGV
> - * at the kernel level because of an -EFAULT was tossed by a caller. What a
> - * PITA :].
> - */
> -inline int
> -setup_sigsegv_sigaction_handler()
> -{
> -	int rc = -1;
> -	struct sigaction sa;
> -	sigset_t sigset;
> -
> -	/* 
> -	 * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a
> -	 * SIGSEGV at the kernel level because of an -EFAULT was tossed by a
> -	 * caller. What a PITA :].
> -	 */
> -	sa.sa_sigaction = (void *)sigsegv_sigaction_handler;
> -	/* We want the handler to persist, so don't do SA_RESETHAND... */
> -	sa.sa_flags = SA_SIGINFO;
> -
> -	if (sigemptyset(&sa.sa_mask) < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup,
> -			"Failed to call sigemptyset for SIGSEGV");
> -	} else if (sigaddset(&sigset, SIGSEGV) < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup,
> -			"Failed to do sigaddset for SIGSEGV");
> -	} else if (sigaction(SIGSEGV, &sa, (struct sigaction *) NULL) < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup,
> -			"Failed to setup sighandler for SIGSEGV");
> -	} else {
> -		rc = 0;
> -	}
> -
> -	return rc;
> -
> -}
> -
> -#endif /* RT_SIG_TEST */
> -
> -#endif
> diff --git a/include/rt_signal.h b/include/rt_signal.h
> new file mode 100644
> index 0000000..be64deb
> --- /dev/null
> +++ b/include/rt_signal.h
> @@ -0,0 +1,60 @@
> +/******************************************************************************/
> +/*                                                                            */
> +/* Copyright (c) 2009 FUJITSU LIMITED                                         */
> +/*                                                                            */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
> +/*                                                                            */
> +/******************************************************************************/
> +
> +#ifndef __LTP_SIGNAL_H
> +#define __LTP_SIGNAL_H
> +
> +/* We do not globally define the SA_RESTORER flag so do it here.  */
> +#define HAVE_SA_RESTORER
> +#define SA_RESTORER 0x04000000
> +
> +struct kernel_sigaction {
> +	__sighandler_t k_sa_handler;
> +	unsigned long sa_flags;
> +	void (*sa_restorer) (void);
> +	sigset_t sa_mask;
> +};
> +
> +void (*restore_rt) (void);
> +
> +void
> +handler_h(void)
> +{
> +	return;
> +}
> +
> +/* initial restore_rt for x86_64 */
> +void
> +sig_initial(int sig)
> +{
> +	struct sigaction act, oact;
> +
> +	act.sa_handler = (void *)handler_h;
> +	sigemptyset(&act.sa_mask);
> +	sigaddset(&act.sa_mask, sig);
> +	/* copy act.sa_restorer to kernel */
> +	sigaction(sig, &act, &oact);
> +	/* copy oact.sa_restorer from kernel */
> +	sigaction(sig, &act, &oact);
> +	restore_rt = oact.sa_restorer;
> +}
> +
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index 6e937d2..d30f204 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -1,266 +1,216 @@
>  /******************************************************************************/
> -/* Copyright (c) Crackerjack Project., 2007				   */
> -/*									    */
> +/* Copyright (c) Crackerjack Project., 2007                                   */
> +/*                                                                            */
>  /* This program is free software;  you can redistribute it and/or modify      */
>  /* it under the terms of the GNU General Public License as published by       */
> -/* the Free Software Foundation; either version 2 of the License, or	  */
> -/* (at your option) any later version.					*/
> -/*									    */
> -/* This program is distributed in the hope that it will be useful,	    */
> -/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	    */
> -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		  */
> -/* the GNU General Public License for more details.			   */
> -/*									    */
> -/* You should have received a copy of the GNU General Public License	  */
> -/* along with this program;  if not, write to the Free Software	       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
>  /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> -/*									    */
> +/*                                                                            */
>  /******************************************************************************/
>  /******************************************************************************/
> -/*									    */
> -/* File:	rt_sigaction01.c					      */
> -/*									    */
> -/* Description: This tests the rt_sigaction() syscall			 */
> +/*                                                                            */
> +/* File:        rt_sigaction01.c                                              */
> +/*                                                                            */
> +/* Description: This tests the rt_sigaction() syscall                         */
>  /*		rt_sigaction alters an action taken by a process on receipt   */
> -/* 		of a particular signal. The action is specified by the	*/
> +/* 		of a particular signal. The action is specified by the        */
>  /*		sigaction structure. The previous action on the signal is     */
> -/*		saved in oact.sigsetsize should indicate the size of a	*/
> -/*		sigset_t type.		       			      */
> -/*									    */
> -/* Usage:  <for command-line>						 */
> -/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]			*/
> -/*      where,  -c n : Run n copies concurrently.			     */
> -/*	      -e   : Turn on errno logging.				 */
> -/*	      -i n : Execute test n times.				  */
> -/*	      -I x : Execute test for x seconds.			    */
> -/*	      -P x : Pause for x seconds between iterations.		*/
> -/*	      -t   : Turn on syscall timing.				*/
> -/*									    */
> -/* Total Tests: 1							     */
> -/*									    */
> -/* Test Name:   rt_sigaction01					     */
> -/* History:     Porting from Crackerjack to LTP is done by		    */
> -/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
> +/*		saved in oact.sigsetsize should indicate the size of a        */
> +/*		sigset_t type.                       			      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   rt_sigaction01                                             */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
>  /******************************************************************************/
> -#define _GNU_SOURCE
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> +#include <signal.h>
>  #include <errno.h>
> -#include <sys/types.h>
> +#include <sys/syscall.h>
>  #include <string.h>
> -#include "config.h"
> 
>  /* Harness Specific Include Files. */
>  #include "test.h"
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> -#define LTP_RT_SIG_TEST
> -#include "ltp_signal.h"
> +
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +/*
> + * For all but __mips__:
> + *
> + * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 2.
> + *
> + * For __mips__:
> + *
> + * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 4.
> + *
> + * See asm/compat.h under the kernel source for more details.
> + *
> + * Multiply that by a fudge factor of 4 and you have your SIGSETSIZE.
> + */
> +#if defined (__mips__)
> +#define SIGSETSIZE 16
> +#else
> +#define SIGSETSIZE 8
> +#endif
> 
>  /* Extern Global Variables */
> -extern int Tst_count;	   /* counter for tst_xxx routines.	 */
> -extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir() */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> 
>  /* Global Variables */
>  char *TCID = "rt_sigaction01";  /* Test program identifier.*/
> -int  expected_signal_number = 0;
> -int  pass_count = 0;
>  int  testno;
> -int  TST_TOTAL = 1;		   /* total number of tests in this file.   */
> -
> -int test_flags[] = {
> -	SA_RESETHAND|SA_SIGINFO,
> -	SA_RESETHAND,
> -	SA_RESETHAND|SA_SIGINFO,
> -	SA_RESETHAND|SA_SIGINFO,
> -	SA_NOMASK
> -};
> -char *test_flags_list[] = {
> -	"SA_RESETHAND|SA_SIGINFO",
> -	"SA_RESETHAND",
> -	"SA_RESETHAND|SA_SIGINFO",
> -	"SA_RESETHAND|SA_SIGINFO",
> -	"SA_NOMASK"
> -};
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> 
>  /* Extern Global Functions */
>  /******************************************************************************/
> -/*									    */
> -/* Function:    cleanup						       */
> -/*									    */
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
>  /* Description: Performs all one time clean up for this test on successful    */
> -/*	      completion,  premature exit or  failure. Closes all temporary */
> -/*	      files, removes all temporary directories exits the test with  */
> -/*	      appropriate return code by calling tst_exit() function.       */
> -/*									    */
> -/* Input:       None.							 */
> -/*									    */
> -/* Output:      None.							 */
> -/*									    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
>  /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> -/*	      On success - Exits calling tst_exit(). With '0' return code.  */
> -/*									    */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
>  /******************************************************************************/
> -static void cleanup() {
> +extern void cleanup() 
> +{
>  	/* Remove tmp dir and all files in it */
>  	TEST_CLEANUP;
>  	tst_rmdir();
> +
> +	/* Exit with appropriate return code. */
> +	tst_exit();
>  }
> 
>  /* Local  Functions */
>  /******************************************************************************/
> -/*									    */
> -/* Function:    setup							 */
> -/*									    */
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
>  /* Description: Performs all one time setup for this test. This function is   */
> -/*	      typically used to capture signals, create temporary dirs      */
> -/*	      and temporary files that may be used in the course of this    */
> -/*	      test.							 */
> -/*									    */
> -/* Input:       None.							 */
> -/*									    */
> -/* Output:      None.							 */
> -/*									    */
> -/* Return:      On failure - Exits by calling cleanup().		      */
> -/*	      On success - returns 0.				       */
> -/*									    */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
>  /******************************************************************************/
> -void
> -setup()
> +void setup() 
>  {
> -	(void) setup_sigsegv_sigaction_handler();
> -	/* Wait for SIGUSR1 if requested */
> -	TEST_PAUSE;
> +	/* Capture signals if any */
>  	/* Create temporary directories */
> +	TEST_PAUSE;
>  	tst_tmpdir();
>  }
> 
> +int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
> +char *test_flags_list[] = {"SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK"};
> +
>  void
>  handler(int sig)
>  {
> -	tst_resm(TINFO, "Signal handler (non-sigaction) called with signal number %d", sig);
> -	pass_count++;
> +        tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
> +        return;
>  }
> -
> -void
> -sigaction_handler(int sig, siginfo_t *siginfo, void *ucontext) {
> -	tst_resm(TINFO, "Signal handler (sigaction) called with signal number %d", sig);
> -	if (sig == expected_signal_number)
> -		pass_count++;
> -}
> -
>  int
>  set_handler(int sig, int mask_flags)
>  {
> -	int rc = -1;
> -	struct sigaction sa;
> -
> -	//memset(&sa, 0, SIGSETSIZE);
> -
> -	sa.sa_flags = mask_flags;
> -
> -	ARCH_SPECIFIC_RT_SIGACTION_SETUP(sa);
> -
> -#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
> -	/*
> -         *  SA_SIGINFO (since Linux 2.2)
> -         *        The  signal  handler  takes  3  arguments, not one.  In this
> -         *        case, sa_sigaction should  be  set  instead  of  sa_handler.
> -         *        This flag is only meaningful when establishing a signal han-
> -         *        dler.
> -         *
> -	 */
> -	if (sa.sa_flags & SA_SIGINFO)
> -		sa.sa_sigaction = (void *) sigaction_handler;
> -	else
> +#ifdef __x86_64__
> +	struct kernel_sigaction sa, oldaction;
> +	mask_flags |= SA_RESTORER;
> +	sa.sa_restorer = restore_rt;
> +	sa.k_sa_handler = (void *)handler;
> +#else
> +	struct sigaction sa, oldaction;
> +	sa.sa_handler = (void *)handler;
>  #endif
> -		sa.sa_handler = (void *) handler;
> -
> -	if (sigemptyset(&sa.sa_mask) < 0) {
> -		tst_resm(TINFO, "sigemptyset(..) failed");
> -	} else if (sigaddset(&sa.sa_mask, sig) < 0) {
> -		tst_resm(TFAIL | TINFO, "sigaddset(..) failed");
> -	} else if (syscall(__NR_rt_sigaction, sig, &sa, (struct sigaction*) NULL, SIGSETSIZE)) {
> -		tst_resm(TFAIL | TERRNO, "rt_sigaction(%d, ..) failed", sig);
> -	} else {
> -		rc = 0;
> -	}
> -	return rc;
> +	sa.sa_flags = mask_flags;
> +	sigemptyset(&sa.sa_mask);
> +	sigaddset(&sa.sa_mask, sig);
> +	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
> +	return TEST_RETURN;
>  }
> 
> -int
> -main(int ac, char **av) {
> 
> -	char *msg;	/* message returned from parse_opts */
> -
> -	/* parse standard options */
> -	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> -		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> -		tst_exit();
> -	}
> -
> -	setup();
> -
> -#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
> -	int flag;
> -	int last_pass_count;
> -	int num_tests_per_signal = sizeof(test_flags) / sizeof(*test_flags);
> -	int tests_passed;
> -	int lc;		/* loop counter */
> -
> -	tst_resm(TINFO, "Will run %d tests per signal in set [%d, %d]",
> -			num_tests_per_signal, SIGRTMIN, SIGRTMAX);
> -
> -	/* Check looping state if -i option given */
> -	for (lc = 0; TEST_LOOPING(lc); ++lc) {
> -
> -		Tst_count = 0;
> -
> -		for (testno = 0; testno < TST_TOTAL; ++testno) {
> -
> -			/* 34 (NPTL) or 35 (LinuxThreads) to 65 (or 128 on mips). */
> -			for (expected_signal_number = SIGRTMIN; expected_signal_number <= SIGRTMAX; expected_signal_number++) { 
> -
> -				last_pass_count = pass_count;
> -
> -				tst_resm(TINFO, "signal: %d ", expected_signal_number);
> -
> -			 	for (flag = 0; flag < num_tests_per_signal; flag++) {
> -
> -					if (set_handler(expected_signal_number, test_flags[flag]) == 0) {
> -
> -						tst_resm(TINFO,
> -							"\tsa.sa_flags = %s",
> -							test_flags_list[flag]);
> -
> -						if (kill(getpid(), expected_signal_number) < 0) {
> -							tst_resm(TINFO | TERRNO, "kill failed");
> -						}
> -
> -		       			}
> -
> -				}
> -
> -				tests_passed = ((pass_count - last_pass_count) ==
> -						 num_tests_per_signal);
> -
> -				tst_resm(tests_passed ? TPASS : TFAIL,
> -					"tests %s for signal = %d",
> -					tests_passed ? "passed" : "failed",
> -					expected_signal_number);
> -
> -			}
> -
> -		}
> -
> -	}
> -#else
> -	tst_brkm(TCONF, NULL,
> -			"Your architecture doesn't support this test (no "
> -			"sa_sigaction field in struct sigaction).");
> +int main(int ac, char **av) {
> +	int signal, flag;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +                
> +			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
> +#ifdef __x86_64__
> +				sig_initial(signal);
>  #endif
> +				for(flag=0; flag<5;flag++) {
> +	                        	 TEST(set_handler(signal, test_flags[flag]));
> +						 if (TEST_RETURN == 0) {
> +        					tst_resm(TINFO,"signal: %d ", signal);
> +        					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
> +        					tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]);
> +						kill(getpid(),signal);
> +			                         } else {
> +                 	   				tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +                       				}
> +                			}
> +		 	printf("\n");	
> +        		}
> +
> +
> +
> +                }
> +        }	
>  	cleanup();
> -	tst_exit();
> -
> +        tst_exit();
>  }
> +
> diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> index 2e51176..8bcdc78 100644
> --- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> +++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
> @@ -1,26 +1,26 @@
>  /******************************************************************************/
> -/* Copyright (c) Crackerjack Project., 2007				      */
> -/*									      */
> +/* Copyright (c) Crackerjack Project., 2007                                   */
> +/*                                                                            */
>  /* This program is free software;  you can redistribute it and/or modify      */
>  /* it under the terms of the GNU General Public License as published by       */
> -/* the Free Software Foundation; either version 2 of the License, or	      */
> -/* (at your option) any later version.					      */
> -/*									      */
> -/* This program is distributed in the hope that it will be useful,	      */
> -/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	      */
> -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		      */
> -/* the GNU General Public License for more details.			      */
> -/*									      */
> -/* You should have received a copy of the GNU General Public License	      */
> -/* along with this program;  if not, write to the Free Software		      */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
>  /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> -/*									      */
> +/*                                                                            */
>  /******************************************************************************/
>  /******************************************************************************/
> -/*									      */
> -/* File:	rt_sigprocmask01.c					      */
> -/*									      */
> -/* Description: This tests the rt_sigprocmask() syscall			      */
> +/*                                                                            */
> +/* File:        rt_sigprocmask01.c                                              */
> +/*                                                                            */
> +/* Description: This tests the rt_sigprocmask() syscall                       */
>  /*		rt_sigprocmask changes the list of currently blocked signals. */
>  /*		The set value stores the signal mask of the pending signals.  */
>  /*		The previous action on the signal is saved in oact. The value */
> @@ -37,170 +37,211 @@
>  /*		SIG_SETMASK						      */
>  /*		    The set of blocked signals is set to the set argument.    */
>  /*		    sigsetsize should indicate the size of a sigset_t type.   */
> -/*									      */
> -/* Usage:  <for command-line>						      */
> -/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]		      */
> -/*      where,  -c n : Run n copies concurrently.			      */
> -/*	      -e   : Turn on errno logging.				      */
> -/*	      -i n : Execute test n times.				      */
> -/*	      -I x : Execute test for x seconds.			      */
> -/*	      -P x : Pause for x seconds between iterations.		      */
> -/*	      -t   : Turn on syscall timing.				      */
> -/*									      */
> -/* Total Tests: 1							      */
> -/*									      */
> -/* Test Name:   rt_sigprocmask01					      */
> -/* History:     Porting from Crackerjack to LTP is done by		      */
> -/*	      Manas Kumar Nayak maknayak@in.ibm.com>			      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   rt_sigprocmask01                                              */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
>  /******************************************************************************/
>  #include <stdio.h>
> +#include <signal.h>
>  #include <errno.h>
> 
>  /* Harness Specific Include Files. */
> -#include "ltp_signal.h"
>  #include "test.h"
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> 
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> +
> +#define TEST_SIG SIGRTMIN
> +
>  /* Extern Global Variables */
> -extern int Tst_count;	   /* counter for tst_xxx routines.	 	      */
> -extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir()	      */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> 
>  /* Global Variables */
> -char *TCID = "rt_sigprocmask01";	/* Test program identifier.	      */
> -int  TST_TOTAL = 8;			/* total number of tests in this file.*/
> +char *TCID = "rt_sigprocmask01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 8;                   /* total number of tests in this file.   */
> 
>  /* Extern Global Functions */
>  /******************************************************************************/
> -/*									      */
> -/* Function:    cleanup							      */
> -/*									      */
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
>  /* Description: Performs all one time clean up for this test on successful    */
> -/*	      completion,  premature exit or  failure. Closes all temporary   */
> -/*	      files, removes all temporary directories exits the test with    */
> -/*	      appropriate return code by calling tst_exit() function.	      */
> -/*									      */
> -/* Input:       None.							      */
> -/*									      */
> -/* Output:      None.							      */
> -/*									      */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
>  /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> -/*	      On success - Exits calling tst_exit(). With '0' return code.    */
> -/*									      */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
>  /******************************************************************************/
>  extern void cleanup() {
> -	/* Remove tmp dir and all files in it */
> -	TEST_CLEANUP;
> -	tst_rmdir();
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> 
> -	/* Exit with appropriate return code. */
> -	tst_exit();
> +        /* Exit with appropriate return code. */
> +        tst_exit();
>  }
> 
>  /* Local  Functions */
>  /******************************************************************************/
> -/*									      */
> -/* Function:    setup							      */
> -/*									      */
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
>  /* Description: Performs all one time setup for this test. This function is   */
> -/*	      typically used to capture signals, create temporary dirs	      */
> -/*	      and temporary files that may be used in the course of this      */
> -/*	      test.							      */
> -/*									      */
> -/* Input:       None.							      */
> -/*									      */
> -/* Output:      None.							      */
> -/*									      */
> -/* Return:      On failure - Exits by calling cleanup().		      */
> -/*	      On success - returns 0.					      */
> -/*									      */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
>  /******************************************************************************/
>  void setup() {
> -	/* Capture signals if any */
> -	/* Create temporary directories */
> -	TEST_PAUSE;
> -	tst_tmpdir();
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
>  }
> 
>  int sig_count = 0;
> 
>  void sig_handler(int sig)
>  {
> -	sig_count++;
> +        sig_count++;
>  }
> 
>  int main(int ac, char **av) {
> -	struct sigaction act, oact;
> -	sigset_t set, oset;
> -	int lc;		 /* loop counter */
> -	char *msg;	      /* message returned from parse_opts */
> +#ifdef __x86_64__
> +	struct kernel_sigaction act, oact;
> +	sig_initial(TEST_SIG);
> +	act.sa_flags |= SA_RESTORER;
> +        act.sa_restorer = restore_rt;
> +        act.k_sa_handler = sig_handler;
> +#else
> +        struct sigaction act, oact;
> +        act.sa_handler = sig_handler;
> +#endif
> +        sigset_t set, oset;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
>  	
> -	/* parse standard options */
> -	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> -		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> -		tst_exit();
> -	}
> -
> -	setup();
> -
> -	Tst_count = 0;
> -	TEST(sigemptyset(&set));
> -	if (TEST_RETURN == -1) {
> -		tst_resm(TFAIL | TTERRNO, "sigemptyset() failed");
> -		cleanup();
> -		tst_exit();
> -	}
> -	TEST(sigaddset(&set, SIGRTMIN));
> -	if (TEST_RETURN == -1){
> -		tst_resm(TFAIL | TTERRNO, "sigaddset() failed");
> -		cleanup();
> -		tst_exit();
> -	}
> -	
> -	/* call rt_sigaction() */
> -	act.sa_handler = sig_handler;
> -	TEST(syscall(__NR_rt_sigaction, SIGRTMIN, &act, &oact,
> -		SIGSETSIZE));
> -	if (TEST_RETURN != 0){
> -		tst_resm(TFAIL | TTERRNO,"rt_sigaction() failed");
> -	}
> -	/* call rt_sigprocmask() to block signal # SIGRTMIN */
> -	TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, SIGSETSIZE));
> -	if (TEST_RETURN == -1) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
> -	}
> -	TEST(kill(getpid(), SIGRTMIN));
> -	if (TEST_RETURN != 0){
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "kill() failed");
> -	}
> -	if (sig_count) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup,
> -			"rt_sigprocmask() failed to change the "
> -			"process's signal mask");
> -	}
> -	/* call rt_sigpending() */
> -	TEST(syscall(__NR_rt_sigpending, &oset, SIGSETSIZE));
> -	if (TEST_RETURN == -1) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigpending() failed");
> -	}
> -	TEST(sigismember(&oset, SIGRTMIN));
> -	if (TEST_RETURN == 0) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "sigismember() failed");
> -	}
> -	/* call rt_sigprocmask() to unblock signal#33 */
> -	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, SIGSETSIZE));
> -	if (TEST_RETURN == -1) {
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
> -	}
> -	if (sig_count) {
> -		tst_resm(TPASS, "rt_sigprocmask() PASSED");
> -	} else {
> -		tst_resm(TFAIL | TTERRNO,
> -			"rt_sigprocmask() "
> -			"functionality failed");
> -	}
> -
> -	cleanup();
> -	tst_exit();
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> 
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			TEST(sigemptyset(&set));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"Call to sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +			TEST(sigaddset(&set, TEST_SIG));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +				
> +			/* call rt_sigaction() */
> +                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
> +			if(TEST_RETURN != 0){
> +				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +			/* call rt_sigprocmask() to block signal#SIGRTMIN */
> +                        TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        	cleanup();
> +				tst_exit();
> +			}
> +			
> +			else {
> +				TEST(kill(getpid(), TEST_SIG));
> +				if(TEST_RETURN != 0){
> +					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        		cleanup();
> +					tst_exit();
> +					
> +				}
> +				if(sig_count){
> +					tst_resm(TFAIL,"FAIL --- rt_sigprocmask() fail to change the process's signal mask, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        		cleanup();
> +					tst_exit();
> +				}
> +				else {
> +					/* call rt_sigpending() */
> +					TEST(syscall(__NR_rt_sigpending, &oset, 8));
> +					if(TEST_RETURN == -1){
> +						tst_resm(TFAIL,"call rt_sigpending() failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        			cleanup();
> +						tst_exit();
> +					}
> +					TEST(sigismember(&oset, TEST_SIG));
> +					if(TEST_RETURN == 0 ){
> +						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        			cleanup();
> +						tst_exit();
> +					}
> +					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
> +					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
> +					if(TEST_RETURN == -1){
> +						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        			cleanup();
> +						tst_exit();
> +					}
> +					if(sig_count) {
> +						tst_resm(TPASS,"rt_sigprocmask() PASSED");
> +                        			cleanup();
> +						tst_exit();
> +					}
> +		                        else {
> +						tst_resm(TFAIL,"rt_sigprocmask() functionality failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +		                                cleanup();
> +						tst_exit();
> +		                        }
> +
> +				}
> +			}
> +
> +                }
> +	Tst_count++;
> +        }	
> +        tst_exit();
>  }
> +
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index fcb5b0b..84f2967 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -18,12 +18,12 @@
>  /******************************************************************************	*/
>  /******************************************************************************	*/
>  /*                                                                            	*/
> -/* File:        rt_sigsuspend01.c                                           	*/
> +/* File:        rt_sigsuspend01.c                                           	      	*/
>  /*                                                                            	*/
> -/* Description: This tests the rt_sigsuspend() syscall.                      	*/
> +/* Description: This tests the rt_sigsuspend() syscall.                      	      	*/
>  /*		                                                               	*/
>  /* Usage:  <for command-line>                                                 	*/
> -/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     	*/
> +/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     		*/
>  /*      where,  -c n : Run n copies concurrently.                             	*/
>  /*              -e   : Turn on errno logging.                                 	*/
>  /*              -i n : Execute test n times.                                  	*/
> @@ -33,15 +33,11 @@
>  /*                                                                            	*/
>  /* Total Tests: 2                                                             	*/
>  /*                                                                            	*/
> -/* Test Name:   rt_sigsuspend01                                             	*/
> +/* Test Name:   rt_sigsuspend01                                             		*/
>  /* History:     Porting from Crackerjack to LTP is done by                    	*/
>  /*              Manas Kumar Nayak maknayak@in.ibm.com>                        	*/
>  /********************************************************************************/
> 
> -#ifndef _GNU_SOURCE
> -#define _GNU_SOURCE
> -#endif
> -
>  #include <stdio.h>
>  #include <signal.h>
>  #include <errno.h>
> @@ -50,16 +46,19 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "linux_syscall_numbers.h"
> -#include "ltp_signal.h"
> +
> +#ifdef __x86_64__
> +#include "rt_signal.h"
> +#endif
> 
>  /* Extern Global Variables */
> -extern int Tst_count;            /* counter for tst_xxx routines.         */
> -extern char *TESTDIR;            /* temporary dir created by tst_tmpdir() */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> 
>  /* Global Variables */
>  char *TCID = "rt_sigsuspend01";  /* Test program identifier.*/
>  int  testno;
> -int  TST_TOTAL = 4;              /* total number of tests in this file.   */
> +int  TST_TOTAL =4;                   /* total number of tests in this file.   */
> 
>  /* Extern Global Functions */
>  /******************************************************************************/
> @@ -69,20 +68,23 @@ int  TST_TOTAL = 4;              /* total number of tests in this file.   */
>  /* Description: Performs all one time clean up for this test on successful    */
>  /*              completion,  premature exit or  failure. Closes all temporary */
>  /*              files, removes all temporary directories exits the test with  */
> -/*              appropriate return code by calling tst_exit() function.       */
> +/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
>  /*                                                                            */
>  /* Input:       None.                                                         */
>  /*                                                                            */
>  /* Output:      None.                                                         */
>  /*                                                                            */
> -/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> -/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
> +/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
>  /*                                                                            */
>  /******************************************************************************/
> -void cleanup() {
> -	/* Remove tmp dir and all files in it */
> -	TEST_CLEANUP;
> -	tst_rmdir();
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate TEST_RETURNurn code. */
> +        tst_exit();
>  }
> 
>  /* Local  Functions */
> @@ -100,14 +102,14 @@ void cleanup() {
>  /* Output:      None.                                                         */
>  /*                                                                            */
>  /* Return:      On failure - Exits by calling cleanup().                      */
> -/*              On success - Returns 0.					      */
> +/*              On success - TEST_RETURNurns 0.                                       */
>  /*                                                                            */
>  /******************************************************************************/
>  void setup() {
> -/* Capture signals if any */
> -/* Create temporary directories */
> -TEST_PAUSE;
> -tst_tmpdir();
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
>  }
> 
> 
> @@ -120,55 +122,77 @@ void sig_handler(int sig)
>  int main(int ac, char **av) {
>  	
>  	sigset_t set, set1, set2;
> -	char *msg;		/* message returned from parse_opts */
> +	int lc;                 /* loop counter */
> +        char *msg;              /* message TEST_RETURNurned from parse_opts */
>  	
> -	/* parse standard options */
> -	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> -		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> -		tst_exit();
> -	}
> -
> -	setup();
> -
> -	Tst_count = 0;
> -	TEST(sigemptyset(&set));
> -	if (TEST_RETURN == -1){
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "sigemptyset() failed");
> -	}
> -	struct sigaction act, oact;
> -	act.sa_handler = sig_handler;
> -			
> -	TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, SIGSETSIZE));
> -	if (TEST_RETURN == -1){
> -	       	tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigaction() failed");
> -	}
> -	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, SIGSETSIZE));
> -	if (TEST_RETURN == -1){
> -		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
> -		cleanup();
> -		tst_exit();
> -	}
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			TEST(sigemptyset(&set));
> +			if(TEST_RETURN == -1){
> +				tst_resm(TFAIL,"sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +				cleanup();
> +				tst_exit();
> +			}
> +#ifdef __x86_64__
> +		        struct kernel_sigaction act, oact;
> +			sig_initial(SIGALRM);
> +			act.sa_flags |= SA_RESTORER;
> +			act.sa_restorer = restore_rt;
> +			act.k_sa_handler = sig_handler;			
> +#else
> +			struct sigaction act, oact;
> +		        act.sa_handler = sig_handler;
> +#endif
> +			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
> +			if(TEST_RETURN == -1){
> +		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +				cleanup();
> +				tst_exit();
> +			}
> +			TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, 8));
> +			if(TEST_RETURN == -1){
> +		        	tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +				cleanup();
> +				tst_exit();
> +			}
>  			
> -	TEST(alarm(5));
> -	int result;
> -	TEST(result = syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE));
> -	TEST(alarm(0));
> -	if (result == -1 && TEST_ERRNO != EINTR) {
> -		TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2,
> -				SIGSETSIZE));
> -		if (TEST_RETURN == -1) {
> -			tst_resm(TFAIL | TTERRNO, "rt_sigprocmask() failed");
> -		} else if (set1.__val[0] != set2.__val[0]) {
> -			tst_resm(TFAIL | TTERRNO,
> -				"rt_sigsuspend failed to preserve signal mask");
> -	        } else {
> -			tst_resm(TPASS, "rt_sigsuspend PASSED");
> -		}
> -	} else {
> -		tst_resm(TFAIL | TTERRNO, "rt_sigsuspend failed");
> -	}
> -
> +			TEST(alarm(5));
> +		        int result;
> +			TEST(result = syscall(__NR_rt_sigsuspend, &set, 8));
> +		        TEST(alarm(0));
> +			if((result == -1) && (TEST_ERRNO != EINTR)){
> +				TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2, 8));
> +				if(TEST_RETURN == -1){
> +		        		tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +					cleanup();
> +					tst_exit();
> +				} else if(set1.__val[0] != set2.__val[0]){
> +		                        tst_resm(TFAIL," rt_sigsuspend failed to preserve signal mask,errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +					cleanup();
> +					tst_exit();
> +			        } else {
> +		                        tst_resm(TPASS,"rt_sigsuspend PASSED");
> +		                }
> +		        }else{
> +		             tst_resm(TFAIL," rt_sigsuspend failed ,errrno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +	                     cleanup();
> +			     tst_exit();
> +			}
> +		
> +	
> +                }
> +	 }
>  	cleanup();
> -	tst_exit();
> -
> +        tst_exit();
>  }
> +
> -- 
> 1.6.2.2
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Return on Information:
> Google Enterprise Search pays you back
> Get the facts.
> http://p.sf.net/sfu/google-dev2dev
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list


------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2009-12-09  7:34 liubo
  2009-12-09 12:14 ` Subrata Modak
  2009-12-18 16:03 ` Subrata Modak
  0 siblings, 2 replies; 34+ messages in thread
From: liubo @ 2009-12-09  7:34 UTC (permalink / raw)
  To: ltp-list

Here is the patch, which contains lots of adjustments 
on style, so it might be a bit huge.

Testcase 1. rt_sigaction01
On arch x86_64, if we directly get to call syscall 
rt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of 
"SA_RESTORER" and the correct pointer to the fuction 
"restorer", according to the kernel code.
2) The other reason is that default syscall rt_sigaction 
use kernel "sigaction" structure, which is different 
with normal "sigaction" structure.

So, 
1) We manage to find the address of the function 
"restorer" by using glibc function "sigaction", 
which might be something tricky. Then we add these 
arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit 
realtime syscall __NR_rt_sigaction.

Testcase 2. rt_sigprocmask01
First, there exsits the same problem as rt_sigaction01.
Second, this testcase uses a unchanged signal number 33, 
which may diff among different archs and lead to error
"unknown signal".

So, we use a macro TEST_SIG which refers to SIGRTMIN 
to replace 33.

Testcase 3. rt_sigsuspend01
There exists the same problem as rt_sigaction01.

This patch fixed these failure.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 include/ltp_signal.h                               |  152 --------
 include/rt_signal.h                                |   60 ++++
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |  364 +++++++++-----------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |  331 ++++++++++--------
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |  168 +++++----
 5 files changed, 499 insertions(+), 576 deletions(-)
 delete mode 100644 include/ltp_signal.h
 create mode 100644 include/rt_signal.h

diff --git a/include/ltp_signal.h b/include/ltp_signal.h
deleted file mode 100644
index 5e9a198..0000000
--- a/include/ltp_signal.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-
-#ifndef __LTP_SIGNAL_H
-#define __LTP_SIGNAL_H
-
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include "config.h"
-
-#define SIGSETSIZE (_NSIG / 8)
-
-#ifdef LTP_RT_SIG_TEST
-
-extern int  expected_signal_number;
-
-#if defined(__x86_64__)
-
-/*
- * From asm/signal.h -- this value isn't exported anywhere outside of glibc and
- * asm/signal.h and is only required for the rt_sig* function family because
- * sigaction(2), et all, appends this if necessary to
- * (struct sigaction).sa_flags. HEH.
- *
- * I do #undef though, just in case...
- */
-#undef SA_RESTORER
-#define SA_RESTORER	0x04000000
-
-/* 
- * From .../arch/x86/kernel/signal.c:448 --
- *
- * x86-64 should always use SA_RESTORER.
- *
- * -- thus SA_RESTORER must always be defined along with
- * (struct sigaction).sa_restorer.
- */
-#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa) __sa.sa_flags |= SA_RESTORER; __sa.sa_restorer = dummy_restorer;
-/* defined(__x86_64) */
-#else
-#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa)
-#endif
-
-/*
- * To help direct sigsegv_sigaction_handler in determining whether or not the
- * segfault was valid.
- */
-extern int  expected_signal_number;
-
-/* 
- * A dummy sa_restorer function, because we have to have it if SA_RESTORER is
- * required.
- */
-inline void
-dummy_restorer(void) {
-	tst_resm(TINFO, "%s called", __func__);
-}
-
-/* 
- * SIGSEGV will be thrown if an overflow occurs, or some other undesired
- * precondition. Let's catch it so the test will at least proceed and not
- * completely bomb the heck out.
- */
-inline void
-sigsegv_sigaction_handler(int signum, siginfo_t *siginfo, void *ucontext) {
-
-	/*
-	 * Backwards compatibility is a pain; I think that's what's driving
-	 * the implicit sa_restorer BS on x86_64, and the reason why mips* and
-	 * ppc* only has a sigaction handler (not rt_sigaction).
-	 *
-	 * GG for backwards compatibility and lack of documentation on an
-	 * internal syscall...
-	 */
-#ifdef __x86_64__
-	if (expected_signal_number == SIGRTMIN) {
-		tst_resm(TINFO, "SIGRTMIN segfaults on x86_64 (known issue).");
-	} else {
-#endif
-	tst_brkm(TBROK | TERRNO, NULL,
-		"Uncaught SIGSEGV; please validate whether or not test meets "
-		"functional requirements as per do_signal and callees in "
-		"$KERN_SRC/arch/<arch>/kernel/signal.c is concerned");
-
-#ifdef __x86_64__
-	}
-#endif
-}
-
-/* 
- * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a SIGSEGV
- * at the kernel level because of an -EFAULT was tossed by a caller. What a
- * PITA :].
- */
-inline int
-setup_sigsegv_sigaction_handler()
-{
-	int rc = -1;
-	struct sigaction sa;
-	sigset_t sigset;
-
-	/* 
-	 * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a
-	 * SIGSEGV at the kernel level because of an -EFAULT was tossed by a
-	 * caller. What a PITA :].
-	 */
-	sa.sa_sigaction = (void *)sigsegv_sigaction_handler;
-	/* We want the handler to persist, so don't do SA_RESETHAND... */
-	sa.sa_flags = SA_SIGINFO;
-
-	if (sigemptyset(&sa.sa_mask) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"Failed to call sigemptyset for SIGSEGV");
-	} else if (sigaddset(&sigset, SIGSEGV) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"Failed to do sigaddset for SIGSEGV");
-	} else if (sigaction(SIGSEGV, &sa, (struct sigaction *) NULL) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"Failed to setup sighandler for SIGSEGV");
-	} else {
-		rc = 0;
-	}
-
-	return rc;
-
-}
-
-#endif /* RT_SIG_TEST */
-
-#endif
diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..be64deb
--- /dev/null
+++ b/include/rt_signal.h
@@ -0,0 +1,60 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) 2009 FUJITSU LIMITED                                         */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/* Author: Liu Bo <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#ifndef __LTP_SIGNAL_H
+#define __LTP_SIGNAL_H
+
+/* We do not globally define the SA_RESTORER flag so do it here.  */
+#define HAVE_SA_RESTORER
+#define SA_RESTORER 0x04000000
+
+struct kernel_sigaction {
+	__sighandler_t k_sa_handler;
+	unsigned long sa_flags;
+	void (*sa_restorer) (void);
+	sigset_t sa_mask;
+};
+
+void (*restore_rt) (void);
+
+void
+handler_h(void)
+{
+	return;
+}
+
+/* initial restore_rt for x86_64 */
+void
+sig_initial(int sig)
+{
+	struct sigaction act, oact;
+
+	act.sa_handler = (void *)handler_h;
+	sigemptyset(&act.sa_mask);
+	sigaddset(&act.sa_mask, sig);
+	/* copy act.sa_restorer to kernel */
+	sigaction(sig, &act, &oact);
+	/* copy oact.sa_restorer from kernel */
+	sigaction(sig, &act, &oact);
+	restore_rt = oact.sa_restorer;
+}
+
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 6e937d2..d30f204 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -1,266 +1,216 @@
 /******************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007				   */
-/*									    */
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
 /* This program is free software;  you can redistribute it and/or modify      */
 /* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or	  */
-/* (at your option) any later version.					*/
-/*									    */
-/* This program is distributed in the hope that it will be useful,	    */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	    */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		  */
-/* the GNU General Public License for more details.			   */
-/*									    */
-/* You should have received a copy of the GNU General Public License	  */
-/* along with this program;  if not, write to the Free Software	       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
-/*									    */
+/*                                                                            */
 /******************************************************************************/
 /******************************************************************************/
-/*									    */
-/* File:	rt_sigaction01.c					      */
-/*									    */
-/* Description: This tests the rt_sigaction() syscall			 */
+/*                                                                            */
+/* File:        rt_sigaction01.c                                              */
+/*                                                                            */
+/* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction alters an action taken by a process on receipt   */
-/* 		of a particular signal. The action is specified by the	*/
+/* 		of a particular signal. The action is specified by the        */
 /*		sigaction structure. The previous action on the signal is     */
-/*		saved in oact.sigsetsize should indicate the size of a	*/
-/*		sigset_t type.		       			      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]			*/
-/*      where,  -c n : Run n copies concurrently.			     */
-/*	      -e   : Turn on errno logging.				 */
-/*	      -i n : Execute test n times.				  */
-/*	      -I x : Execute test for x seconds.			    */
-/*	      -P x : Pause for x seconds between iterations.		*/
-/*	      -t   : Turn on syscall timing.				*/
-/*									    */
-/* Total Tests: 1							     */
-/*									    */
-/* Test Name:   rt_sigaction01					     */
-/* History:     Porting from Crackerjack to LTP is done by		    */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
+/*		saved in oact.sigsetsize should indicate the size of a        */
+/*		sigset_t type.                       			      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   rt_sigaction01                                             */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <signal.h>
 #include <errno.h>
-#include <sys/types.h>
+#include <sys/syscall.h>
 #include <string.h>
-#include "config.h"
 
 /* Harness Specific Include Files. */
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#define LTP_RT_SIG_TEST
-#include "ltp_signal.h"
+
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
+/*
+ * For all but __mips__:
+ *
+ * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 2.
+ *
+ * For __mips__:
+ *
+ * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 4.
+ *
+ * See asm/compat.h under the kernel source for more details.
+ *
+ * Multiply that by a fudge factor of 4 and you have your SIGSETSIZE.
+ */
+#if defined (__mips__)
+#define SIGSETSIZE 16
+#else
+#define SIGSETSIZE 8
+#endif
 
 /* Extern Global Variables */
-extern int Tst_count;	   /* counter for tst_xxx routines.	 */
-extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir() */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
 
 /* Global Variables */
 char *TCID = "rt_sigaction01";  /* Test program identifier.*/
-int  expected_signal_number = 0;
-int  pass_count = 0;
 int  testno;
-int  TST_TOTAL = 1;		   /* total number of tests in this file.   */
-
-int test_flags[] = {
-	SA_RESETHAND|SA_SIGINFO,
-	SA_RESETHAND,
-	SA_RESETHAND|SA_SIGINFO,
-	SA_RESETHAND|SA_SIGINFO,
-	SA_NOMASK
-};
-char *test_flags_list[] = {
-	"SA_RESETHAND|SA_SIGINFO",
-	"SA_RESETHAND",
-	"SA_RESETHAND|SA_SIGINFO",
-	"SA_RESETHAND|SA_SIGINFO",
-	"SA_NOMASK"
-};
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
 
 /* Extern Global Functions */
 /******************************************************************************/
-/*									    */
-/* Function:    cleanup						       */
-/*									    */
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
 /* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary */
-/*	      files, removes all temporary directories exits the test with  */
-/*	      appropriate return code by calling tst_exit() function.       */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
 /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.  */
-/*									    */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
 /******************************************************************************/
-static void cleanup() {
+extern void cleanup() 
+{
 	/* Remove tmp dir and all files in it */
 	TEST_CLEANUP;
 	tst_rmdir();
+
+	/* Exit with appropriate return code. */
+	tst_exit();
 }
 
 /* Local  Functions */
 /******************************************************************************/
-/*									    */
-/* Function:    setup							 */
-/*									    */
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
 /* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs      */
-/*	      and temporary files that may be used in the course of this    */
-/*	      test.							 */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.				       */
-/*									    */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
 /******************************************************************************/
-void
-setup()
+void setup() 
 {
-	(void) setup_sigsegv_sigaction_handler();
-	/* Wait for SIGUSR1 if requested */
-	TEST_PAUSE;
+	/* Capture signals if any */
 	/* Create temporary directories */
+	TEST_PAUSE;
 	tst_tmpdir();
 }
 
+int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};
+char *test_flags_list[] = {"SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK"};
+
 void
 handler(int sig)
 {
-	tst_resm(TINFO, "Signal handler (non-sigaction) called with signal number %d", sig);
-	pass_count++;
+        tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
+        return;
 }
-
-void
-sigaction_handler(int sig, siginfo_t *siginfo, void *ucontext) {
-	tst_resm(TINFO, "Signal handler (sigaction) called with signal number %d", sig);
-	if (sig == expected_signal_number)
-		pass_count++;
-}
-
 int
 set_handler(int sig, int mask_flags)
 {
-	int rc = -1;
-	struct sigaction sa;
-
-	//memset(&sa, 0, SIGSETSIZE);
-
-	sa.sa_flags = mask_flags;
-
-	ARCH_SPECIFIC_RT_SIGACTION_SETUP(sa);
-
-#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
-	/*
-         *  SA_SIGINFO (since Linux 2.2)
-         *        The  signal  handler  takes  3  arguments, not one.  In this
-         *        case, sa_sigaction should  be  set  instead  of  sa_handler.
-         *        This flag is only meaningful when establishing a signal han-
-         *        dler.
-         *
-	 */
-	if (sa.sa_flags & SA_SIGINFO)
-		sa.sa_sigaction = (void *) sigaction_handler;
-	else
+#ifdef __x86_64__
+	struct kernel_sigaction sa, oldaction;
+	mask_flags |= SA_RESTORER;
+	sa.sa_restorer = restore_rt;
+	sa.k_sa_handler = (void *)handler;
+#else
+	struct sigaction sa, oldaction;
+	sa.sa_handler = (void *)handler;
 #endif
-		sa.sa_handler = (void *) handler;
-
-	if (sigemptyset(&sa.sa_mask) < 0) {
-		tst_resm(TINFO, "sigemptyset(..) failed");
-	} else if (sigaddset(&sa.sa_mask, sig) < 0) {
-		tst_resm(TFAIL | TINFO, "sigaddset(..) failed");
-	} else if (syscall(__NR_rt_sigaction, sig, &sa, (struct sigaction*) NULL, SIGSETSIZE)) {
-		tst_resm(TFAIL | TERRNO, "rt_sigaction(%d, ..) failed", sig);
-	} else {
-		rc = 0;
-	}
-	return rc;
+	sa.sa_flags = mask_flags;
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, sig);
+	TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
+	return TEST_RETURN;
 }
 
-int
-main(int ac, char **av) {
 
-	char *msg;	/* message returned from parse_opts */
-
-	/* parse standard options */
-	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
-		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
-
-	setup();
-
-#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
-	int flag;
-	int last_pass_count;
-	int num_tests_per_signal = sizeof(test_flags) / sizeof(*test_flags);
-	int tests_passed;
-	int lc;		/* loop counter */
-
-	tst_resm(TINFO, "Will run %d tests per signal in set [%d, %d]",
-			num_tests_per_signal, SIGRTMIN, SIGRTMAX);
-
-	/* Check looping state if -i option given */
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-
-		Tst_count = 0;
-
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-
-			/* 34 (NPTL) or 35 (LinuxThreads) to 65 (or 128 on mips). */
-			for (expected_signal_number = SIGRTMIN; expected_signal_number <= SIGRTMAX; expected_signal_number++) { 
-
-				last_pass_count = pass_count;
-
-				tst_resm(TINFO, "signal: %d ", expected_signal_number);
-
-			 	for (flag = 0; flag < num_tests_per_signal; flag++) {
-
-					if (set_handler(expected_signal_number, test_flags[flag]) == 0) {
-
-						tst_resm(TINFO,
-							"\tsa.sa_flags = %s",
-							test_flags_list[flag]);
-
-						if (kill(getpid(), expected_signal_number) < 0) {
-							tst_resm(TINFO | TERRNO, "kill failed");
-						}
-
-		       			}
-
-				}
-
-				tests_passed = ((pass_count - last_pass_count) ==
-						 num_tests_per_signal);
-
-				tst_resm(tests_passed ? TPASS : TFAIL,
-					"tests %s for signal = %d",
-					tests_passed ? "passed" : "failed",
-					expected_signal_number);
-
-			}
-
-		}
-
-	}
-#else
-	tst_brkm(TCONF, NULL,
-			"Your architecture doesn't support this test (no "
-			"sa_sigaction field in struct sigaction).");
+int main(int ac, char **av) {
+	int signal, flag;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+                
+			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
+#ifdef __x86_64__
+				sig_initial(signal);
 #endif
+				for(flag=0; flag<5;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
+						 if (TEST_RETURN == 0) {
+        					tst_resm(TINFO,"signal: %d ", signal);
+        					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
+        					tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]);
+						kill(getpid(),signal);
+			                         } else {
+                 	   				tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+                       				}
+                			}
+		 	printf("\n");	
+        		}
+
+
+
+                }
+        }	
 	cleanup();
-	tst_exit();
-
+        tst_exit();
 }
+
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 2e51176..8bcdc78 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -1,26 +1,26 @@
 /******************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007				      */
-/*									      */
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
 /* This program is free software;  you can redistribute it and/or modify      */
 /* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or	      */
-/* (at your option) any later version.					      */
-/*									      */
-/* This program is distributed in the hope that it will be useful,	      */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	      */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		      */
-/* the GNU General Public License for more details.			      */
-/*									      */
-/* You should have received a copy of the GNU General Public License	      */
-/* along with this program;  if not, write to the Free Software		      */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
-/*									      */
+/*                                                                            */
 /******************************************************************************/
 /******************************************************************************/
-/*									      */
-/* File:	rt_sigprocmask01.c					      */
-/*									      */
-/* Description: This tests the rt_sigprocmask() syscall			      */
+/*                                                                            */
+/* File:        rt_sigprocmask01.c                                              */
+/*                                                                            */
+/* Description: This tests the rt_sigprocmask() syscall                       */
 /*		rt_sigprocmask changes the list of currently blocked signals. */
 /*		The set value stores the signal mask of the pending signals.  */
 /*		The previous action on the signal is saved in oact. The value */
@@ -37,170 +37,211 @@
 /*		SIG_SETMASK						      */
 /*		    The set of blocked signals is set to the set argument.    */
 /*		    sigsetsize should indicate the size of a sigset_t type.   */
-/*									      */
-/* Usage:  <for command-line>						      */
-/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]		      */
-/*      where,  -c n : Run n copies concurrently.			      */
-/*	      -e   : Turn on errno logging.				      */
-/*	      -i n : Execute test n times.				      */
-/*	      -I x : Execute test for x seconds.			      */
-/*	      -P x : Pause for x seconds between iterations.		      */
-/*	      -t   : Turn on syscall timing.				      */
-/*									      */
-/* Total Tests: 1							      */
-/*									      */
-/* Test Name:   rt_sigprocmask01					      */
-/* History:     Porting from Crackerjack to LTP is done by		      */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   rt_sigprocmask01                                              */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
 #include <stdio.h>
+#include <signal.h>
 #include <errno.h>
 
 /* Harness Specific Include Files. */
-#include "ltp_signal.h"
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
+#define TEST_SIG SIGRTMIN
+
 /* Extern Global Variables */
-extern int Tst_count;	   /* counter for tst_xxx routines.	 	      */
-extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir()	      */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
 
 /* Global Variables */
-char *TCID = "rt_sigprocmask01";	/* Test program identifier.	      */
-int  TST_TOTAL = 8;			/* total number of tests in this file.*/
+char *TCID = "rt_sigprocmask01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 8;                   /* total number of tests in this file.   */
 
 /* Extern Global Functions */
 /******************************************************************************/
-/*									      */
-/* Function:    cleanup							      */
-/*									      */
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
 /* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary   */
-/*	      files, removes all temporary directories exits the test with    */
-/*	      appropriate return code by calling tst_exit() function.	      */
-/*									      */
-/* Input:       None.							      */
-/*									      */
-/* Output:      None.							      */
-/*									      */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
 /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.    */
-/*									      */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
 /******************************************************************************/
 extern void cleanup() {
-	/* Remove tmp dir and all files in it */
-	TEST_CLEANUP;
-	tst_rmdir();
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
 
-	/* Exit with appropriate return code. */
-	tst_exit();
+        /* Exit with appropriate return code. */
+        tst_exit();
 }
 
 /* Local  Functions */
 /******************************************************************************/
-/*									      */
-/* Function:    setup							      */
-/*									      */
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
 /* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs	      */
-/*	      and temporary files that may be used in the course of this      */
-/*	      test.							      */
-/*									      */
-/* Input:       None.							      */
-/*									      */
-/* Output:      None.							      */
-/*									      */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.					      */
-/*									      */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
 /******************************************************************************/
 void setup() {
-	/* Capture signals if any */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
 }
 
 int sig_count = 0;
 
 void sig_handler(int sig)
 {
-	sig_count++;
+        sig_count++;
 }
 
 int main(int ac, char **av) {
-	struct sigaction act, oact;
-	sigset_t set, oset;
-	int lc;		 /* loop counter */
-	char *msg;	      /* message returned from parse_opts */
+#ifdef __x86_64__
+	struct kernel_sigaction act, oact;
+	sig_initial(TEST_SIG);
+	act.sa_flags |= SA_RESTORER;
+        act.sa_restorer = restore_rt;
+        act.k_sa_handler = sig_handler;
+#else
+        struct sigaction act, oact;
+        act.sa_handler = sig_handler;
+#endif
+        sigset_t set, oset;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
 	
-	/* parse standard options */
-	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
-		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
-
-	setup();
-
-	Tst_count = 0;
-	TEST(sigemptyset(&set));
-	if (TEST_RETURN == -1) {
-		tst_resm(TFAIL | TTERRNO, "sigemptyset() failed");
-		cleanup();
-		tst_exit();
-	}
-	TEST(sigaddset(&set, SIGRTMIN));
-	if (TEST_RETURN == -1){
-		tst_resm(TFAIL | TTERRNO, "sigaddset() failed");
-		cleanup();
-		tst_exit();
-	}
-	
-	/* call rt_sigaction() */
-	act.sa_handler = sig_handler;
-	TEST(syscall(__NR_rt_sigaction, SIGRTMIN, &act, &oact,
-		SIGSETSIZE));
-	if (TEST_RETURN != 0){
-		tst_resm(TFAIL | TTERRNO,"rt_sigaction() failed");
-	}
-	/* call rt_sigprocmask() to block signal # SIGRTMIN */
-	TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, SIGSETSIZE));
-	if (TEST_RETURN == -1) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
-	}
-	TEST(kill(getpid(), SIGRTMIN));
-	if (TEST_RETURN != 0){
-		tst_brkm(TFAIL | TTERRNO, cleanup, "kill() failed");
-	}
-	if (sig_count) {
-		tst_brkm(TFAIL | TTERRNO, cleanup,
-			"rt_sigprocmask() failed to change the "
-			"process's signal mask");
-	}
-	/* call rt_sigpending() */
-	TEST(syscall(__NR_rt_sigpending, &oset, SIGSETSIZE));
-	if (TEST_RETURN == -1) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigpending() failed");
-	}
-	TEST(sigismember(&oset, SIGRTMIN));
-	if (TEST_RETURN == 0) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "sigismember() failed");
-	}
-	/* call rt_sigprocmask() to unblock signal#33 */
-	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, SIGSETSIZE));
-	if (TEST_RETURN == -1) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
-	}
-	if (sig_count) {
-		tst_resm(TPASS, "rt_sigprocmask() PASSED");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
-			"rt_sigprocmask() "
-			"functionality failed");
-	}
-
-	cleanup();
-	tst_exit();
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
 
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			TEST(sigemptyset(&set));
+			if(TEST_RETURN == -1){
+				tst_resm(TFAIL,"Call to sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        	cleanup();
+				tst_exit();
+			}
+			TEST(sigaddset(&set, TEST_SIG));
+			if(TEST_RETURN == -1){
+				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        	cleanup();
+				tst_exit();
+			}
+				
+			/* call rt_sigaction() */
+                        TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8));
+			if(TEST_RETURN != 0){
+				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        	cleanup();
+				tst_exit();
+			}
+			/* call rt_sigprocmask() to block signal#SIGRTMIN */
+                        TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
+			if(TEST_RETURN == -1){
+				tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        	cleanup();
+				tst_exit();
+			}
+			
+			else {
+				TEST(kill(getpid(), TEST_SIG));
+				if(TEST_RETURN != 0){
+					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        		cleanup();
+					tst_exit();
+					
+				}
+				if(sig_count){
+					tst_resm(TFAIL,"FAIL --- rt_sigprocmask() fail to change the process's signal mask, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        		cleanup();
+					tst_exit();
+				}
+				else {
+					/* call rt_sigpending() */
+					TEST(syscall(__NR_rt_sigpending, &oset, 8));
+					if(TEST_RETURN == -1){
+						tst_resm(TFAIL,"call rt_sigpending() failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        			cleanup();
+						tst_exit();
+					}
+					TEST(sigismember(&oset, TEST_SIG));
+					if(TEST_RETURN == 0 ){
+						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        			cleanup();
+						tst_exit();
+					}
+					/* call rt_sigprocmask() to unblock signal#SIGRTMIN */
+					TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8));
+					if(TEST_RETURN == -1){
+						tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        			cleanup();
+						tst_exit();
+					}
+					if(sig_count) {
+						tst_resm(TPASS,"rt_sigprocmask() PASSED");
+                        			cleanup();
+						tst_exit();
+					}
+		                        else {
+						tst_resm(TFAIL,"rt_sigprocmask() functionality failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+		                                cleanup();
+						tst_exit();
+		                        }
+
+				}
+			}
+
+                }
+	Tst_count++;
+        }	
+        tst_exit();
 }
+
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index fcb5b0b..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -18,12 +18,12 @@
 /******************************************************************************	*/
 /******************************************************************************	*/
 /*                                                                            	*/
-/* File:        rt_sigsuspend01.c                                           	*/
+/* File:        rt_sigsuspend01.c                                           	      	*/
 /*                                                                            	*/
-/* Description: This tests the rt_sigsuspend() syscall.                      	*/
+/* Description: This tests the rt_sigsuspend() syscall.                      	      	*/
 /*		                                                               	*/
 /* Usage:  <for command-line>                                                 	*/
-/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     	*/
+/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     		*/
 /*      where,  -c n : Run n copies concurrently.                             	*/
 /*              -e   : Turn on errno logging.                                 	*/
 /*              -i n : Execute test n times.                                  	*/
@@ -33,15 +33,11 @@
 /*                                                                            	*/
 /* Total Tests: 2                                                             	*/
 /*                                                                            	*/
-/* Test Name:   rt_sigsuspend01                                             	*/
+/* Test Name:   rt_sigsuspend01                                             		*/
 /* History:     Porting from Crackerjack to LTP is done by                    	*/
 /*              Manas Kumar Nayak maknayak@in.ibm.com>                        	*/
 /********************************************************************************/
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
@@ -50,16 +46,19 @@
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#include "ltp_signal.h"
+
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
 
 /* Extern Global Variables */
-extern int Tst_count;            /* counter for tst_xxx routines.         */
-extern char *TESTDIR;            /* temporary dir created by tst_tmpdir() */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
 
 /* Global Variables */
 char *TCID = "rt_sigsuspend01";  /* Test program identifier.*/
 int  testno;
-int  TST_TOTAL = 4;              /* total number of tests in this file.   */
+int  TST_TOTAL =4;                   /* total number of tests in this file.   */
 
 /* Extern Global Functions */
 /******************************************************************************/
@@ -69,20 +68,23 @@ int  TST_TOTAL = 4;              /* total number of tests in this file.   */
 /* Description: Performs all one time clean up for this test on successful    */
 /*              completion,  premature exit or  failure. Closes all temporary */
 /*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
+/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
 /*                                                                            */
 /* Input:       None.                                                         */
 /*                                                                            */
 /* Output:      None.                                                         */
 /*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
+/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
 /*                                                                            */
 /******************************************************************************/
-void cleanup() {
-	/* Remove tmp dir and all files in it */
-	TEST_CLEANUP;
-	tst_rmdir();
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate TEST_RETURNurn code. */
+        tst_exit();
 }
 
 /* Local  Functions */
@@ -100,14 +102,14 @@ void cleanup() {
 /* Output:      None.                                                         */
 /*                                                                            */
 /* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - Returns 0.					      */
+/*              On success - TEST_RETURNurns 0.                                       */
 /*                                                                            */
 /******************************************************************************/
 void setup() {
-/* Capture signals if any */
-/* Create temporary directories */
-TEST_PAUSE;
-tst_tmpdir();
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
 }
 
 
@@ -120,55 +122,77 @@ void sig_handler(int sig)
 int main(int ac, char **av) {
 	
 	sigset_t set, set1, set2;
-	char *msg;		/* message returned from parse_opts */
+	int lc;                 /* loop counter */
+        char *msg;              /* message TEST_RETURNurned from parse_opts */
 	
-	/* parse standard options */
-	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
-		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
-
-	setup();
-
-	Tst_count = 0;
-	TEST(sigemptyset(&set));
-	if (TEST_RETURN == -1){
-		tst_brkm(TFAIL | TTERRNO, cleanup, "sigemptyset() failed");
-	}
-	struct sigaction act, oact;
-	act.sa_handler = sig_handler;
-			
-	TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, SIGSETSIZE));
-	if (TEST_RETURN == -1){
-	       	tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigaction() failed");
-	}
-	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, SIGSETSIZE));
-	if (TEST_RETURN == -1){
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
-		cleanup();
-		tst_exit();
-	}
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			TEST(sigemptyset(&set));
+			if(TEST_RETURN == -1){
+				tst_resm(TFAIL,"sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+				cleanup();
+				tst_exit();
+			}
+#ifdef __x86_64__
+		        struct kernel_sigaction act, oact;
+			sig_initial(SIGALRM);
+			act.sa_flags |= SA_RESTORER;
+			act.sa_restorer = restore_rt;
+			act.k_sa_handler = sig_handler;			
+#else
+			struct sigaction act, oact;
+		        act.sa_handler = sig_handler;
+#endif
+			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
+			if(TEST_RETURN == -1){
+		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+				cleanup();
+				tst_exit();
+			}
+			TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, 8));
+			if(TEST_RETURN == -1){
+		        	tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+				cleanup();
+				tst_exit();
+			}
 			
-	TEST(alarm(5));
-	int result;
-	TEST(result = syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE));
-	TEST(alarm(0));
-	if (result == -1 && TEST_ERRNO != EINTR) {
-		TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2,
-				SIGSETSIZE));
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL | TTERRNO, "rt_sigprocmask() failed");
-		} else if (set1.__val[0] != set2.__val[0]) {
-			tst_resm(TFAIL | TTERRNO,
-				"rt_sigsuspend failed to preserve signal mask");
-	        } else {
-			tst_resm(TPASS, "rt_sigsuspend PASSED");
-		}
-	} else {
-		tst_resm(TFAIL | TTERRNO, "rt_sigsuspend failed");
-	}
-
+			TEST(alarm(5));
+		        int result;
+			TEST(result = syscall(__NR_rt_sigsuspend, &set, 8));
+		        TEST(alarm(0));
+			if((result == -1) && (TEST_ERRNO != EINTR)){
+				TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2, 8));
+				if(TEST_RETURN == -1){
+		        		tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+					cleanup();
+					tst_exit();
+				} else if(set1.__val[0] != set2.__val[0]){
+		                        tst_resm(TFAIL," rt_sigsuspend failed to preserve signal mask,errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+					cleanup();
+					tst_exit();
+			        } else {
+		                        tst_resm(TPASS,"rt_sigsuspend PASSED");
+		                }
+		        }else{
+		             tst_resm(TFAIL," rt_sigsuspend failed ,errrno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+	                     cleanup();
+			     tst_exit();
+			}
+		
+	
+                }
+	 }
 	cleanup();
-	tst_exit();
-
+        tst_exit();
 }
+
-- 
1.6.2.2










------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2010-02-27  4:12 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-10  9:38 [LTP] [PATCH] syscalls: fix some failure on arch X86_64 liubo
2009-11-11  1:28 ` liubo
2009-11-11  4:14   ` Garrett Cooper
2009-11-11  4:30     ` Wei Yongjun
2009-11-11  5:22     ` liubo
2009-11-11  4:33 ` Mike Frysinger
2009-11-11  5:03   ` Wei Yongjun
2009-11-16  8:13     ` Subrata Modak
2009-11-16  8:53       ` liubo
2009-11-26 11:11         ` Garrett Cooper
2009-11-27  5:33           ` liubo
2009-11-27  6:49             ` Garrett Cooper
2009-11-27  8:50               ` Garrett Cooper
2009-11-27 10:07                 ` liubo
2009-11-27 22:18                   ` Garrett Cooper
2009-11-29  1:22                     ` Wei Yongjun
2009-12-01  0:00                       ` Garrett Cooper
2009-12-09  7:29                         ` liubo
2009-12-09  7:34 liubo
2009-12-09 12:14 ` Subrata Modak
2009-12-18 16:03 ` Subrata Modak
2009-12-22  2:51   ` Garrett Cooper
2009-12-22 13:12     ` liubo
2010-02-22  5:21 liubo
2010-02-22  7:56 ` Garrett Cooper
2010-02-22  9:08   ` liubo
2010-02-22 18:05     ` Garrett Cooper
2010-02-23  0:59       ` liubo
2010-02-25  7:26         ` liubo
2010-02-25 10:00           ` Garrett Cooper
2010-02-26  0:35             ` liubo
2010-02-27  4:12               ` Garrett Cooper
2010-02-22  9:20 liubo
2010-02-22 14:45 ` Rishikesh K Rajak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.