From patchwork Thu Aug 18 18:44:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Mateus Martins Araujo e Castro X-Patchwork-Id: 1667822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M7v491rFkz1ygl for ; Fri, 19 Aug 2022 04:46:33 +1000 (AEST) Received: from localhost ([::1]:52020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOkXH-0000cb-3r for incoming@patchwork.ozlabs.org; Thu, 18 Aug 2022 14:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOkVL-0000bO-0F; Thu, 18 Aug 2022 14:44:31 -0400 Received: from [200.168.210.66] (port=25889 helo=outlook.eldorado.org.br) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOkVJ-0006bK-EP; Thu, 18 Aug 2022 14:44:30 -0400 Received: from p9ibm ([10.10.71.235]) by outlook.eldorado.org.br over TLS secured channel with Microsoft SMTPSVC(8.5.9600.16384); Thu, 18 Aug 2022 15:44:22 -0300 Received: from eldorado.org.br (unknown [10.10.70.45]) by p9ibm (Postfix) with ESMTP id 060AD80030B; Thu, 18 Aug 2022 15:44:22 -0300 (-03) From: "Lucas Mateus Castro(alqotel)" To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, danielhb413@gmail.com, "Lucas Mateus Castro(alqotel)" Subject: [PATCH v2 2/2] tests/tcg/ppc64le: Added an underflow with UE=1 test Date: Thu, 18 Aug 2022 15:44:20 -0300 Message-Id: <20220818184420.368154-2-lucas.araujo@eldorado.org.br> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220818184420.368154-1-lucas.araujo@eldorado.org.br> References: <20220818184420.368154-1-lucas.araujo@eldorado.org.br> MIME-Version: 1.0 X-OriginalArrivalTime: 18 Aug 2022 18:44:22.0248 (UTC) FILETIME=[88371E80:01D8B332] X-Host-Lookup-Failed: Reverse DNS lookup failed for 200.168.210.66 (failed) Received-SPF: pass client-ip=200.168.210.66; envelope-from=lucas.araujo@eldorado.org.br; helo=outlook.eldorado.org.br X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, PDS_HP_HELO_NORDNS=0.659, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Added a test to see if the adjustment is being made correctly when an underflow occurs and UE is set. Signed-off-by: Lucas Mateus Castro (alqotel) --- This patch will also fail without the underflow with UE set bugfix Message-Id:<20220805141522.412864-3-lucas.araujo@eldorado.org.br> --- tests/tcg/ppc64/Makefile.target | 1 + tests/tcg/ppc64le/Makefile.target | 1 + tests/tcg/ppc64le/ue_excp.c | 53 +++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tests/tcg/ppc64le/ue_excp.c diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.target index 43958ad87b..583677031b 100644 --- a/tests/tcg/ppc64/Makefile.target +++ b/tests/tcg/ppc64/Makefile.target @@ -30,5 +30,6 @@ run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10 PPC64_TESTS += signal_save_restore_xer PPC64_TESTS += xxspltw PPC64_TESTS += oe_excp +PPC64_TESTS += ue_excp TESTS += $(PPC64_TESTS) diff --git a/tests/tcg/ppc64le/Makefile.target b/tests/tcg/ppc64le/Makefile.target index 8d11ac731d..b9e689c582 100644 --- a/tests/tcg/ppc64le/Makefile.target +++ b/tests/tcg/ppc64le/Makefile.target @@ -28,5 +28,6 @@ PPC64LE_TESTS += mffsce PPC64LE_TESTS += signal_save_restore_xer PPC64LE_TESTS += xxspltw PPC64LE_TESTS += oe_excp +PPC64LE_TESTS += ue_excp TESTS += $(PPC64LE_TESTS) diff --git a/tests/tcg/ppc64le/ue_excp.c b/tests/tcg/ppc64le/ue_excp.c new file mode 100644 index 0000000000..028ef3bbc7 --- /dev/null +++ b/tests/tcg/ppc64le/ue_excp.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include + +#define FP_UE (1ull << 5) +#define MTFSF(FLM, FRB) asm volatile ("mtfsf %0, %1" :: "i" (FLM), "f" (FRB)) + +void sigfpe_handler(int sig, siginfo_t *si, void *ucontext) +{ + union { + uint64_t ll; + double dp; + } r; + uint64_t ch = 0x1b64f1c1b0000000ull; + r.dp = ((ucontext_t *)ucontext)->uc_mcontext.fp_regs[2]; + if (r.ll == ch) { + exit(0); + } + fprintf(stderr, "expected result: %lx\n result: %lx\n", ch, r.ll); + exit(1); +} + +int main() +{ + uint64_t fpscr; + uint64_t a = 0x00005ca8ull; + uint64_t b = 0x00001cefull; + + struct sigaction sa = { + .sa_sigaction = sigfpe_handler, + .sa_flags = SA_SIGINFO + }; + + prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE); + sigaction(SIGFPE, &sa, NULL); + + fpscr = FP_UE; + MTFSF(0b11111111, fpscr); + + asm ( + "lfd 0, %0\n\t" + "lfd 1, %1\n\t" + "fmul 2, 0, 1\n\t" + : + : "m"(a), "m"(b) + : "memory", "fr0", "fr1", "fr2" + ); + + abort(); +}