From patchwork Wed Mar 8 13:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 660435 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp329071wrb; Wed, 8 Mar 2023 05:32:56 -0800 (PST) X-Google-Smtp-Source: AK7set8ROwN/zAdvi4j1L5q6GaXhaVsdIkJkBTbO5zukMTqR9+LUuQPPy4N0+o0Xx7CkwDBl2R3r X-Received: by 2002:a05:622a:1a02:b0:3b8:5057:377b with SMTP id f2-20020a05622a1a0200b003b85057377bmr32246154qtb.65.1678282376502; Wed, 08 Mar 2023 05:32:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678282376; cv=none; d=google.com; s=arc-20160816; b=ktQYlJFqoJ9djMwfMcHV4jgu1yXNvTEXbUuzTq7DtN+dXhgQOApBeJhTF9GrQxvjdN 8pLJyPX4NqWzf279TAPQl1zsXU40/d7jbeEavu7IHETLAhQdeDEqevOTZVsEY326Jj8v wp0U51BsMevQsWuFyHul8STUNqA+glD3r0wPGr+UzHXBvyoXQ/C3rQW6yJkvM78pBLA8 2EQf8sUhCLYvtujiQsTykWsoFX2cugVzhQAEtd6EuhUtwZ1D2fknuFobriJULEEDPlnu drnJUlZIZlAM2q1cNfs3/is0gLYzOIieUNh3ic7D4P8tdF8rGC7V8T8g2hHaKjxoJhpe Vywg== 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:ui-outboundreport :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=dyUZcyqw58ajEPsQCsxwpYGwpENkrTYPLw3Q/OgGe+s=; b=csvOtYWDWXpkCN73Pjh7uvUkdmU2kwx+pUstQrU/IxEB+wKGtW9Okb3VvJBiWZH066 jz+YtcF/O3WUWNEjX5qkkKAxk7LfgIaNx3IsS3vhVg6pJ3fGJaYzuqtpDVGL3mihdw46 GRlZ+B9iNO3f7Uvb9g7t0aMfm9wsCuvffl9q1+lmddUf18rCM4gaCcpuvb/2kqNELLgS MU1YZQ9Z1FQKnXgZbOv2f5fvmOxrBJYboLLQHwaBRV95lyRcgc3n6ZGtdNGE8FhwDkwd Ez2xQs9nZhaYqW3SWVjF6pyiKNuMjCHCC5LqauL49y7nt/0IFgOPhZrDYUvNqjuMRMKT ZCYg== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t8-20020a05622a180800b003bd00b830c6si12475776qtc.78.2023.03.08.05.32.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Mar 2023 05:32:56 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZttu-0004Xs-1E; Wed, 08 Mar 2023 08:32:15 -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 1pZtrD-0001ql-Pv for qemu-devel@nongnu.org; Wed, 08 Mar 2023 08:29:35 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZtr3-00069G-66 for qemu-devel@nongnu.org; Wed, 08 Mar 2023 08:29:22 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MRnXY-1pykFs3thy-00TF9w; Wed, 08 Mar 2023 14:29:15 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier Subject: [PULL 26/28] linux-user/sparc: Handle floating-point exceptions Date: Wed, 8 Mar 2023 14:28:55 +0100 Message-Id: <20230308132857.161793-27-laurent@vivier.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230308132857.161793-1-laurent@vivier.eu> References: <20230308132857.161793-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:cdCaLCEuPYp6LjNd40NuPkbrygQXunlN85LjOx8UtRkulL4eRbq FKWLDDz3DAZGZhlm5QRudExxwxKBjq9lGV+QyeGQMIZoXaPfM8bYtulCyANOuxr+MYNOfN6 a6Jg9ZIc34/6qyHbP2Ymme4INDwR3SUifVyLfpMsR5jjgsjUL0H4okJYu/RGWj0ivrLdCEK zY1Z9e66e/3o71x91LSkA== UI-OutboundReport: notjunk:1;M01:P0:gKuMY2h/z8M=;gBtJ6krGvV5XDr0qfqEtvX/GGTB l4OJ7ROjZ1zZ8+BBjqsi2MMQc+6ZMq32CHMA3lEEgi5T3WtIne9UEKq2MAeLYbxAF1/bYX/Ub GMN6sMtR+vVMyy+QaC/JY9K48p+0cr8ryZN1cJw4NrokWx4ehvwlS6nEjZapfxnFB0+fpT4zH 1YzJbhYrvxInzxdi/PQ3vo+7REfp4/ptEPTmJ7tDX62lP0hRP7X0rN1NtAcqZ9y25iDYifU0C /zMTmXgwdn2mpfziWleDCpgT7HK3P2xp+m2it23sRAwuD2u2nxQXhYQpI/ESVmP4pwFLjrbHD ZxcVJg4WAx3c7n3m9HoYUcsNd0wEwEBnq5fXWbg8kSPbSW7vei+Hm117OJgsN+AJp0CmO0cbe zVDgjh/twz9HPeSDYxoNBopFgBq7cbe9vMPeNe/fB4zhLqe2K6592vKM8V4dMaUF+Fv8+J+ef 6dlPgVXTYbWPg4UIzIzmLPeaeh3XyDdW1wc2CGMej3pJ8FyIw7O9SnfUoXFPmqa8MWDPDnEY+ 8YTjjt3UAn5l3vlhBO/FN2arNPh9XXzYbnZ+oKZXNlrzr/FWfMeZkSZB6scVzIFXd0PRQgt7m jX2rlzcrbW+AZ9up3ZqtZC5yA7xyCBXrYO5aaJCOmHGISXlHMbF198ZG7IKGe7eoJzU/Cdkvy c9ff09ZjHaz1NEyvGQvLyhqb/a3Dj+CGd2UxpxwDVw== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 From: Richard Henderson 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 Message-Id: <20230216054516.1267305-15-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sparc/cpu_loop.c | 22 ++++++++++++++++++++++ target/sparc/cpu.h | 3 +-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 093358a39a4a..5a8a71e976bc 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -297,6 +297,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; diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ed0069d0b196..fb98843dad53 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