All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, laurent@vivier.eu, imp@bsdimp.com
Subject: [RFC PATCH 0/7] linux-user: Streamline handling of SIGSEGV/SIGBUS
Date: Mon, 13 Sep 2021 15:05:45 -0700	[thread overview]
Message-ID: <20210913220552.604064-1-richard.henderson@linaro.org> (raw)

Our current setup is:

  host_signal_handler
  cpu_signal_handler
     handle_cpu_signal
        cc->tcg_ops->tlb_fill
           raise_exception
  cpu_loop
     queue_signal

and in the process lose information from the host siginfo_t,
which we (mostly) do not recreate properly.  Moreover, the
intermediate cpu_signal_handler handles the host-specific
portions of extracting pc + is_write from the ucontext_t.

I'm replacing this with

  host_signal_handler
    host_signal_pc
    host_sigsegv_write
    adjust_signal_pc
    handle_sigsegv_accerr_write
    queue_signal
    raise_exception
  cpu_loop

All of the really tcg-specific portions are still in user-exec.c,
and all of the really host-specific portions are now ditributed
across linux-user/host/<arch>/.  Importantly, SEGV_MAPERR and
SEGV_ACCERR are now passed through from the host kernel -- or at
least there's a single place from which to manage it [1].

Note that I've dropped all of the BSD (and Solaris!) code from
user-exec.c.  I thought about moving it similar to linux-user,
but I've caught Warner in the middle of his re-org and the whole
of bsd-user/signal.c is currently empty.  I think it will be
easier to create the new interfaces from scratch when ready.

Still to-do:
  * Make cc->tcg_ops->tlb_fill sysemu only (once again).
  * Drop all of the code from cpu_loop that interfaced with tlb_fill.


r~


[1] I've just this minute realized that the reserved_va mapping that we
do for emulating 32-bit guests will incorrectly give SEGV_ACCERR for pages
that are not mapped by the guest, and should result in SEGV_MAPERR.


Richard Henderson (7):
  include/exec: Move cpu_signal_handler declaration
  accel/tcg: Split out adjust_signal_pc
  accel/tcg: Split out handle_sigsegv_accerr_write
  accel/tcg: Move clear_helper_retaddr to cpu loop
  accel/tcg: Fold cpu_exit_tb_from_sighandler into caller
  linux-user: Handle SIGSEGV/SIGBUS in host_to_target_siginfo_noswap
  linux-user: Reorg cpu_signal_handler

 include/exec/exec-all.h               |  21 +
 linux-user/host/aarch64/host-signal.h |  73 +++
 linux-user/host/alpha/host-signal.h   |  41 ++
 linux-user/host/arm/host-signal.h     |  30 +
 linux-user/host/i386/host-signal.h    |  24 +
 linux-user/host/mips/host-signal.h    |  61 ++
 linux-user/host/ppc/host-signal.h     |  24 +
 linux-user/host/ppc64/host-signal.h   |   1 +
 linux-user/host/riscv32/host-signal.h |  57 ++
 linux-user/host/riscv64/host-signal.h |   1 +
 linux-user/host/s390/host-signal.h    |  92 +++
 linux-user/host/s390x/host-signal.h   |   1 +
 linux-user/host/sparc/host-signal.h   |  53 ++
 linux-user/host/sparc64/host-signal.h |   1 +
 linux-user/host/x86_64/host-signal.h  |  24 +
 target/alpha/cpu.h                    |   6 -
 target/arm/cpu.h                      |   7 -
 target/avr/cpu.h                      |   2 -
 target/cris/cpu.h                     |   8 -
 target/hexagon/cpu.h                  |   3 -
 target/hppa/cpu.h                     |   3 -
 target/i386/cpu.h                     |   7 -
 target/m68k/cpu.h                     |   8 -
 target/microblaze/cpu.h               |   7 -
 target/mips/cpu.h                     |   3 -
 target/mips/internal.h                |   2 -
 target/nios2/cpu.h                    |   2 -
 target/openrisc/cpu.h                 |   2 -
 target/ppc/cpu.h                      |   7 -
 target/riscv/cpu.h                    |   2 -
 target/rx/cpu.h                       |   4 -
 target/s390x/cpu.h                    |   7 -
 target/sh4/cpu.h                      |   3 -
 target/sparc/cpu.h                    |   2 -
 target/tricore/cpu.h                  |   2 -
 target/xtensa/cpu.h                   |   2 -
 accel/tcg/cpu-exec.c                  |   3 +-
 accel/tcg/user-exec.c                 | 807 ++------------------------
 linux-user/signal.c                   | 102 ++--
 39 files changed, 635 insertions(+), 870 deletions(-)
 create mode 100644 linux-user/host/aarch64/host-signal.h
 create mode 100644 linux-user/host/alpha/host-signal.h
 create mode 100644 linux-user/host/arm/host-signal.h
 create mode 100644 linux-user/host/i386/host-signal.h
 create mode 100644 linux-user/host/mips/host-signal.h
 create mode 100644 linux-user/host/ppc/host-signal.h
 create mode 100644 linux-user/host/ppc64/host-signal.h
 create mode 100644 linux-user/host/riscv32/host-signal.h
 create mode 100644 linux-user/host/riscv64/host-signal.h
 create mode 100644 linux-user/host/s390/host-signal.h
 create mode 100644 linux-user/host/s390x/host-signal.h
 create mode 100644 linux-user/host/sparc/host-signal.h
 create mode 100644 linux-user/host/sparc64/host-signal.h
 create mode 100644 linux-user/host/x86_64/host-signal.h

-- 
2.25.1



             reply	other threads:[~2021-09-13 22:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 22:05 Richard Henderson [this message]
2021-09-13 22:05 ` [RFC PATCH 1/7] include/exec: Move cpu_signal_handler declaration Richard Henderson
2021-09-14  6:03   ` Philippe Mathieu-Daudé
2021-09-15 16:09   ` Warner Losh
2021-09-13 22:05 ` [RFC PATCH 2/7] accel/tcg: Split out adjust_signal_pc Richard Henderson
2021-09-14  6:07   ` Philippe Mathieu-Daudé
2021-09-13 22:05 ` [RFC PATCH 3/7] accel/tcg: Split out handle_sigsegv_accerr_write Richard Henderson
2021-09-14  6:58   ` Philippe Mathieu-Daudé
2021-09-13 22:05 ` [RFC PATCH 4/7] accel/tcg: Move clear_helper_retaddr to cpu loop Richard Henderson
2021-09-13 22:05 ` [RFC PATCH 5/7] accel/tcg: Fold cpu_exit_tb_from_sighandler into caller Richard Henderson
2021-09-13 22:05 ` [RFC PATCH 6/7] linux-user: Handle SIGSEGV/SIGBUS in host_to_target_siginfo_noswap Richard Henderson
2021-09-15 16:23   ` Warner Losh
2021-09-15 16:27     ` Richard Henderson
2021-09-13 22:05 ` [RFC PATCH 7/7] linux-user: Reorg cpu_signal_handler Richard Henderson
2021-09-15 16:43   ` Warner Losh
2021-09-15 16:52     ` Richard Henderson
2021-09-16  8:51   ` Philippe Mathieu-Daudé
2021-09-14  1:18 ` [RFC PATCH 0/7] linux-user: Streamline handling of SIGSEGV/SIGBUS 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=20210913220552.604064-1-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=imp@bsdimp.com \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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.