All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Laurent Vivier" <laurent@vivier.eu>
Subject: Re: [PATCH v2 10/23] linux-user/i386: Implement setup_sigtramp
Date: Tue, 29 Jun 2021 15:40:40 +0100	[thread overview]
Message-ID: <CAFEAcA9SZmnxcN48_JEcfkSyUDhngcW0Z34DquMpjAaHyPm-cA@mail.gmail.com> (raw)
In-Reply-To: <20210618192951.125651-11-richard.henderson@linaro.org>

On Fri, 18 Jun 2021 at 20:38, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Create and record the two signal trampolines.
> Use them when the guest does not use SA_RESTORER.
> Note that x86_64 does not use this code.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/i386/target_signal.h   |  2 ++
>  linux-user/x86_64/target_signal.h |  3 +++
>  linux-user/i386/signal.c          | 42 ++++++++++++++++++-------------
>  3 files changed, 29 insertions(+), 18 deletions(-)
>
> diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signal.h
> index 50361af874..64d09f2e75 100644
> --- a/linux-user/i386/target_signal.h
> +++ b/linux-user/i386/target_signal.h
> @@ -22,4 +22,6 @@ typedef struct target_sigaltstack {
>  #include "../generic/signal.h"
>
>  #define TARGET_ARCH_HAS_SETUP_FRAME
> +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
> +
>  #endif /* I386_TARGET_SIGNAL_H */
> diff --git a/linux-user/x86_64/target_signal.h b/linux-user/x86_64/target_signal.h
> index 4ea74f20dd..4673c5a886 100644
> --- a/linux-user/x86_64/target_signal.h
> +++ b/linux-user/x86_64/target_signal.h
> @@ -21,4 +21,7 @@ typedef struct target_sigaltstack {
>
>  #include "../generic/signal.h"
>
> +/* For x86_64, use of SA_RESTORER is mandatory. */
> +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0
> +
>  #endif /* X86_64_TARGET_SIGNAL_H */
> diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c
> index 8701774e37..a83ecba54f 100644
> --- a/linux-user/i386/signal.c
> +++ b/linux-user/i386/signal.c
> @@ -337,16 +337,7 @@ void setup_frame(int sig, struct target_sigaction *ka,
>      if (ka->sa_flags & TARGET_SA_RESTORER) {
>          __put_user(ka->sa_restorer, &frame->pretcode);
>      } else {
> -        uint16_t val16;
> -        abi_ulong retcode_addr;
> -        retcode_addr = frame_addr + offsetof(struct sigframe, retcode);
> -        __put_user(retcode_addr, &frame->pretcode);
> -        /* This is popl %eax ; movl $,%eax ; int $0x80 */
> -        val16 = 0xb858;
> -        __put_user(val16, (uint16_t *)(frame->retcode+0));
> -        __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2));
> -        val16 = 0x80cd;
> -        __put_user(val16, (uint16_t *)(frame->retcode+6));
> +        __put_user(default_sigreturn, &frame->pretcode);
>

In the kernel in arch/x86/kernel/signal.c there is a comment:

        /*
         * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
         *
         * WE DO NOT USE IT ANY MORE! It's only left here for historical
         * reasons and because gdb uses it as a signature to notice
         * signal handler stack frames.
         */

which suggests that we also should continue to fill in the
retcode bytes in the signal frame for gdb's benefit even though
we don't actually execute them any more.

thanks
-- PMM


  reply	other threads:[~2021-06-29 14:46 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18 19:29 [PATCH v2 00/23] linux-user: Move signal trampolines to new page Richard Henderson
2021-06-18 19:29 ` [PATCH v2 01/23] linux-user: Add infrastructure for a signal trampoline page Richard Henderson
2021-06-19  9:33   ` Philippe Mathieu-Daudé
2021-06-29 13:30   ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Richard Henderson
2021-06-29 13:36   ` Peter Maydell
2021-07-01 19:27     ` Richard Henderson
2021-06-18 19:29 ` [PATCH v2 03/23] linux-user/arm: Split out v2_frame Richard Henderson
2021-06-29 13:53   ` Peter Maydell
2021-06-29 14:30     ` Richard Henderson
2021-06-18 19:29 ` [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Richard Henderson
2021-06-29 13:54   ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Richard Henderson
2021-06-29 14:09   ` Peter Maydell
2021-06-29 18:32     ` Richard Henderson
2021-06-18 19:29 ` [PATCH v2 06/23] linux-user/alpha: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 07/23] linux-user/cris: " Richard Henderson
2021-06-19  9:33   ` Philippe Mathieu-Daudé
2021-06-19 12:55     ` Richard Henderson
2021-06-19 14:17       ` Philippe Mathieu-Daudé
2021-06-18 19:29 ` [PATCH v2 08/23] linux-user/hexagon: " Richard Henderson
2021-06-19  9:31   ` Philippe Mathieu-Daudé
2021-06-18 19:29 ` [PATCH v2 09/23] linux-user/hppa: Document non-use of setup_sigtramp Richard Henderson
2021-06-18 19:29 ` [PATCH v2 10/23] linux-user/i386: Implement setup_sigtramp Richard Henderson
2021-06-29 14:40   ` Peter Maydell [this message]
2021-06-29 18:30     ` Richard Henderson
2021-06-18 19:29 ` [PATCH v2 11/23] linux-user/m68k: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 12/23] linux-user/microblaze: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 13/23] linux-user/mips: Tidy install_sigtramp Richard Henderson
2021-06-19  9:29   ` Philippe Mathieu-Daudé
2021-06-18 19:29 ` [PATCH v2 14/23] linux-user/mips: Implement setup_sigtramp Richard Henderson
2021-06-18 19:29 ` [PATCH v2 15/23] linux-user/nios2: Document non-use of setup_sigtramp Richard Henderson
2021-06-19  9:35   ` Philippe Mathieu-Daudé
2021-06-18 19:29 ` [PATCH v2 16/23] linux-user/openrisc: Implement setup_sigtramp Richard Henderson
2021-06-18 19:29 ` [PATCH v2 17/23] linux-user/ppc: " Richard Henderson
2021-06-29 14:52   ` Peter Maydell
2021-06-18 19:29 ` [PATCH v2 18/23] linux-user/riscv: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 19/23] linux-user/s390x: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 20/23] linux-user/sh4: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 21/23] linux-user/sparc: " Richard Henderson
2021-07-02  9:05   ` Philippe Mathieu-Daudé
2021-06-18 19:29 ` [PATCH v2 22/23] linux-user/xtensa: " Richard Henderson
2021-06-18 19:29 ` [PATCH v2 23/23] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFEAcA9SZmnxcN48_JEcfkSyUDhngcW0Z34DquMpjAaHyPm-cA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.