From patchwork Wed Jul 25 22:10:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 173305 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 D71562C0078 for ; Thu, 26 Jul 2012 09:04:11 +1000 (EST) Received: from localhost ([::1]:52339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su9np-0001DF-LL for incoming@patchwork.ozlabs.org; Wed, 25 Jul 2012 18:11:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su9n9-0007dm-8p for qemu-devel@nongnu.org; Wed, 25 Jul 2012 18:10:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su9n8-00011k-1k for qemu-devel@nongnu.org; Wed, 25 Jul 2012 18:10:51 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:53016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su9n7-00011f-Tl for qemu-devel@nongnu.org; Wed, 25 Jul 2012 18:10:49 -0400 Received: by yhpp34 with SMTP id p34so1266256yhp.4 for ; Wed, 25 Jul 2012 15:10:49 -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=Vj9FOJaf3UAMJymnRPGoysxDN3qTM6mQdYz40c2IEFi0MSz8AKO0JImDNpnapAMQmU FRbX0ZroUh0N0SMlc13fUqD5g+TFVQTEbpyijhK8R+itbZJWlV+qGuRR12wu0vr72TKl 8VzwskqoHkhV3b1roMFAkeLGnqI1jHht0OrX9Zeu9l419Dd/SMVJHZMGWZL6p/Ve5T9V OklIp6yYPBDTrpgy3WTjbezmlzm+mfY+EpjYbhJin3VDpCVd5a9oBy72c6Ps0b/202df fvlLftrlizIxrbeX64I1T9kE00Me1sh7leyts6QHTh/qEIemoB14gyOP2fbOOw+6OnLR k9Hg== Received: by 10.66.87.138 with SMTP id ay10mr15751712pab.38.1343254249128; Wed, 25 Jul 2012 15:10:49 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id oo6sm15136761pbc.22.2012.07.25.15.10.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jul 2012 15:10:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Jul 2012 15:10:31 -0700 Message-Id: <1343254238-4727-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1343254238-4727-1-git-send-email-rth@twiddle.net> References: <1343254238-4727-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.213.45 Cc: riku.voipio@iki.fi Subject: [Qemu-devel] [PATCH 03/10] 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 Reviewed-by: Peter Maydell --- 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;