Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1396615 > unrolled thread

qemu m68k/mcf5208: problem with signal handler

Started byWaldemar Brodkorb <wbx@openadk.org>
First post2016-05-09 08:50 +0200
Last post2016-05-09 18:30 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  qemu m68k/mcf5208: problem with signal handler Waldemar Brodkorb <wbx@openadk.org> - 2016-05-09 08:50 +0200
    Re: qemu m68k/mcf5208: problem with signal handler Waldemar Brodkorb <wbx@openadk.org> - 2016-05-09 11:00 +0200
      Re: qemu m68k/mcf5208: problem with signal handler Greg Ungerer <gerg@uclinux.org> - 2016-05-09 16:00 +0200
        Re: qemu m68k/mcf5208: problem with signal handler Waldemar Brodkorb <wbx@openadk.org> - 2016-05-09 18:30 +0200

#1396615 — qemu m68k/mcf5208: problem with signal handler

FromWaldemar Brodkorb <wbx@openadk.org>
Date2016-05-09 08:50 +0200
Subjectqemu m68k/mcf5208: problem with signal handler
Message-ID<rwNaW-7n5-13@gated-at.bofh.it>
Dear kernel hackers,

I have a problem with the signal handling under qemu-system-m68k
emulating coldfire mcf5208 evalboard. Following example code
provided by Busybox maintainer Denys Vlasenko
shows the problem when running on qemu:

#include <unistd.h>                                                                                                                                                    
#include <signal.h>                                                                                                                                                    
#include <sys/types.h>                                                                                                                                                 
#include <sys/wait.h>                                                                                                                                                  
static void sighandler(int sig)                                                                                                                                        
{                                                                                                                                                                      
        write(1, "SIGNAL\n", 7);                                                                                                                                       
}                                                                                                                                                                      
int main()                                                                                                                                                             
{                                                                                                                                                                      
        int pid;                                                                                                                                                       
                                                                                                                                                                       
        write(1, "VFORK1\n", 7);                                                                                                                                       
        pid = vfork();                                                                                                                                                 
        if (pid == 0) {                                                                                                                                                
                write(1, "EXIT1\n", 6);                                                                                                                                
                _exit(1);                                                                                                                                              
        }                                                                                                                                                              
        wait(NULL);                                                                                                                                                    
        signal(SIGCHLD, sighandler);                                                                                                                                   
        write(1, "VFORK2\n", 7);                                                                                                                                       
        pid = vfork();                                                                                                                                                 
        if (pid == 0) {                                                                                                                                                
                write(1, "EXIT2\n", 6);                                                                                                                                
                _exit(1);                                                                                                                                              
        }                                                                                                                                                              
        wait(NULL);                                                                                                                                                    
        write(1, "EXIT\n", 5);                                                                                                                                         
        return 0;                                                                                                                                                      
}                                                                                                                                                                      

You can generate a bootable image with latest buildroot, which shows the issue:
$ git clone git://git.buildroot.net/buildroot
$ cd buildroot; make qemu_m68k_mcf5208_defconfig; make
$ qemu-system-m68k -M mcf5208evb -cpu m5208 -kernel output/images/vmlinux -nographic

Every command forked from busybox hush shell will lead into a segmentation fault.

