From patchwork Fri May 10 03:27:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163815 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1821269ilr; Thu, 9 May 2019 20:30:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4zlhd4j9qn7hs38evvC+sjbwnPD8zKkHuEE00BlT40yecmoHupKMVpGZ9pzd6jx/UZAP5 X-Received: by 2002:a5d:52ce:: with SMTP id r14mr5963333wrv.224.1557459012831; Thu, 09 May 2019 20:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557459012; cv=none; d=google.com; s=arc-20160816; b=Ip6n3qLNar39C3VHF48SYThNldoQw/eFd7p53XTZsw40rZueTuseSg+pnY2kfq7HRG 7qNBQnZW6UfXyrEEPp1l/V469+Fn4cfqCf8esGMERYl2XA8g6Ahms+A8aJ+dgfd8V+Ci Oe9h6mPLZiSHWYIsb4YskSfVqOeAeNQn1aDTx5duINsw+cm9eCLjNfoRZek92ojHjQ3D 59Mlq5CKb3om/W7Hp12NTlyjBZut9ANoGwCmeomre8HS8gVBHZznSo00NvifnNt3kCsq ofdVxKPzskfT7rX8Nk8CWtjczs7c2Pm/BKEOLGl6Y2Is3Bn4D5zLt7ydA74A1AsIfDTA UOXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature; bh=kYPvR/+3oXoM1cgriFFufz2gVs7DQlnW5GngOT7E9H8=; b=ojh0oji1tKV5jXz5bTfG51i7sCrDcyv+HIWochyq+ED13NdrRSst/So70EK0269epJ 4Hztbo+tPVqneOER7fv1wAkN1S9NLQW5kS7r+DsIEjpbIp9KZ+fDsUhd9Id+RiI/ydIa pGpd5FHdokp10/kx3zb5UTXV5C5QkZleHhS7SMqGV/rG6i5xPZ9Ywzeuo7q24LrQqW/R Q8NSVNgKcth6cgX9UKZV3qSQlUQFMPP+I1OfMiMOqL/Nq5pPD0k2shdCTKIKCTDClfF9 iK2XcsSmbRj8ouHd1QAHPbSfMPYdtWF4PPV1mprfXyLbtmumUkJxcL/vPxfiuhou/qWt nLzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yYL35neT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 91si3548527wrm.23.2019.05.09.20.30.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 20:30:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yYL35neT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:36157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOwEd-0005Rh-Oq for patch@linaro.org; Thu, 09 May 2019 23:30:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOwBo-0002w0-Bc for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOwBn-0001M6-3W for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:16 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOwBm-0001KP-Ta for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:15 -0400 Received: by mail-pf1-x443.google.com with SMTP id 13so2408375pfw.9 for ; Thu, 09 May 2019 20:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kYPvR/+3oXoM1cgriFFufz2gVs7DQlnW5GngOT7E9H8=; b=yYL35neTghlReS1E0H4blVXqlra6l8YuWplq0b0FCOswSQnBFlJjkScr+IGCK2mmRr hoAa62HQ8ckBe0VY8wJ+Gw9XD1c0g7ikv39uq54pvVqPWhPDCMMWiSvM2sq5EJCqVSba /dlaoPJQAKb2EfyEC7/RL3F/9Sp7GUvXhQ9atTyMafJQVYnn+++FZN03Tn6CTH0qdLz2 r/G9KM8zQRUaxQjx0gH1pl0HJjCdNauFwJibFbtSjGsY1cJfRmxUKuSXKhJA7NoYPMFA F1CAuRhwiT5HRyW5CYagJC2JtPQZ/ZN2s3dntg8X5Axlb33B+UIGt4S4Ddaj6m8Gm5VT otwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kYPvR/+3oXoM1cgriFFufz2gVs7DQlnW5GngOT7E9H8=; b=C0369nkNsjRhEBmXSPD6SDwtwUIMMbybayaG/Yz7lSZ+XApTymn3fqWGlaMr4h9818 yTtxhJDEMybkcrvuSGyCre8vDAXN5A2uVZPT3F/FexFKXIedjifnkixAWjmsb+rFj5Yg iR8PH8GRelEskCaZ4v5qm70eLtpYZgt61oGNm+l/eHLCtJeqgVdrlUcKc5SgrOl/W3gm /gKmHllWf/bhiUYePiCdkEB08N0l3Q+FVE3L5X/Yig8hVyz+8Erg7EE26jZlZH7A8q5j 1MFfKtNlv9gBka8vEV4ZcUHxcBAm+o9vSCE/fksgb10a4qjeZ+31PQLO3LCuKaNenzSf YPWw== X-Gm-Message-State: APjAAAXmyBKWlYi6LuqWxY0KfkrtnhZYXADT6v5pobVY5qoFhFiRTbHA h4xguUOAqvH4j+dxpf1kJEFGxaw5t6s= X-Received: by 2002:a63:a84c:: with SMTP id i12mr10862267pgp.115.1557458833034; Thu, 09 May 2019 20:27:13 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id t26sm6259695pgk.62.2019.05.09.20.27.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 20:27:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 20:27:02 -0700 Message-Id: <20190510032710.23910-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v2 0/8] linux-user sparc fixes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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