From patchwork Sat Jun 2 19:29:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 162444 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 22FF5B6FA5 for ; Sun, 3 Jun 2012 05:30:33 +1000 (EST) Received: from localhost ([::1]:46856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sau1u-0007Fe-Rx for incoming@patchwork.ozlabs.org; Sat, 02 Jun 2012 15:30:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sau1Z-00078P-IW for qemu-devel@nongnu.org; Sat, 02 Jun 2012 15:30:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sau1X-00016Y-Ig for qemu-devel@nongnu.org; Sat, 02 Jun 2012 15:30:09 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:42473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sau1X-00012e-AF for qemu-devel@nongnu.org; Sat, 02 Jun 2012 15:30:07 -0400 Received: by dadv2 with SMTP id v2so4554060dad.4 for ; Sat, 02 Jun 2012 12:30:05 -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=ivjW6tQW4WdboG7/opH3kq9GCfiK+5zxCg4edLn+Af0=; b=SzIG/7xcuPg50lKdD5nYTq9WbtDGXaaUBaAKTs5x0XMbLvWkZ3EMygTq3K+tGjyrL4 NdqrQZ98Z2S0shtHNRcjTW1OOw8v0aRZN8vKAPxD2dcElourOiM1/2+HxNO0Vs6aEXlD wWTc8mSjoH6K8tYP35sXHvU4bUak9EPdPJCSSI1/8R2GGvF5shX1yk5VDa4U9R+rmwFS S1xt5ijZVG7AIfgcDW3tllikjfsmT07jKqG3WdSn2JiNC2DOqbLAP73Ch837/mJg/nE6 NSu7MQtxwtbnrgVJoPoC7PnnQtIYJiocb7ABjpbv3lwUR12RS6WmDbJXuP3mU39/XIEl X/Vg== Received: by 10.68.238.232 with SMTP id vn8mr22907580pbc.78.1338665405280; Sat, 02 Jun 2012 12:30:05 -0700 (PDT) Received: from anchor.twiddle.home ([173.160.232.49]) by mx.google.com with ESMTPS id z2sm7176147pbv.34.2012.06.02.12.30.04 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 02 Jun 2012 12:30:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 2 Jun 2012 12:29:54 -0700 Message-Id: <1338665397-20917-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1338665397-20917-1-git-send-email-rth@twiddle.net> References: <1338665397-20917-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.210.45 Cc: Riku Voipio Subject: [Qemu-devel] [PATCH 3/6] 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 20d2a74..d35ed2c 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;