I added following printk to start investigating the problem:
diff -Nur linux-4.5.3.orig/arch/m68k/kernel/signal.c linux-4.5.3/arch/m68k/kernel/signal.c
--- linux-4.5.3.orig/arch/m68k/kernel/signal.c	2016-05-04 23:50:38.000000000 +0200
+++ linux-4.5.3/arch/m68k/kernel/signal.c	2016-05-09 04:24:53.885199544 +0200
@@ -595,6 +595,7 @@
 			       void __user *fp)
 {
 	int fsize = frame_extra_sizes(formatvec >> 12);
+	printk("avoid broken signal handler...\n");
 	if (fsize < 0) {
 		/*
 		 * user process trying to return with weird frame format

But now the problem disappeared. :/

What do you think? Is it a Kernel bug or a C library problem?

Busybox hush otherwise works fine for other noMMU targets as stm32
evalboard with cortex-m4. It also works in Qemu M68k emulating Q800
full MMU system.

Thanks for any ideas,
 Waldemar

http://lists.busybox.net/pipermail/busybox/2014-September/081659.html

[toc] | [next] | [standalone]


#1396863

FromWaldemar Brodkorb <wbx@openadk.org>
Date2016-05-09 11:00 +0200
Message-ID<rwPcK-1Kc-21@gated-at.bofh.it>
In reply to#1396615
Hi,

forgot to add Greg in CC.
And sorry for the whitespace fuckup in the example code.

Waldemar Brodkorb wrote,

> Dear kernel hackers,
> 
> I have a problem with the signal handling under qemu-system-m68k
> emulating coldfire mcf5208 evalboard. Following example code
> provided by Busybox maintainer Denys Vlasenko
> shows the problem when running on qemu:

[ .. ]

> You can generate a bootable image with latest buildroot, which shows the issue:
> $ git clone git://git.buildroot.net/buildroot
> $ cd buildroot; make qemu_m68k_mcf5208_defconfig; make
> $ qemu-system-m68k -M mcf5208evb -cpu m5208 -kernel output/images/vmlinux -nographic
> 
> Every command forked from busybox hush shell will lead into a segmentation fault.
> 
> I added following printk to start investigating the problem:
> diff -Nur linux-4.5.3.orig/arch/m68k/kernel/signal.c linux-4.5.3/arch/m68k/kernel/signal.c
> --- linux-4.5.3.orig/arch/m68k/kernel/signal.c	2016-05-04 23:50:38.000000000 +0200
> +++ linux-4.5.3/arch/m68k/kernel/signal.c	2016-05-09 04:24:53.885199544 +0200
> @@ -595,6 +595,7 @@
>  			       void __user *fp)
>  {
>  	int fsize = frame_extra_sizes(formatvec >> 12);
> +	printk("avoid broken signal handler...\n");
>  	if (fsize < 0) {
>  		/*
>  		 * user process trying to return with weird frame format
> 
> But now the problem disappeared. :/
> 
> What do you think? Is it a Kernel bug or a C library problem?
> 
> Busybox hush otherwise works fine for other noMMU targets as stm32
> evalboard with cortex-m4. It also works in Qemu M68k emulating Q800
> full MMU system.
> 
> Thanks for any ideas,
>  Waldemar
> 
> http://lists.busybox.net/pipermail/busybox/2014-September/081659.html
> 

[toc] | [prev] | [next] | [standalone]


#1397074

FromGreg Ungerer <gerg@uclinux.org>
Date2016-05-09 16:00 +0200
Message-ID<rwTT4-6II-7@gated-at.bofh.it>
In reply to#1396863
Hi Waldemar,

On 09/05/16 18:58, Waldemar Brodkorb wrote:
> Hi,
>
> forgot to add Greg in CC.
> And sorry for the whitespace fuckup in the example code.
>
> Waldemar Brodkorb wrote,
>
>> Dear kernel hackers,
>>
>> I have a problem with the signal handling under qemu-system-m68k
>> emulating coldfire mcf5208 evalboard. Following example code
>> provided by Busybox maintainer Denys Vlasenko
>> shows the problem when running on qemu:
>
> [ .. ]
>
>> You can generate a bootable image with latest buildroot, which shows the issue:
>> $ git clone git://git.buildroot.net/buildroot
>> $ cd buildroot; make qemu_m68k_mcf5208_defconfig; make
>> $ qemu-system-m68k -M mcf5208evb -cpu m5208 -kernel output/images/vmlinux -nographic
>>
>> Every command forked from busybox hush shell will lead into a segmentation fault.
>>
>> I added following printk to start investigating the problem:
>> diff -Nur linux-4.5.3.orig/arch/m68k/kernel/signal.c linux-4.5.3/arch/m68k/kernel/signal.c
>> --- linux-4.5.3.orig/arch/m68k/kernel/signal.c	2016-05-04 23:50:38.000000000 +0200
>> +++ linux-4.5.3/arch/m68k/kernel/signal.c	2016-05-09 04:24:53.885199544 +0200
>> @@ -595,6 +595,7 @@
>>   			       void __user *fp)
>>   {
>>   	int fsize = frame_extra_sizes(formatvec >> 12);
>> +	printk("avoid broken signal handler...\n");
>>   	if (fsize < 0) {
>>   		/*
>>   		 * user process trying to return with weird frame format
>>
>> But now the problem disappeared. :/
>>
>> What do you think? Is it a Kernel bug or a C library problem?

What version of linux kernel?
What version of gcc?

This sounds a lot like the problem I fixed in linux commit a9551799
("m68k: Use conventional function parameters for do_sigreturn").

Definitely try that first.

Regards
Greg


>> Busybox hush otherwise works fine for other noMMU targets as stm32
>> evalboard with cortex-m4. It also works in Qemu M68k emulating Q800
>> full MMU system.
>>
>> Thanks for any ideas,
>>   Waldemar
>>
>> http://lists.busybox.net/pipermail/busybox/2014-September/081659.html
>>
>

[toc] | [prev] | [next] | [standalone]


#1397166

FromWaldemar Brodkorb <wbx@openadk.org>
Date2016-05-09 18:30 +0200
Message-ID<rwWef-RF-23@gated-at.bofh.it>
In reply to#1397074
Hi Greg,
Greg Ungerer wrote,

> >>What do you think? Is it a Kernel bug or a C library problem?
> 
> What version of linux kernel?

4.5.3

> What version of gcc?

4.9.3
 
> This sounds a lot like the problem I fixed in linux commit a9551799
> ("m68k: Use conventional function parameters for do_sigreturn").
> 
> Definitely try that first.

Jackpot. Thanks a lot. This works!
May be some candidate for LTS kernels.

best regards
 Waldemar

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web