From patchwork Thu Jun 7 22:24:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6FA46B6FA4 for ; Fri, 8 Jun 2012 09:11:33 +1000 (EST) Received: from localhost ([::1]:59539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scl91-0003Wa-Qs for incoming@patchwork.ozlabs.org; Thu, 07 Jun 2012 18:25:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scl8G-0001Im-Vk for qemu-devel@nongnu.org; Thu, 07 Jun 2012 18:24:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Scl8E-0006EU-Op for qemu-devel@nongnu.org; Thu, 07 Jun 2012 18:24:44 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:48169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scl8E-0006Db-FS for qemu-devel@nongnu.org; Thu, 07 Jun 2012 18:24:42 -0400 Received: by pbbro12 with SMTP id ro12so1843661pbb.4 for ; Thu, 07 Jun 2012 15:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=rGss5FxfftS50d279VrzqDqzHFOxPy2MWc6Bl5EDdg8=; b=LmiFoUotnNHa2WNNqC+k80f5cPDh1F9Yc6NyGEeeYVjWgk1hSw5ZePGyHYEd9lwP4N 72AeEfGEA/5yy6kBH8ce1S6otufcCci7Io+2L6afh81IiE4CKU4qAF9Una9CN2HntlQu Wi0BOZoFe+F+e43c3dJ0b3MMXQ4kcMZdocJ1CWl2KOQhli1an0T5X51tsQY2IwD9lebS a/wG/wBdJ1tpPc33BGXAKk+UnKt4F7T92Su9ridNd36O53wtCKCMIooFzbMNdPBj0/9c nHZcjn0LHupN7fxaFFyOykd4aqleumsQtJSiI+DyfTX0j7W6a9YUSSswY73dbf0ZXElS wsCw== Received: by 10.68.231.10 with SMTP id tc10mr12999330pbc.107.1339107880230; Thu, 07 Jun 2012 15:24:40 -0700 (PDT) Received: from anchor.twiddle.home ([173.160.232.49]) by mx.google.com with ESMTPS id u5sm5454817pbu.76.2012.06.07.15.24.39 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Jun 2012 15:24:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Jun 2012 15:24:25 -0700 Message-Id: <1339107871-4487-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1339107871-4487-1-git-send-email-rth@twiddle.net> References: <1339107871-4487-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Riku Voipio Subject: [Qemu-devel] [PATCH 3/9] alpha-linux-user: Handle TARGET_SSI_IEEE_RAISE_EXCEPTION properly 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 We weren't aggregating the exceptions, nor raising signals properly. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 61 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 51 insertions(+), 10 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 539af3f..1cbbfbf 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7699,13 +7699,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_SSI_IEEE_FP_CONTROL: - case TARGET_SSI_IEEE_RAISE_EXCEPTION: { uint64_t swcr, fpcr, orig_fpcr; - if (get_user_u64 (swcr, arg2)) + if (get_user_u64 (swcr, arg2)) { goto efault; - orig_fpcr = cpu_alpha_load_fpcr (cpu_env); + } + orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr & FPCR_DYN_MASK; /* Copied from linux ieee_swcr_to_fpcr. */ @@ -7719,16 +7719,57 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; - cpu_alpha_store_fpcr (cpu_env, fpcr); + cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; + } + break; + + case TARGET_SSI_IEEE_RAISE_EXCEPTION: + { + uint64_t exc, fpcr, orig_fpcr; + int si_code; + + if (get_user_u64(exc, arg2)) { + goto efault; + } - if (arg1 == TARGET_SSI_IEEE_RAISE_EXCEPTION) { - /* Old exceptions are not signaled. */ - fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); + orig_fpcr = cpu_alpha_load_fpcr(cpu_env); - /* If any exceptions set by this call, and are unmasked, - send a signal. */ - /* ??? FIXME */ + /* We only add to the exception status here. */ + fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); + + cpu_alpha_store_fpcr(cpu_env, fpcr); + ret = 0; + + /* Old exceptions are not signaled. */ + fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); + + /* If any exceptions set by this call, + and are unmasked, send a signal. */ + si_code = 0; + if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) { + si_code = TARGET_FPE_FLTRES; + } + if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) { + si_code = TARGET_FPE_FLTUND; + } + if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) { + si_code = TARGET_FPE_FLTOVF; + } + if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) { + si_code = TARGET_FPE_FLTDIV; + } + if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) { + si_code = TARGET_FPE_FLTINV; + } + if (si_code != 0) { + target_siginfo_t info; + info.si_signo = SIGFPE; + info.si_errno = 0; + info.si_code = si_code; + info._sifields._sigfault._addr + = ((CPUArchState *)cpu_env)->pc; + queue_signal((CPUArchState *)cpu_env, info.si_signo, &info); } } break;