On Thu, Jan 13, 2022 at 10:45 AM Peter Maydell <peter.maydell@linaro.org> wrote:
On Sun, 9 Jan 2022 at 16:29, Warner Losh <imp@bsdimp.com> wrote:
>
> Implement host_to_target_signal and target_to_host_signal.
>
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Kyle Evans <kevans@freebsd.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>  bsd-user/qemu.h   |  2 ++
>  bsd-user/signal.c | 11 +++++++++++
>  2 files changed, 13 insertions(+)
>
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 1b3b974afe9..334f8b1d715 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -210,6 +210,8 @@ long do_sigreturn(CPUArchState *env);
>  long do_rt_sigreturn(CPUArchState *env);
>  void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
>  abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
> +int target_to_host_signal(int sig);
> +int host_to_target_signal(int sig);
>
>  /* mmap.c */
>  int target_mprotect(abi_ulong start, abi_ulong len, int prot);
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index 844dfa19095..7ea86149981 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -2,6 +2,7 @@
>   *  Emulation of BSD signals
>   *
>   *  Copyright (c) 2003 - 2008 Fabrice Bellard
> + *  Copyright (c) 2013 Stacey Son
>   *
>   *  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
> @@ -27,6 +28,16 @@
>   * fork.
>   */
>
> +int host_to_target_signal(int sig)
> +{
> +    return sig;
> +}
> +
> +int target_to_host_signal(int sig)
> +{
> +    return sig;
> +}
> +

This could use a comment:

/*
 * For the BSDs signal numbers are always the same regardless of
 * CPU architecture, so (unlike Linux) these functions are just
 * the identity mapping.
 */

(assuming that is correct, of course!)

It's true enough. Even though there's code to run FooBSD on BarBSD,
that code doesn't work (at all really) today. It would take some doing to
get that working, so I've added a comment that the encoding might not
be the same in that case, but otherwise is the same.

This is issue is one I'm deferring doing anything on until I can get things
upstreamed... It's a bit of a mess if you aren't on FreeBSD, but neither the
NetBSD nor OpenBSD communities are using bsd-user because it's so
broken and incomplete in implementing their ABIs.
 
Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Thanks!

Warner