# Re: \[PATCH 10/19\] LoongArch: Add signal handling support

- From: Huacai Chen \<hidden\>
- Date: 2021-07-08 13:04:45 
- List: linux-arch
- Page: https://ratatoskr.run/linux-arch/2021/07/13337078
- Thread: https://ratatoskr.run/linux-arch/2021/07/13337006/t.md

```text
Hi Arnd,

On Tue, Jul 6, 2021 at 6:17 PM Arnd Bergmann [ref] wrote:
>
> On Tue, Jul 6, 2021 at 6:18 AM Huacai Chen [ref] wrote:
> >
> > This patch adds signal handling support for LoongArch.
> >
> > Signed-off-by: Huacai Chen <redacted>
>
> Eric Biederman should review this part as well.
>
> > --- /dev/null
> > +++ b/arch/loongarch/include/asm/sigcontext.h
> > @@ -0,0 +1,10 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * Copyright (C) 2020-2021 Loongson Technology Corporation Limited
> > + */
> > +#ifndef _ASM_SIGCONTEXT_H
> > +#define _ASM_SIGCONTEXT_H
> > +
> > +#include <uapi/asm/sigcontext.h>
> > +
> > +#endif /* _ASM_SIGCONTEXT_H */
>
> Remove this file
OK, thanks.

>
> > + */
> > +#ifndef _UAPI_ASM_SIGINFO_H
> > +#define _UAPI_ASM_SIGINFO_H
> > +
> > +#if _LOONGARCH_SZLONG == 32
> > +#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
> > +#else
> > +#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
> > +#endif
>
> These are no longer used.
OK, thanks.

>
> > +
> > +#ifndef _NSIG
> > +#define _NSIG          128
> > +#endif
>
> Everything else uses 64 here, except for MIPS.
Once before we also wanted to use 64, but we also want to use LBT to
execute X86/MIPS/ARM binaries, so we chose the largest value (128).
Some applications, such as sighold02 in LTP, will fail if _NSIG is not
big enough.

Huacai
>
> > +#define _NSIG_BPW      __BITS_PER_LONG
> > +#define _NSIG_WORDS    (_NSIG / _NSIG_BPW)
> > +
> > +#define SIGHUP          1
> > +#define SIGINT          2
> > +#define SIGQUIT                 3
> > +#define SIGILL          4
> > +#define SIGTRAP                 5
> > +#define SIGABRT                 6
> > +#define SIGIOT          6
> > +#define SIGBUS          7
> > +#define SIGFPE          8
> > +#define SIGKILL                 9
> > +#define SIGUSR1                10
> > +#define SIGSEGV                11
> > +#define SIGUSR2                12
> > +#define SIGPIPE                13
> > +#define SIGALRM                14
> > +#define SIGTERM                15
> > +#define SIGSTKFLT      16
> > +#define SIGCHLD                17
> > +#define SIGCONT                18
> > +#define SIGSTOP                19
> > +#define SIGTSTP                20
> > +#define SIGTTIN                21
> > +#define SIGTTOU                22
> > +#define SIGURG         23
> > +#define SIGXCPU                24
> > +#define SIGXFSZ                25
> > +#define SIGVTALRM      26
> > +#define SIGPROF                27
> > +#define SIGWINCH       28
> > +#define SIGIO          29
> > +#define SIGPOLL                SIGIO
> > +#define SIGPWR         30
> > +#define SIGSYS         31
> > +#define        SIGUNUSED       31
>
> Please try to use the asm-generic version of these definitions instead
> copying them. If you need something different, you can add an #ifdef there,
> and then we can discuss whether the difference makes sense.
>
>
>         Arnd
```
