qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: laurent@vivier.eu
Subject: [Qemu-devel] [PATCH v2 0/8] linux-user sparc fixes
Date: Thu,  9 May 2019 20:27:02 -0700	[thread overview]
Message-ID: <20190510032710.23910-1-richard.henderson@linaro.org> (raw)

Version 1 was posted back in July 2018.  Oops.  ;-)

https://lists.gnu.org/archive/html/qemu-devel/2018-07/msg05788.html

--- v1 cover letter

There are at least 4 separate bugs preventing clone from working.

(1) cpu_copy left both cpus sharing the same register window (!)

(2) cpu_clone_regs did not initialize %o1, so the new thread path
    in the guest __clone was always taken, even for the parent
    (old %o1 value was newsp, and so non-zero).

(3) cpu_clone_regs did not advance the pc past the syscall in the
    child, which meant that the child re-executed the syscall
    (and because of (1), with essentially random inputs).

(4) clone did not flush register windows, which would cause the
    parent stack to be clobbered by the child writing out old
    windows in order to allocate a new one.
    
This is enough for Alex's atomic-test to make progress, but not
quite enough for it to actually work.  What I'm seeing now is a
legitimate SEGV for a write to a r-xp memory segment.  I'll need
to examine the testcase further to see why that is happening.

---

I have now traced the remaining problem to cpu_clone_regs putting the
newsp into the frame pointer, not the stack pointer.  In fixing this,
I define a set of WREG_* constants in target/sparc/cpu.h, and then go
on to fix some related problems in linux-user/sparc/signal.c.


r~


Richard Henderson (8):
  linux-user: Disallow setting newsp for fork
  linux-user: Pass the parent env to cpu_clone_regs
  target/sparc: Define an enumeration for accessing env->regwptr
  linux-user/sparc: Use WREG constants in sparc/target_cpu.h
  linux-user/sparc: Use WREG constants in sparc/signal.c
  linux-user/sparc: Fix cpu_clone_regs
  linux-user/sparc: Flush register windows before clone
  scripts/qemu-binfmt-conf: Update for sparc64

 linux-user/aarch64/target_cpu.h    |  3 +-
 linux-user/alpha/target_cpu.h      |  3 +-
 linux-user/arm/target_cpu.h        |  3 +-
 linux-user/cris/target_cpu.h       |  3 +-
 linux-user/hppa/target_cpu.h       |  3 +-
 linux-user/i386/target_cpu.h       |  3 +-
 linux-user/m68k/target_cpu.h       |  3 +-
 linux-user/microblaze/target_cpu.h |  3 +-
 linux-user/mips/target_cpu.h       |  3 +-
 linux-user/nios2/target_cpu.h      |  3 +-
 linux-user/openrisc/target_cpu.h   |  4 +-
 linux-user/ppc/target_cpu.h        |  3 +-
 linux-user/riscv/target_cpu.h      |  3 +-
 linux-user/s390x/target_cpu.h      |  3 +-
 linux-user/sh4/target_cpu.h        |  3 +-
 linux-user/sparc/target_cpu.h      | 41 ++++++++-----
 linux-user/tilegx/target_cpu.h     |  3 +-
 linux-user/xtensa/target_cpu.h     |  3 +-
 target/sparc/cpu.h                 | 33 ++++++++++
 linux-user/sparc/cpu_loop.c        |  3 +
 linux-user/sparc/signal.c          | 96 ++++++++++--------------------
 linux-user/syscall.c               |  9 ++-
 scripts/qemu-binfmt-conf.sh        |  8 ++-
 23 files changed, 141 insertions(+), 101 deletions(-)

-- 
2.17.1



             reply	other threads:[~2019-05-10  3:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10  3:27 Richard Henderson [this message]
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 1/8] linux-user: Disallow setting newsp for fork Richard Henderson
2019-05-15  0:31   ` Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 2/8] linux-user: Pass the parent env to cpu_clone_regs Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 3/8] target/sparc: Define an enumeration for accessing env->regwptr Richard Henderson
2019-05-15  5:44   ` Philippe Mathieu-Daudé
2019-05-20  3:09     ` Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 4/8] linux-user/sparc: Use WREG constants in sparc/target_cpu.h Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 5/8] linux-user/sparc: Use WREG constants in sparc/signal.c Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 6/8] linux-user/sparc: Fix cpu_clone_regs Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 7/8] linux-user/sparc: Flush register windows before clone Richard Henderson
2019-05-10  3:27 ` [Qemu-devel] [PATCH v2 8/8] scripts/qemu-binfmt-conf: Update for sparc64 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=20190510032710.23910-1-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=laurent@vivier.eu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).