From patchwork Tue Oct 18 18:50:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 120497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1EB62B70DD for ; Wed, 19 Oct 2011 06:47:10 +1100 (EST) Received: from localhost ([::1]:45154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGF1M-0006W5-Rw for incoming@patchwork.ozlabs.org; Tue, 18 Oct 2011 15:08:16 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGF1B-0005ly-Or for qemu-devel@nongnu.org; Tue, 18 Oct 2011 15:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGElt-0002IX-Ml for qemu-devel@nongnu.org; Tue, 18 Oct 2011 14:52:23 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:53655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGElt-0002CC-F7 for qemu-devel@nongnu.org; Tue, 18 Oct 2011 14:52:17 -0400 Received: by mail-wy0-f173.google.com with SMTP id 15so1034654wyh.4 for ; Tue, 18 Oct 2011 11:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=3g9UmWg+04ZEKvx0kwdUQNr2kVuOSpULrU/5s0lj7XQ=; b=DeKMrYJZ2dnEwEN7UPx6SoIAMlPq6l0HS4T3rN+UrC17OLcQNCrIqOnfiT8idf0BJG XAMqqJ7F1eocJpXgSOWiaJFr76K6UxQSIHOgMubS9S1xEV9kM4On/OeC98kNlRqF2vwa 8NhCXARIxBZCe6WUjoZ1nv8z9l3Vpz8HhuT68= Received: by 10.216.47.11 with SMTP id s11mr653057web.24.1318963936424; Tue, 18 Oct 2011 11:52:16 -0700 (PDT) Received: from localhost.localdomain (c-71-227-161-214.hsd1.wa.comcast.net. [71.227.161.214]) by mx.google.com with ESMTPS id 11sm5169602wby.15.2011.10.18.11.52.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Oct 2011 11:52:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2011 11:50:43 -0700 Message-Id: <1318963843-25100-22-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.6.4 In-Reply-To: <1318963843-25100-1-git-send-email-rth@twiddle.net> References: <1318963843-25100-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: blauwirbel@gmail.com, Riku Voipio Subject: [Qemu-devel] [PATCH 21/21] sparc-linux-user: Enable NPTL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ??? This doesn't work yet. The new thread crashes more or less immediately in the translated code, and then TCG aborts. Perhaps some of that cpu_reset is really required? The problem with it is that it zeros pc/npc, which also sends us off into nevernever land. Perhaps cpu_clone_regs should take both the old and new env, and move the copy/reset/update into cpu-specific code? That would certainly avoid the ifdef there... Anyone see what's going wrong? Not-signed-off-by: Richard Henderson Cc: Riku Voipio --- configure | 3 +++ linux-user/syscall.c | 12 +++++++++++- target-sparc/cpu.h | 30 +++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 283ba81..8df9a6d 100755 --- a/configure +++ b/configure @@ -3313,11 +3313,13 @@ case "$target_arch2" in ;; sparc) target_phys_bits=64 + target_nptl="yes" ;; sparc64) TARGET_BASE_ARCH=sparc target_phys_bits=64 target_long_alignment=8 + target_nptl="yes" ;; sparc32plus) TARGET_ARCH=sparc64 @@ -3325,6 +3327,7 @@ case "$target_arch2" in TARGET_ABI_DIR=sparc echo "TARGET_ABI32=y" >> $config_target_mak target_phys_bits=64 + target_nptl="yes" ;; s390x) target_nptl="yes" diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7735008..dfd7a89 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3961,6 +3961,12 @@ static void *clone_func(void *arg) /* Wait until the parent has finshed initializing the tls state. */ pthread_mutex_lock(&clone_lock); pthread_mutex_unlock(&clone_lock); + +#ifdef TARGET_SPARC + /* Funny calling conventions for Sparc: the new TID is in %o0. */ + env->regwptr[0] = info->tid; +#endif + cpu_loop(env); /* never exits */ return NULL; @@ -4006,8 +4012,12 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp, init_task_state(ts); /* we create a new CPU instance. */ new_env = cpu_copy(env); -#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC) +#if defined(TARGET_I386) || defined(TARGET_PPC) cpu_reset(new_env); +#elif defined(TARGET_SPARC) + /* Funny calling conventions for Sparc: %o1 == 0 for parent, + and == 1 for child. We handle the later in cpu_clone_regs. */ + env->regwptr[1] = 0; #endif /* Init regs that differ from the parent. */ cpu_clone_regs(new_env, newsp); diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 71a890c..2c7d67b 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -675,12 +675,32 @@ static inline int cpu_pil_allowed(CPUState *env1, int pil) #if defined(CONFIG_USER_ONLY) static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) { - if (newsp) + if (newsp) { + if (TARGET_VIRT_ADDR_SPACE_BITS == 32) { + newsp &= 0xffffffff; + } env->regwptr[22] = newsp; - env->regwptr[0] = 0; - /* FIXME: Do we also need to clear CF? */ - /* XXXXX */ - printf ("HELPME: %s:%d\n", __FILE__, __LINE__); + } + + /* Glibc tests for syscall error (carry set) before testing for + parent or child. We must signal success. */ +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) + env->xcc &= ~PSR_CARRY; +#else + env->psr &= ~PSR_CARRY; +#endif + + /* Indicate child. */ + env->regwptr[1] = 1; + + /* Next instruction. */ + env->pc = env->npc; + env->npc = env->npc + 4; +} + +static inline void cpu_set_tls(CPUState *env, target_ulong newtls) +{ + env->gregs[7] = newtls; } #endif