From patchwork Thu Feb 2 00:52:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 649647 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp609717pva; Wed, 1 Feb 2023 16:54:21 -0800 (PST) X-Google-Smtp-Source: AK7set/jh5DoYAImz7q8PJM6+XliZl0eqGEWiCexwH18zX2M6R3pwuCKkAb6RdWES+O+ojR4V3uk X-Received: by 2002:a05:622a:14e:b0:3b8:694e:4b5b with SMTP id v14-20020a05622a014e00b003b8694e4b5bmr8103756qtw.1.1675299260893; Wed, 01 Feb 2023 16:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675299260; cv=none; d=google.com; s=arc-20160816; b=FPnMOhj2mB1EpxBmcJn20i+BzbHQY6lGWId5Xh1KIjNeSUTMnS2URhu0Kc2Gb+Yq4g 6LDS+afvcBD0EWnA+OXdzUHa4tkxoTWWLkEexzykikcg8dz4UJzqw0hJenu1HR8Gi3FW xRkwlcCW53f5dVtcB3iFZV3gBahMC7Ao3ZNafSgT/G0tUoVXCoZFCw7TnGUXlOF2DgTD /gdrsodIIZwVcBxn3nRaHnC/IM/lkdg4j3ziy6nWpVYCJLfQ5KaQevpqmNfFBJTwmkcV AEOxqiJHRICVHw6psndn/WGeZWlirFkVENLa6QUEMQn2F9pIm2rtLMg8r07xs1IiGYQk PnVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=99mKRPmhuKoadjBj2q33vILsr06N7+B7c/sSXSWRdhI=; b=MLkm2JsCQDnpBLXkbdOX6URKrYwA0g+nQrTYXY9tzWrIEH//TVC7M7eqG4H5TFlu8I 9F96l6GFz6+T5oJ8QN2Vnk+CRp0uPrhliT0fh+mqK8dK5oCcYC7BRbcUYiBRqUyAbGoJ tyusGkzBmIRIVs15uONNvJDVMHbCtmRyf/b6ZpjWEdt0pz/M8YQ7aTWHpCt27+iHGinu lqT/6Bzilo9gBSKr5VAXjBd6yOmhjIcHXqum25yhyXuSku/bl9zCcuh/TzUzYfDYApE0 i4OZcJ81CcaG95MN+I1KP+4pG9TTvj3MI5QTudgJgzzMriNPqU5vifIfyoToPWZpw0VP grcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HY/n1Ql+"; 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=pass (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 oo22-20020a05620a531600b00720fdb50988si5249628qkn.746.2023.02.01.16.54.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2023 16:54:20 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b="HY/n1Ql+"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNNq7-0006I4-4G; Wed, 01 Feb 2023 19:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNNq5-0006DC-Km for qemu-devel@nongnu.org; Wed, 01 Feb 2023 19:52:33 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNNq4-0000Rw-2p for qemu-devel@nongnu.org; Wed, 01 Feb 2023 19:52:33 -0500 Received: by mail-pj1-x1029.google.com with SMTP id c10-20020a17090a1d0a00b0022e63a94799so4056324pjd.2 for ; Wed, 01 Feb 2023 16:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=99mKRPmhuKoadjBj2q33vILsr06N7+B7c/sSXSWRdhI=; b=HY/n1Ql+PQ8SLcDNHlfymT7uyflmPdTfAGyScmHtSw3qJJ7acvSgFVg2gf8Efigz1T txyzOd8pTBFqH+Wx+yKjWY6/1gBKMBMvsRn8b066RPYInL/GYd/Ah8KtagPGmMgz8SSo q4GDLEU2m2PumgpIPWl9SaUIwvz+1M+khEVq8QmSl15SLmPww3a7wzZbLUV3s2UEnTzU cBbdf5IsURiVnNNux6ODmujduW7AvlklVUXomBuo0xQhB9YdcsiHyOmxNveRw5FdFbgi QZnnGq3FdeVkyQScbaUHgFxsP6UHXzuOW7RYFAPr8Do0zdJipZ4txaL3SYNk1nKGEAb2 PYgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=99mKRPmhuKoadjBj2q33vILsr06N7+B7c/sSXSWRdhI=; b=iOOW5miHY4Hc33jZjJh28+ojkGpoY04LWZ3n2xXcHeEirfK/Kw7beguGHjqT/5s7aX rmJ1U6Phlufy3x0DJyyPDs4ZEqoKlUAYZHOL415ZjVOz3Q/5BC86RDP8v/Kc+iuVHHik PGJRMFTDLiYMbvtrQ/OBXvS5pyBkgyUMmRP4MB+alVT8rXqYcofz8k3rB8g+E+K2KDft xdqVmDnixYjzR9UHQZTPIpcu5i1csA6qvywtEGJGJLEv050Qsx0dz2jr2d7Z2OTQdC/1 e1FAzE6w82yuzN2t6QC+ttT0kd8VQAgWRWu09dbp+AlqCTuvz8D+//NfIIVPwrpkWe1l hqOQ== X-Gm-Message-State: AO0yUKUPIjDbeAXXGYq/GpA6GCvHLyvUxqAd2CMnXzGMx0c/WdMIxe2s O5lmTmXhaY5u/uUH1EHGeUzrt25hhWs/uY3b X-Received: by 2002:a17:902:db0a:b0:196:11b1:101d with SMTP id m10-20020a170902db0a00b0019611b1101dmr6291152plx.28.1675299150748; Wed, 01 Feb 2023 16:52:30 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id z3-20020a1709028f8300b00192cf87ed25sm12391334plo.35.2023.02.01.16.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 16:52:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, laurent@vivier.eu, iii@linux.ibm.com Subject: [PATCH 13/14] linux-user/sparc: Handle floating-point exceptions Date: Wed, 1 Feb 2023 14:52:03 -1000 Message-Id: <20230202005204.2055899-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202005204.2055899-1-richard.henderson@linaro.org> References: <20230202005204.2055899-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Raise SIGFPE for ieee exceptions. The other types, such as FSR_FTT_UNIMPFPOP, should not appear, because we enable normal emulation of missing insns at the start of sparc_cpu_realizefn(). Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 3 +-- linux-user/sparc/cpu_loop.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index e478c5eb16..ae8de606d5 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -197,8 +197,7 @@ enum { #define FSR_FTT2 (1ULL << 16) #define FSR_FTT1 (1ULL << 15) #define FSR_FTT0 (1ULL << 14) -//gcc warns about constant overflow for ~FSR_FTT_MASK -//#define FSR_FTT_MASK (FSR_FTT2 | FSR_FTT1 | FSR_FTT0) +#define FSR_FTT_MASK (FSR_FTT2 | FSR_FTT1 | FSR_FTT0) #ifdef TARGET_SPARC64 #define FSR_FTT_NMASK 0xfffffffffffe3fffULL #define FSR_FTT_CEXC_NMASK 0xfffffffffffe3fe0ULL diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7ba543983a..18109f545d 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -301,6 +301,28 @@ void cpu_loop (CPUSPARCState *env) restore_window(env); break; + case TT_FP_EXCP: + { + int code = TARGET_FPE_FLTUNK; + target_ulong fsr = env->fsr; + + if ((fsr & FSR_FTT_MASK) == FSR_FTT_IEEE_EXCP) { + if (fsr & FSR_NVC) { + code = TARGET_FPE_FLTINV; + } else if (fsr & FSR_OFC) { + code = TARGET_FPE_FLTOVF; + } else if (fsr & FSR_UFC) { + code = TARGET_FPE_FLTUND; + } else if (fsr & FSR_DZC) { + code = TARGET_FPE_FLTDIV; + } else if (fsr & FSR_NXC) { + code = TARGET_FPE_FLTRES; + } + } + force_sig_fault(TARGET_SIGFPE, code, env->pc); + } + break; + case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break;