From nobody Sat Nov 28 01:30:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature); dmarc=fail(p=none dis=none) header.from=korins.ky Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795726097710554.3147046537089; Thu, 26 Nov 2026 12:48:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWgNf-0000w9-FP; Thu, 26 Nov 2026 15:47:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWgNe-0000vZ-09 for qemu-devel@nongnu.org; Thu, 26 Nov 2026 15:47:46 -0500 Received: from mx1.catap.net ([2a01:4f8:271:125e::2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWgNb-0006Hw-KT for qemu-devel@nongnu.org; Thu, 26 Nov 2026 15:47:45 -0500 Received: by mx1.catap.net (OpenSMTPD) id 9f5b88fd; Thu, 26 Nov 2026 21:47:38 +0100 (CET) Received: from localhost (matebook.home.arpa [local]) by matebook.home.arpa (OpenSMTPD) with ESMTPA id 980267ce; Thu, 26 Nov 2026 21:47:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=20240125rsa; cv=none; d=mx.catap.net; b=lxB1N0x 9ZBHt+NR+lATDwVwrDzarQIrU4mtO+lZPoCdgTa4yuANGS5JTpSRk45Rb0ibjw0W3vqht9 u0OQyWcrjpsmzzu+a3JYvlijGtG3PRz0R9kFm59HyIISqTeUlRvTHfZmalG2bEKm67Pdqa L+ocBctN/Q7W5TiMGXyeTsuNT4sXcJRBUt06AOSHqiPCBwrKS18I34EMscRPoMxu/RE/An 58h70eP+KPiPzklTaHvQ5BXc4IJWZ/ko82qb4HAFMKXFQwXKhUelcZ/mOMq8ehm9i+5QMB C+N+IQ72JEpquG6nI/fzz+k7P8TGdUmHAei7pTH4GpqCmTkgIKOsk0w== ARC-Message-Signature: i=1; a=rsa-sha256; s=20240125rsa; c=simple/simple; bh=f TZj8KzVqBRt5yab9n31u+3o2YGWKyai2HO8h+keKJ0=; h=references:in-reply-to: date:subject:cc:to:from:dkim-signature:dkim-signature; d=mx.catap.net; b=Y/nC0cpPCDWSEpPuv37j7xhTVoyOgEP3CoO4dTT6KD+oMxLj+kwRFobkQcMRQ7VihprZ pfbXeMtYtWPTRqSvwg6TGJGvXvxlQHVf6wWaQf7fb4zfwpAiyLRyUApYkIgsDqn5oM5AL8 lfuJXwuhU5ONTPO5qwG3zn5DnKBnvLSJtGwu2JctLCJUW0RAgZ0nalb34embR/e/h7X5Sf +dAmvjl4GO06TwMWoSG+dkI/HmFAZlI6aPWsHa8azgz/AJHCeSa8HaSfo4XqlxNtvV7NuU FQN/dc8I/hPysdsjr44VMO9jDPxOMzLP2NiyeTgxG9XY+Dt4d8WKd61EqDdHA8GQ== ARC-Authentication-Results: i=1; mx.catap.net; dkim=pass header.s=20240125rsa header.d=korins.ky header.a=rsa-sha256 header.b=zNBOEa8E; dkim=pass header.s=20240125ed25519 header.d=korins.ky header.a=ed25519-sha256 header.b=gceer0M9; arc=none; iprev=pass; spf=none smtp.helo=postmaster@matebook.home.arpa; spf=softfail smtp.mailfrom=kirill@korins.ky DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=20240125rsa; bh=fTZj8KzV qBRt5yab9n31u+3o2YGWKyai2HO8h+keKJ0=; h=references:in-reply-to:date: subject:cc:to:from; d=korins.ky; b=zNBOEa8ESqq2DlrsQxAY8NHm3LtC1k02/PD qsQ+SCyInyOfkXGQytJONU6Zry2Xl9up2+56r6RpBojv0KubecRMLI3tmUvVLFw9tBjCxz JWaYCwQhApK+Pnd/bBkS84RYTkad1/G5wHtnec4oDedlvUz31k+MWSine0GI5SduZM9YL7 QhPxSIAmdChKI9uwtT5Mlz2QbvZSfBSATd91+Z3xDnA8RcSVBfYcHFnNOohP944GxipzEp OVgiUNiyZrx179RkIJDbaJ2TlBtcB6i2nPqk339B2HKBQhyzD1bwNN74CPsP3jvms2gj8J d/ES2hgo1tMh4XF0I8ni34Sm8KA== DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=20240125ed25519; bh=fTZj8KzVqBRt5yab9n31u+3o2YGWKyai2HO8h+keKJ0=; h=references: in-reply-to:date:subject:cc:to:from; d=korins.ky; b=gceer0M9g6fhT7TCls o7UKsoYB2m4qHu7ffVJ2lINWLkB8dtvhiGFUvbNyb+3qnGCYbp9pwZCKaHLZeqx0MlCw== From: Kirill A. Korinsky To: Richard Henderson , Helge Deller , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org Cc: "Kirill A . Korinsky" Subject: [PATCH 1/3] target/hppa: Emulate FREM Date: Thu, 26 Nov 2026 21:39:20 +0100 Message-ID: <20261126204733.9423-2-kirill@korins.ky> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126204733.9423-1-kirill@korins.ky> References: <20261126204733.9423-1-kirill@korins.ky> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:4f8:271:125e::2; envelope-from=kirill@korins.ky; helo=mx1.catap.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1795726101208158500 Content-Type: text/plain; charset="utf-8" From: "Kirill A. Korinsky" OpenBSD/hppa's libm remainder tests terminate with SIGILL on FREM because QEMU's HPPA decoder omits class 3 subopcode 4 under both major opcodes, 0x0c and 0x0e, sending both encodings through gen_illegal() to raise EXCP_ILL when the FPU is enabled. Decode both encodings and compute IEEE remainder in single and double precision with SoftFloat, with qtest coverage for exact result bits at quotient ties under directed rounding and for the FPSR invalid operation flag on zero divisors and infinite dividends. Signed-off-by: Kirill A. Korinsky --- target/hppa/fpu_helper.c | 14 +++++ target/hppa/helper.h | 2 + target/hppa/insns.decode | 4 ++ target/hppa/translate.c | 10 ++++ tests/qtest/hppa-fpu-test.c | 105 +++++++++++++++++++++++++++++++++++- 5 files changed, 134 insertions(+), 1 deletion(-) diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c index a0c8c91ee5..f42044cdef 100644 --- a/target/hppa/fpu_helper.c +++ b/target/hppa/fpu_helper.c @@ -177,6 +177,13 @@ float32 HELPER(fdiv_s)(CPUHPPAState *env, float32 a, f= loat32 b) return ret; } =20 +float32 HELPER(frem_s)(CPUHPPAState *env, float32 a, float32 b) +{ + float32 ret =3D float32_rem(a, b, &env->fp_status); + update_fr0_op(env, GETPC()); + return ret; +} + float64 HELPER(fsqrt_d)(CPUHPPAState *env, float64 arg) { float64 ret =3D float64_sqrt(arg, &env->fp_status); @@ -219,6 +226,13 @@ float64 HELPER(fdiv_d)(CPUHPPAState *env, float64 a, f= loat64 b) return ret; } =20 +float64 HELPER(frem_d)(CPUHPPAState *env, float64 a, float64 b) +{ + float64 ret =3D float64_rem(a, b, &env->fp_status); + update_fr0_op(env, GETPC()); + return ret; +} + float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg) { float64 ret =3D float32_to_float64(arg, &env->fp_status); diff --git a/target/hppa/helper.h b/target/hppa/helper.h index f6c7e16f0f..b99e298ee8 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -30,6 +30,7 @@ DEF_HELPER_FLAGS_3(fadd_s, TCG_CALL_NO_RWG, f32, env, f32= , f32) DEF_HELPER_FLAGS_3(fsub_s, TCG_CALL_NO_RWG, f32, env, f32, f32) DEF_HELPER_FLAGS_3(fmpy_s, TCG_CALL_NO_RWG, f32, env, f32, f32) DEF_HELPER_FLAGS_3(fdiv_s, TCG_CALL_NO_RWG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(frem_s, TCG_CALL_NO_RWG, f32, env, f32, f32) =20 DEF_HELPER_FLAGS_2(fsqrt_d, TCG_CALL_NO_RWG, f64, env, f64) DEF_HELPER_FLAGS_2(frnd_d, TCG_CALL_NO_RWG, f64, env, f64) @@ -37,6 +38,7 @@ DEF_HELPER_FLAGS_3(fadd_d, TCG_CALL_NO_RWG, f64, env, f64= , f64) DEF_HELPER_FLAGS_3(fsub_d, TCG_CALL_NO_RWG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fmpy_d, TCG_CALL_NO_RWG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fdiv_d, TCG_CALL_NO_RWG, f64, env, f64, f64) +DEF_HELPER_FLAGS_3(frem_d, TCG_CALL_NO_RWG, f64, env, f64, f64) =20 DEF_HELPER_FLAGS_2(fcnv_s_d, TCG_CALL_NO_RWG, f64, env, f32) DEF_HELPER_FLAGS_2(fcnv_d_s, TCG_CALL_NO_RWG, f32, env, f64) diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode index 135f563c88..ebc290d830 100644 --- a/target/hppa/insns.decode +++ b/target/hppa/insns.decode @@ -620,21 +620,25 @@ fadd_f 001100 ..... ..... 000 00 ...... ....= . @f0c_3 fsub_f 001100 ..... ..... 001 00 ...... ..... @f0c_3 fmpy_f 001100 ..... ..... 010 00 ...... ..... @f0c_3 fdiv_f 001100 ..... ..... 011 00 ...... ..... @f0c_3 +frem_f 001100 ..... ..... 100 00 ...... ..... @f0c_3 =20 fadd_d 001100 ..... ..... 000 01 ...... ..... @f0c_3 fsub_d 001100 ..... ..... 001 01 ...... ..... @f0c_3 fmpy_d 001100 ..... ..... 010 01 ...... ..... @f0c_3 fdiv_d 001100 ..... ..... 011 01 ...... ..... @f0c_3 +frem_d 001100 ..... ..... 100 01 ...... ..... @f0c_3 =20 fadd_f 001110 ..... ..... 000 ..... ... ..... @f0e_f_3 fsub_f 001110 ..... ..... 001 ..... ... ..... @f0e_f_3 fmpy_f 001110 ..... ..... 010 ..... ... ..... @f0e_f_3 fdiv_f 001110 ..... ..... 011 ..... ... ..... @f0e_f_3 +frem_f 001110 ..... ..... 100 ..... ... ..... @f0e_f_3 =20 fadd_d 001110 ..... ..... 000 ..... ... ..... @f0e_d_3 fsub_d 001110 ..... ..... 001 ..... ... ..... @f0e_d_3 fmpy_d 001110 ..... ..... 010 ..... ... ..... @f0e_d_3 fdiv_d 001110 ..... ..... 011 ..... ... ..... @f0e_d_3 +frem_d 001110 ..... ..... 100 ..... ... ..... @f0e_d_3 =20 xmpyu 001110 ..... ..... 010 .0111 .00 t:5 r1=3D%ra64 r2=3D%r= b64 =20 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index ab3505f9c9..0713112063 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4498,6 +4498,16 @@ static bool trans_fdiv_d(DisasContext *ctx, arg_fcla= ss3 *a) return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fdiv_d); } =20 +static bool trans_frem_f(DisasContext *ctx, arg_fclass3 *a) +{ + return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_frem_s); +} + +static bool trans_frem_d(DisasContext *ctx, arg_fclass3 *a) +{ + return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_frem_d); +} + static bool trans_xmpyu(DisasContext *ctx, arg_xmpyu *a) { TCGv_i64 x, y; diff --git a/tests/qtest/hppa-fpu-test.c b/tests/qtest/hppa-fpu-test.c index af4ff2a162..40e097dbbe 100644 --- a/tests/qtest/hppa-fpu-test.c +++ b/tests/qtest/hppa-fpu-test.c @@ -1,5 +1,5 @@ /* - * HPPA CCR floating-point enable and lazy context switching tests. + * HPPA floating-point instruction and context switching tests. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -296,6 +296,104 @@ static void test_lazy(void) qtest_quit(qts); } =20 +typedef struct FremTest { + const char *name; + uint32_t instruction; + uint64_t dividend; + uint64_t divisor; + uint64_t result; + uint32_t fpsr; + uint32_t flags; +} FremTest; + +static const FremTest frem_tests[] =3D { + { + .name =3D "single-tie", + .instruction =3D 0x318d860e, /* frem,sgl fr12,fr13,fr14 */ + .dividend =3D 0x40e0000000000000ULL, /* 7.0f */ + .divisor =3D 0x4000000000000000ULL, /* 2.0f */ + .result =3D 0xbf80000089abcdefULL, /* -1.0f */ + .fpsr =3D 0x200, /* round toward zero */ + }, + { + .name =3D "double-tie", + .instruction =3D 0x318d8e0e, /* frem,dbl fr12,fr13,fr14 */ + .dividend =3D 0x4014000000000000ULL, /* 5.0 */ + .divisor =3D 0x4000000000000000ULL, /* 2.0 */ + .result =3D 0x3ff0000000000000ULL, /* 1.0 */ + .fpsr =3D 0x400, /* round upward */ + }, + { + .name =3D "single-extended-subnormal", + .instruction =3D 0x398d96ce, /* frem,sgl fr12R,fr13R,fr14R */ + .dividend =3D 0x0000000000000001ULL, /* smallest subnormal */ + .divisor =3D 0x000000003f800000ULL, /* 1.0f */ + .result =3D 0x0123456700000001ULL, + .fpsr =3D 0x600, /* round downward */ + }, + { + .name =3D "double-extended-negative-zero", + .instruction =3D 0x398d8e0e, /* frem,dbl fr12,fr13,fr14 */ + .dividend =3D 0xc010000000000000ULL, /* -4.0 */ + .divisor =3D 0x4000000000000000ULL, /* 2.0 */ + .result =3D 0x8000000000000000ULL, /* -0.0 */ + }, + { + .name =3D "single-zero-divisor", + .instruction =3D 0x318d860e, + .dividend =3D 0x3f80000000000000ULL, /* 1.0f */ + .divisor =3D 0, + .result =3D 0x7fa0000089abcdefULL, /* quiet NaN */ + .flags =3D 0x80000000, /* invalid operation */ + }, + { + .name =3D "double-infinite-dividend", + .instruction =3D 0x398d8e0e, + .dividend =3D 0x7ff0000000000000ULL, /* infinity */ + .divisor =3D 0x3ff0000000000000ULL, /* 1.0 */ + .result =3D 0x7ff4000000000000ULL, /* quiet NaN */ + .flags =3D 0x80000000, /* invalid operation */ + }, +}; + +static void test_frem(const void *opaque) +{ + const FremTest *test =3D opaque; + const uint32_t guest[] =3D { + 0x34011000, /* ldi 0x800,r1 */ + 0x01c11840, /* mtctl r1,iva */ + 0x34103000, /* ldi 0x1800,r16 */ + 0x34113200, /* ldi 0x1900,r17 */ + 0x34010180, /* ldi 0xc0,r1 */ + 0x01411840, /* mtctl r1,ccr */ + 0x2e00100c, /* fldd 0(r16),fr12 */ + 0x2e10100d, /* fldd 8(r16),fr13 */ + 0x36100020, /* ldo 16(r16),r16 */ + 0x2e001000, /* fldd 0(r16),fr0 */ + 0x2e10100e, /* fldd 8(r16),fr14 */ + test->instruction, + 0x2e10120e, /* fstd fr14,8(r16) */ + 0x2e001200, /* fstd fr0,0(r16) */ + 0x34010002, /* ldi 1,r1 */ + 0x6a210000, /* stw r1,0(r17): completion */ + }; + QTestState *qts =3D start_guest(false); + uint32_t end =3D CODE + sizeof(guest); + + write_words(qts, CODE, guest, G_N_ELEMENTS(guest)); + qtest_writel(qts, end, branch(end, HALT)); + qtest_writeq(qts, DATA, test->dividend); + qtest_writeq(qts, DATA + 8, test->divisor); + qtest_writeq(qts, DATA + 16, (uint64_t)test->fpsr << 32); + /* A single-precision write must preserve the other half of FR14. */ + qtest_writeq(qts, DATA + 24, 0x0123456789abcdefULL); + + run_guest(qts, 1); + g_assert_cmphex(qtest_readq(qts, DATA + 24), =3D=3D, test->result); + g_assert_cmphex(qtest_readl(qts, DATA + 16), =3D=3D, test->fpsr | test= ->flags); + qtest_quit(qts); +} + static const uint32_t fault_guest[] =3D { 0x34011000, /* ldi 0x800,r1 */ 0x01c11840, /* mtctl r1,iva */ @@ -362,6 +460,11 @@ int main(int argc, char **argv) qtest_add_data_func(name, &fp_tests[i], test_fp); } qtest_add_func("fpu/lazy-contexts", test_lazy); + for (size_t i =3D 0; i < G_N_ELEMENTS(frem_tests); i++) { + g_autofree char *name =3D g_strdup_printf("fpu/frem/%s", frem_test= s[i].name); + + qtest_add_data_func(name, &frem_tests[i], test_frem); + } for (size_t i =3D 0; i < G_N_ELEMENTS(fault_tests); i++) { g_autofree char *name =3D g_strdup_printf("fpu/%s", fault_tests[i]= .name); =20 --=20 2.56.1 From nobody Sat Nov 28 01:30:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature); dmarc=fail(p=none dis=none) header.from=korins.ky Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795726098572493.77351177011576; Thu, 26 Nov 2026 12:48:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWgNh-0000xK-0T; Thu, 26 Nov 2026 15:47:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWgNf-0000w1-0Y for qemu-devel@nongnu.org; Thu, 26 Nov 2026 15:47:47 -0500 Received: from mx1.catap.net ([162.55.82.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWgNc-0006Hz-A0 for qemu-devel@nongnu.org; Thu, 26 Nov 2026 15:47:46 -0500 Received: by mx1.catap.net (OpenSMTPD) id b9d565dd; Thu, 26 Nov 2026 21:47:39 +0100 (CET) Received: from localhost (matebook.home.arpa [local]) by matebook.home.arpa (OpenSMTPD) with ESMTPA id e0fe966b; Thu, 26 Nov 2026 21:47:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=20240125rsa; cv=none; d=mx.catap.net; b=aD0Zddy IwjAv9x+c1rZzTl8ovHBRyZUEC4qaKyV/hsNtzlq6/i0efJClxxhT0I+S+xhKEmw4/37C1 GKM13BQQQPvFlQSufLXTM6JgQ+OsTEmxz6i5tDoNf2xkpy71GZQNNsO6rI+Vz3BRfRjFKI dGTZz4FPc7Fr4jO4kypRug6shTPz4eD6XSksknB/NVsJr1idDQ3AZZsvrywq6Hzenx5f9e 6qG7kuPTF08abtNTQCuY+aFWmOXKVmapwlXGzmM+qrOh+kqDXVsY+/TZxY95wzMtOR9JAM 7yfRdTQHdpWdPqpDRxKdsoDID2e9onIsnAPmo9xU9kcHqXpqKiYQppA== ARC-Message-Signature: i=1; a=rsa-sha256; s=20240125rsa; c=simple/simple; bh=I ZvJVKL71yV2YWlyN5Xj521fBe/jW/9ZZrWrVwyBj8s=; h=references:in-reply-to: date:subject:cc:to:from:dkim-signature:dkim-signature; d=mx.catap.net; b=RFujMlrepOk7gnnWz0OA3pjkCyR3gPCSZnJNy7R26n9GmWP5txvfsv9+BfCyam55zyuP q3YEZofFqk+fwTmsDbtmDkf+DnJddNfwFoiHgaAiJ8/A8G1Sj4A6JUd46nleg05JSh2ZuZ M+nyO1IVAQgCdIBjlaX5aBjWIYnZFg5hmSIu3XT3TB7XcuTe8+ZA2SE7Ur4XghU2yt1RlP a9g/W/Pjsk8V3394WMFdXKOtUfdfHaFPhNB6dvNOv06aP55Wc+s+uFuKtTk56ZhYV/JHtD gnowdSxMRT9bModFtvjAZ3s3LngXs3Gfa+dF3Euam6Ij4gWMiV2zNRuSm6r96Jsw== ARC-Authentication-Results: i=1; mx.catap.net; dkim=pass header.s=20240125rsa header.d=korins.ky header.a=rsa-sha256 header.b=P41NjJHK; dkim=pass header.s=20240125ed25519 header.d=korins.ky header.a=ed25519-sha256 header.b=/1t43leL; arc=none; iprev=pass; spf=none smtp.helo=postmaster@matebook.home.arpa; spf=softfail smtp.mailfrom=kirill@korins.ky DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=20240125rsa; bh=IZvJVKL7 1yV2YWlyN5Xj521fBe/jW/9ZZrWrVwyBj8s=; h=references:in-reply-to:date: subject:cc:to:from; d=korins.ky; b=P41NjJHKfcorq2Q660ycxh7ydkbNmwL1/MW mcHcAtDnyjcLWzpUrFnqBWXkROPk/IxQSFA3yXpwXPLKfv/Jwy+MQav4h9YKdBIPqKm1BX E/zpeeULj3oIZgkyfxbEmDyhwhksEAF8QaNiUUOemRfWNhdg251txomLBPQBiiwhFOxIUz sU0CGWo2akP0UXvn/AFX85WGwQ6EOxW8ziVx5KbmWCDZY+NTrmIgtqY433owVdp58uZsif YmO1pd/lEemYSvQdtrLTC9cLNnMtS9so+GTFHn5LhC6DmU5yiFb05G1GxvjWfGUilv8V+F KUpVMyddX6yjSkDeSKvovCJkccw== DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=20240125ed25519; bh=IZvJVKL71yV2YWlyN5Xj521fBe/jW/9ZZrWrVwyBj8s=; h=references: in-reply-to:date:subject:cc:to:from; d=korins.ky; b=/1t43leLSSDDkBKMb3 ck5pLTUpQZV6y9wvlqjgwwq0obO6G0+LJuipbp6L36PStef3TJgMIfFiLWbqmK4uyoDQ== From: Kirill A. Korinsky To: Richard Henderson , Helge Deller , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org Cc: "Kirill A . Korinsky" Subject: [PATCH 2/3] target/hppa: Defer PA7300LC FCNVFF on NaNs Date: Thu, 26 Nov 2026 21:39:21 +0100 Message-ID: <20261126204733.9423-3-kirill@korins.ky> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126204733.9423-1-kirill@korins.ky> References: <20261126204733.9423-1-kirill@korins.ky> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=162.55.82.72; envelope-from=kirill@korins.ky; helo=mx1.catap.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1795726101344158500 Content-Type: text/plain; charset="utf-8" From: "Kirill A. Korinsky" QEMU passed PA7300LC FCNVFF NaN operands to SoftFloat, bypassing the deferred assist exercised by OpenBSD/hppa's fmaxmin_test-11. For a NaN operand, leave the destination intact, record the instruction in ER2 and set FPSR.T so the next active floating point instruction takes assist vector 14 before execution. FSTD FR0 can save the pending status first, clearing T only after the store succeeds. Signed-off-by: Kirill A. Korinsky --- target/hppa/cpu.h | 1 + target/hppa/fpu_helper.c | 47 ++++++++++++-- target/hppa/helper.h | 4 +- target/hppa/int_helper.c | 4 ++ target/hppa/translate.c | 79 +++++++++++++++++------ tests/qtest/hppa-fpu-test.c | 121 ++++++++++++++++++++++++++++++++++++ 6 files changed, 228 insertions(+), 28 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 7b708a564b..842964074a 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -97,6 +97,7 @@ =20 /* Emulated hardware TOC button */ #define EXCP_TOC 32 /* TOC =3D Transfer of control (NMI) */ +#define EXCP_ASSIST_DELAYED 33 /* Internal, delivered through vector = 14 */ =20 const char *hppa_exception_name(int excp); =20 diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c index f42044cdef..82ad6da34d 100644 --- a/target/hppa/fpu_helper.c +++ b/target/hppa/fpu_helper.c @@ -113,6 +113,10 @@ static void update_fr0_op(CPUHPPAState *env, uintptr_t= ra) shadow =3D FIELD_DP32(shadow, FPSR, T, 1); /* fill exception register #1, which is lower 32-bits of fr[0] */ #if !defined(CONFIG_USER_ONLY) + if (!hppa_is_pa20(env)) { + /* Drop any retained ER2 record before an immediate trap. */ + env->fr[1] =3D (uint32_t)env->fr[1]; + } if (hard_exp & (R_FPSR_ENA_O_MASK | R_FPSR_ENA_U_MASK)) { /* over- and underflow both set overflow flag only */ fr1 =3D FIELD_DP32(fr1, FPSR, C, 1); @@ -233,18 +237,49 @@ float64 HELPER(frem_d)(CPUHPPAState *env, float64 a, = float64 b) return ret; } =20 -float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg) +#ifndef CONFIG_USER_ONLY +static void defer_fp_unimplemented(CPUHPPAState *env, uint32_t insn) +{ + uint32_t code =3D (insn >> 26) =3D=3D 0x0c ? 0x09 : 0x0b; + uint32_t record =3D deposit32(insn, 26, 6, code); + + /* PA7300LC records the original operation in exception register 2. */ + env->fr[1] =3D deposit64(env->fr[1], 32, 32, record); + env->fr0_shadow |=3D R_FPSR_T_MASK; + env->fr[0] =3D deposit64(env->fr[0], 32, 32, env->fr0_shadow); +} +#endif + +void HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg, uint32_t reg, uint32= _t insn) { - float64 ret =3D float32_to_float64(arg, &env->fp_status); + float64 ret; + +#ifndef CONFIG_USER_ONLY + if (!hppa_is_pa20(env) && float32_is_any_nan(arg)) { + defer_fp_unimplemented(env, insn); + return; + } +#endif + ret =3D float32_to_float64(arg, &env->fp_status); update_fr0_op(env, GETPC()); - return ret; + env->fr[reg] =3D ret; } =20 -float32 HELPER(fcnv_d_s)(CPUHPPAState *env, float64 arg) +void HELPER(fcnv_d_s)(CPUHPPAState *env, float64 arg, uint32_t reg, uint32= _t insn) { - float32 ret =3D float64_to_float32(arg, &env->fp_status); + float32 ret; + unsigned shift =3D reg & 32 ? 0 : 32; + +#ifndef CONFIG_USER_ONLY + if (!hppa_is_pa20(env) && float64_is_any_nan(arg)) { + defer_fp_unimplemented(env, insn); + return; + } +#endif + ret =3D float64_to_float32(arg, &env->fp_status); update_fr0_op(env, GETPC()); - return ret; + reg &=3D 31; + env->fr[reg] =3D deposit64(env->fr[reg], shift, 32, ret); } =20 float32 HELPER(fcnv_w_s)(CPUHPPAState *env, int32_t arg) diff --git a/target/hppa/helper.h b/target/hppa/helper.h index b99e298ee8..84937ee73f 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -40,8 +40,8 @@ DEF_HELPER_FLAGS_3(fmpy_d, TCG_CALL_NO_RWG, f64, env, f64= , f64) DEF_HELPER_FLAGS_3(fdiv_d, TCG_CALL_NO_RWG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(frem_d, TCG_CALL_NO_RWG, f64, env, f64, f64) =20 -DEF_HELPER_FLAGS_2(fcnv_s_d, TCG_CALL_NO_RWG, f64, env, f32) -DEF_HELPER_FLAGS_2(fcnv_d_s, TCG_CALL_NO_RWG, f32, env, f64) +DEF_HELPER_FLAGS_4(fcnv_s_d, TCG_CALL_NO_RWG, void, env, f32, i32, i32) +DEF_HELPER_FLAGS_4(fcnv_d_s, TCG_CALL_NO_RWG, void, env, f64, i32, i32) =20 DEF_HELPER_FLAGS_2(fcnv_w_s, TCG_CALL_NO_RWG, f32, env, s32) DEF_HELPER_FLAGS_2(fcnv_dw_s, TCG_CALL_NO_RWG, f32, env, s64) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index da9c7c6457..8a19232062 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -162,6 +162,7 @@ void hppa_cpu_do_interrupt(CPUState *cs) case EXCP_COND: case EXCP_PRIV_REG: case EXCP_PRIV_OPR: + case EXCP_ASSIST_DELAYED: /* IIR set via translate.c. */ break; =20 @@ -223,6 +224,9 @@ void hppa_cpu_do_interrupt(CPUState *cs) } =20 /* step 7 */ + if (i =3D=3D EXCP_ASSIST_DELAYED) { + i =3D EXCP_ASSIST; + } if (i =3D=3D EXCP_TOC) { hwaddr pdc_toc_addr =3D FIRMWARE_START; =20 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 0713112063..67670768d1 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -1692,13 +1692,32 @@ static bool do_load(DisasContext *ctx, unsigned rt,= unsigned rb, return nullify_end(ctx); } =20 +static void gen_fp_assist_check(DisasContext *ctx) +{ +#ifndef CONFIG_USER_ONLY + if (!ctx->is_pa20) { + TCGv_i32 fpsr =3D tcg_temp_new_i32(); + DisasDelayException *e =3D delay_excp(ctx, EXCP_ASSIST_DELAYED); + + tcg_gen_ld_i32(fpsr, tcg_env, offsetof(CPUHPPAState, fr0_shadow)); + tcg_gen_brcondi_i32(TCG_COND_TSTNE, fpsr, R_FPSR_T_MASK, e->lab); + } +#endif +} + +static void fp_nullify_over(DisasContext *ctx) +{ + nullify_over(ctx); + gen_fp_assist_check(ctx); +} + static bool do_floadw(DisasContext *ctx, unsigned rt, unsigned rb, unsigned rx, int scale, int64_t disp, unsigned sp, int modify) { TCGv_i32 tmp; =20 - nullify_over(ctx); + fp_nullify_over(ctx); =20 tmp =3D tcg_temp_new_i32(); do_load_32(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_UL); @@ -1745,7 +1764,7 @@ static bool do_floadd(DisasContext *ctx, unsigned rt,= unsigned rb, { TCGv_i64 tmp; =20 - nullify_over(ctx); + fp_nullify_over(ctx); =20 tmp =3D tcg_temp_new_i64(); do_load_64(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_UQ); @@ -1782,7 +1801,7 @@ static bool do_fstorew(DisasContext *ctx, unsigned rt= , unsigned rb, { TCGv_i32 tmp; =20 - nullify_over(ctx); + fp_nullify_over(ctx); =20 tmp =3D load_frw_i32(rt); do_store_32(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_UL); @@ -1807,8 +1826,22 @@ static bool do_fstored(DisasContext *ctx, unsigned r= t, unsigned rb, =20 nullify_over(ctx); =20 + if (rt !=3D 0) { + gen_fp_assist_check(ctx); + } tmp =3D load_frd(rt); do_store_64(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_UQ); +#ifndef CONFIG_USER_ONLY + if (rt =3D=3D 0 && !ctx->is_pa20) { + TCGv_i32 fpsr =3D tcg_temp_new_i32(); + + /* FSTD FR0 saves T in memory and clears it only after the store. = */ + tcg_gen_andi_i64(tmp, tmp, ~((uint64_t)R_FPSR_T_MASK << 32)); + save_frd(0, tmp); + tcg_gen_extrh_i64_i32(fpsr, tmp); + tcg_gen_st_i32(fpsr, tcg_env, offsetof(CPUHPPAState, fr0_shadow)); + } +#endif =20 return nullify_end(ctx); } @@ -1827,7 +1860,7 @@ static bool do_fop_wew(DisasContext *ctx, unsigned rt= , unsigned ra, { TCGv_i32 tmp; =20 - nullify_over(ctx); + fp_nullify_over(ctx); tmp =3D load_frw0_i32(ra); =20 func(tmp, tcg_env, tmp); @@ -1842,7 +1875,7 @@ static bool do_fop_wed(DisasContext *ctx, unsigned rt= , unsigned ra, TCGv_i32 dst; TCGv_i64 src; =20 - nullify_over(ctx); + fp_nullify_over(ctx); src =3D load_frd(ra); dst =3D tcg_temp_new_i32(); =20 @@ -1857,7 +1890,7 @@ static bool do_fop_ded(DisasContext *ctx, unsigned rt= , unsigned ra, { TCGv_i64 tmp; =20 - nullify_over(ctx); + fp_nullify_over(ctx); tmp =3D load_frd0(ra); =20 func(tmp, tcg_env, tmp); @@ -1872,7 +1905,7 @@ static bool do_fop_dew(DisasContext *ctx, unsigned rt= , unsigned ra, TCGv_i32 src; TCGv_i64 dst; =20 - nullify_over(ctx); + fp_nullify_over(ctx); src =3D load_frw0_i32(ra); dst =3D tcg_temp_new_i64(); =20 @@ -1888,7 +1921,7 @@ static bool do_fop_weww(DisasContext *ctx, unsigned r= t, { TCGv_i32 a, b; =20 - nullify_over(ctx); + fp_nullify_over(ctx); a =3D load_frw0_i32(ra); b =3D load_frw0_i32(rb); =20 @@ -1904,7 +1937,7 @@ static bool do_fop_dedd(DisasContext *ctx, unsigned r= t, { TCGv_i64 a, b; =20 - nullify_over(ctx); + fp_nullify_over(ctx); a =3D load_frd0(ra); b =3D load_frd0(rb); =20 @@ -4133,7 +4166,7 @@ static bool trans_fid_f(DisasContext *ctx, arg_fid_f = *a) ret =3D 0x0f080000000000ULL; /* PA7300LC (PCX-L2) */ } =20 - nullify_over(ctx); + fp_nullify_over(ctx); save_frd(0, tcg_constant_i64(ret)); return nullify_end(ctx); } @@ -4239,12 +4272,18 @@ static bool trans_fnegabs_d(DisasContext *ctx, arg_= fclass01 *a) =20 static bool trans_fcnv_d_f(DisasContext *ctx, arg_fclass01 *a) { - return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_d_s); + fp_nullify_over(ctx); + gen_helper_fcnv_d_s(tcg_env, load_frd(a->r), tcg_constant_i32(a->t), + tcg_constant_i32(ctx->insn)); + return nullify_end(ctx); } =20 static bool trans_fcnv_f_d(DisasContext *ctx, arg_fclass01 *a) { - return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_s_d); + fp_nullify_over(ctx); + gen_helper_fcnv_s_d(tcg_env, load_frw0_i32(a->r), tcg_constant_i32(a->= t), + tcg_constant_i32(ctx->insn)); + return nullify_end(ctx); } =20 static bool trans_fcnv_w_f(DisasContext *ctx, arg_fclass01 *a) @@ -4375,7 +4414,7 @@ static bool trans_fcmp_f(DisasContext *ctx, arg_fclas= s2 *a) { TCGv_i32 ta, tb, tc, ty; =20 - nullify_over(ctx); + fp_nullify_over(ctx); =20 ta =3D load_frw0_i32(a->r1); tb =3D load_frw0_i32(a->r2); @@ -4392,7 +4431,7 @@ static bool trans_fcmp_d(DisasContext *ctx, arg_fclas= s2 *a) TCGv_i64 ta, tb; TCGv_i32 tc, ty; =20 - nullify_over(ctx); + fp_nullify_over(ctx); =20 ta =3D load_frd0(a->r1); tb =3D load_frd0(a->r2); @@ -4412,9 +4451,6 @@ static bool trans_ftest(DisasContext *ctx, arg_ftest = *a) =20 nullify_over(ctx); =20 - t =3D tcg_temp_new_i64(); - tcg_gen_ld32u_i64(t, tcg_env, offsetof(CPUHPPAState, fr0_shadow)); - if (a->y =3D=3D 1) { switch (a->c) { case 0: /* simple */ @@ -4450,6 +4486,9 @@ static bool trans_ftest(DisasContext *ctx, arg_ftest = *a) mask =3D R_FPSR_CA0_MASK >> cbit; } =20 + gen_fp_assist_check(ctx); + t =3D tcg_temp_new_i64(); + tcg_gen_ld32u_i64(t, tcg_env, offsetof(CPUHPPAState, fr0_shadow)); ctx->null_cond =3D cond_make_ti(tc, t, mask); return nullify_end(ctx); } @@ -4512,7 +4551,7 @@ static bool trans_xmpyu(DisasContext *ctx, arg_xmpyu = *a) { TCGv_i64 x, y; =20 - nullify_over(ctx); + fp_nullify_over(ctx); =20 x =3D load_frw0_i64(a->r1); y =3D load_frw0_i64(a->r2); @@ -4580,7 +4619,7 @@ static bool trans_fmpyfadd_f(DisasContext *ctx, arg_f= mpyfadd_f *a) { TCGv_i32 x, y, z; =20 - nullify_over(ctx); + fp_nullify_over(ctx); x =3D load_frw0_i32(a->rm1); y =3D load_frw0_i32(a->rm2); z =3D load_frw0_i32(a->ra3); @@ -4599,7 +4638,7 @@ static bool trans_fmpyfadd_d(DisasContext *ctx, arg_f= mpyfadd_d *a) { TCGv_i64 x, y, z; =20 - nullify_over(ctx); + fp_nullify_over(ctx); x =3D load_frd0(a->rm1); y =3D load_frd0(a->rm2); z =3D load_frd0(a->ra3); diff --git a/tests/qtest/hppa-fpu-test.c b/tests/qtest/hppa-fpu-test.c index 40e097dbbe..f49d834e31 100644 --- a/tests/qtest/hppa-fpu-test.c +++ b/tests/qtest/hppa-fpu-test.c @@ -394,6 +394,122 @@ static void test_frem(const void *opaque) qtest_quit(qts); } =20 +typedef struct FcnvTest { + const char *name; + uint32_t instruction; + uint64_t operand; + uint64_t result; + uint64_t result_mask; + uint32_t er2; + bool result_first; +} FcnvTest; + +static const FcnvTest fcnv_tests[] =3D { + { + .name =3D "status-first", + .instruction =3D 0x3180220c, /* fcnvff,sgl,dbl fr12,fr12 */ + .operand =3D 0x7fa0000012345678ULL, + .result =3D 0x7fa0000000000000ULL, + .result_mask =3D 0xffffffff00000000ULL, + .er2 =3D 0x2580220c, + }, + { + .name =3D "result-first", + .instruction =3D 0x3180220c, + .operand =3D 0x7fa0000012345678ULL, + .result =3D 0x7fa0000000000000ULL, + .result_mask =3D 0xffffffff00000000ULL, + .er2 =3D 0x2580220c, + .result_first =3D true, + }, + { + .name =3D "finite", + .instruction =3D 0x3180220c, + .operand =3D 0x4000000012345678ULL, /* 2.0f in the left half */ + .result =3D 0x4000000000000000ULL, /* 2.0 */ + .result_mask =3D UINT64_MAX, + }, + { + .name =3D "extended-status-first", + .instruction =3D 0x39800a4c, /* fcnvff,dbl,sgl fr12,fr12R */ + .operand =3D 0x7ff4000001234567ULL, + .result =3D 0x7ff4000001234567ULL, + .result_mask =3D UINT64_MAX, + .er2 =3D 0x2d800a4c, + }, + { + .name =3D "extended-finite", + .instruction =3D 0x39800a4c, + .operand =3D 0x4004000000000000ULL, /* 2.5 */ + .result =3D 0x4004000040200000ULL, /* 2.5f in the right half */ + .result_mask =3D UINT64_MAX, + }, +}; + +static const uint32_t fcnv_save[] =3D { + 0x2e101200, /* fstd fr0,8(r16) */ + 0x36100020, /* ldo 16(r16),r16 */ + 0x2e001201, /* fstd fr1,0(r16) */ + 0x2e101200, /* fstd fr0,8(r16) */ + 0x36100020, /* ldo 16(r16),r16 */ + 0x2e00120c, /* fstd fr12,0(r16) */ +}; + +static void test_fcnv(const void *opaque) +{ + const FcnvTest *test =3D opaque; + const uint32_t guest[] =3D { + 0x34011000, /* ldi 0x800,r1 */ + 0x01c11840, /* mtctl r1,iva */ + 0x34103000, /* ldi 0x1800,r16 */ + 0x34113200, /* ldi 0x1900,r17 */ + 0x34123050, /* ldi 0x1828,r18 */ + 0x34010180, /* ldi 0xc0,r1 */ + 0x01411840, /* mtctl r1,ccr */ + 0x2e00100c, /* fldd 0(r16),fr12 */ + test->instruction, + 0x08002880, /* cmpclr,=3D r0,r0,r0 */ + 0x2e40120c, /* fstd fr12,0(r18): nullified */ + }; + static const uint32_t complete[] =3D { + 0x34010002, /* ldi 1,r1 */ + 0x6a210000, /* stw r1,0(r17): completion */ + }; + QTestState *qts =3D start_guest(false); + uint32_t pc =3D CODE + sizeof(guest); + uint64_t fr0 =3D test->er2 ? 0x0000004000000000ULL : 0; + + write_words(qts, CODE, guest, G_N_ELEMENTS(guest)); + if (test->result_first) { + uint32_t vector_branch =3D 0x800 + 14 * 32 + 4; + uint32_t end =3D ASSIST + sizeof(fcnv_save); + + qtest_writel(qts, pc, 0x2e40120c); /* fstd fr12,0(r18) */ + pc +=3D 4; + qtest_writel(qts, vector_branch, branch(vector_branch, ASSIST)); + write_words(qts, ASSIST, fcnv_save, G_N_ELEMENTS(fcnv_save)); + qtest_writel(qts, end, branch(end, UNEXPECTED)); + } + write_words(qts, pc, fcnv_save, G_N_ELEMENTS(fcnv_save)); + pc +=3D sizeof(fcnv_save); + write_words(qts, pc, complete, G_N_ELEMENTS(complete)); + pc +=3D sizeof(complete); + qtest_writel(qts, pc, branch(pc, HALT)); + qtest_writeq(qts, DATA, test->operand); + + run_guest(qts, test->result_first ? 0x10e : 1); + if (test->result_first) { + g_assert_cmphex(qtest_readl(qts, RESULT + 8), =3D=3D, CODE + sizeo= f(guest)); + } + g_assert_cmphex(qtest_readq(qts, DATA + 8), =3D=3D, fr0); + g_assert_cmphex(qtest_readl(qts, DATA + 16), =3D=3D, test->er2); + g_assert_cmphex(qtest_readq(qts, DATA + 24), =3D=3D, 0); + g_assert_cmphex(qtest_readq(qts, DATA + 32) & test->result_mask, =3D= =3D, + test->result); + g_assert_cmphex(qtest_readq(qts, DATA + 40), =3D=3D, 0); + qtest_quit(qts); +} + static const uint32_t fault_guest[] =3D { 0x34011000, /* ldi 0x800,r1 */ 0x01c11840, /* mtctl r1,iva */ @@ -465,6 +581,11 @@ int main(int argc, char **argv) =20 qtest_add_data_func(name, &frem_tests[i], test_frem); } + for (size_t i =3D 0; i < G_N_ELEMENTS(fcnv_tests); i++) { + g_autofree char *name =3D g_strdup_printf("fpu/fcnv/%s", fcnv_test= s[i].name); + + qtest_add_data_func(name, &fcnv_tests[i], test_fcnv); + } for (size_t i =3D 0; i < G_N_ELEMENTS(fault_tests); i++) { g_autofree char *name =3D g_strdup_printf("fpu/%s", fault_tests[i]= .name); =20 --=20 2.56.1 From nobody Sat Nov 28 01:30:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature); dmarc=fail(p=none dis=none) header.from=korins.ky Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795726107832167.82935992085788; Thu, 26 Nov 2026 12:48:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWgNh-0000xc-Hu; Thu, 26 Nov 2026 15:47:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWgNf-0000wT-Ub for qemu-devel@nongnu.org; Thu, 26 Nov 2026 15:47:47 -0500 Received: from mx1.catap.net ([162.55.82.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWgNc-00066Y-Iy for qemu-devel@nongnu.org; Thu, 26 Nov 2026 15:47:47 -0500 Received: by mx1.catap.net (OpenSMTPD) id e5e3ad77; Thu, 26 Nov 2026 21:47:39 +0100 (CET) Received: from localhost (matebook.home.arpa [local]) by matebook.home.arpa (OpenSMTPD) with ESMTPA id 5ade4d50; Thu, 26 Nov 2026 21:47:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=20240125rsa; cv=none; d=mx.catap.net; b=Yx6IQTe eotRaK4ikWy4MfDVwY7SinNFObqUWK58Z7Fw9Wvk25xvkjIJ34SNDzp7OA23B2iA8elS0t W0+/Ah2rpPQg0ZqaE0qz3U6BgawkTXklqTq+T7DJ08ZtUThOj9f3Cg8EaD5nJR0GfQwRfB +jCQTBimUzgkvBt+RUQy/9QsW6E1rrSW8oN6qrMbpHmpnGQL5yfctXHw0xMu9AHGDnOsZV H+gjKhrpxYqNg4dgoSbGtSB/juWJRF+/9YBtrkA9wxkf0CchOfbTq0LXDpA8q/0VOGahbX 2CQdNwE2T7KmtRLkxbg0UpTO4ENBVL9CuIg1POCnE7lCqauJc9mpgcg== ARC-Message-Signature: i=1; a=rsa-sha256; s=20240125rsa; c=simple/simple; bh=t qHKdggepmmZrJE0AVlW5WOYWsdKBJQmRifm+0lrdj8=; h=references:in-reply-to: date:subject:cc:to:from:dkim-signature:dkim-signature; d=mx.catap.net; b=v+MQpWXXUWVTswQdXwJid4rxdfB6GIDJfbe35QxFjTmb4mOxWWwCMYUFSa7ZiKIITFsF EmVGICPEsGWTKtRzKr0tKFWZ5Q/TpLLul7SZHODvCbrWVl34UKMDKE0cC7PQ8VrnunhtAe 7qqweAMDeXJeoary7i2XydC3FPhbTtgsyZS2f5Qq7Ec8xQpRfy3Rnf4XIGneZm24o+Bmxc s7p7m02K1MGc0oQnklgQI6DwdFy/r/BtMTWH5HbwmvE5y4SUlUJCtsOLv0H7+E0hZFocbo pjWyUyXC3S74gI2OkQDkz0+0HmOjg31+3Y81rZv9qy1ipvy8zzQttRmh6DdFjZVQ== ARC-Authentication-Results: i=1; mx.catap.net; dkim=pass header.s=20240125rsa header.d=korins.ky header.a=rsa-sha256 header.b=khaoCYug; dkim=pass header.s=20240125ed25519 header.d=korins.ky header.a=ed25519-sha256 header.b=Yy7wiewc; arc=none; iprev=pass; spf=none smtp.helo=postmaster@matebook.home.arpa; spf=softfail smtp.mailfrom=kirill@korins.ky DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=20240125rsa; bh=tqHKdgge pmmZrJE0AVlW5WOYWsdKBJQmRifm+0lrdj8=; h=references:in-reply-to:date: subject:cc:to:from; d=korins.ky; b=khaoCYugWghREcIoNOqZ3MC8hIW0os1wS52 iPl0zs1LjxEsfjC3v83dKFJaAO9zW5NPzhG88cvAAz0/xNr3+wOBGhUjx5OvmZ5nuvODfb fcXUTiubqXdgaw+f8qyLFW8KCcoMCrfF1Cs5r1NVg0UrpXaK9DvP4ItAhJRlp/gDBKPUBm UOui9BQTieA1LBSBJjM9SNwvL8y1FdApOV7YM1FW0/PQF2v2RXjO66m5AkTMI+OAAA1Wqi ywEZbCdwlKrCV8GBoIJyZblRy5isuvbIlDVnCHpN5S7TcSITTUva7fmgZ5JjQb64WBJ8Pi IAeyHF0DbXoYuHJEpveSfyW4vqA== DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=20240125ed25519; bh=tqHKdggepmmZrJE0AVlW5WOYWsdKBJQmRifm+0lrdj8=; h=references: in-reply-to:date:subject:cc:to:from; d=korins.ky; b=Yy7wiewcIvz35lBfyH dFB52ev+dyIdjEN3+60A9dxr+a+TXmO3zl1MshTF5wD6i/04v2NvjU9jy1R0qy7/NwCQ== From: Kirill A. Korinsky To: Richard Henderson , Helge Deller , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org Cc: "Kirill A . Korinsky" Subject: [PATCH 3/3] target/hppa: Defer PA7300LC multiply assists Date: Thu, 26 Nov 2026 21:39:22 +0100 Message-ID: <20261126204733.9423-4-kirill@korins.ky> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126204733.9423-1-kirill@korins.ky> References: <20261126204733.9423-1-kirill@korins.ky> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=162.55.82.72; envelope-from=kirill@korins.ky; helo=mx1.catap.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1795726109238158500 Content-Type: text/plain; charset="utf-8" From: "Kirill A. Korinsky" With FPSR.D clear, PA7300LC defers FMPY, FMPYADD and FMPYSUB for certain denormal operands or a result that is tiny after rounding, including exact results that leave IEEE underflow clear. Detect tininess through SoftFloat's output flush flag on a scratch status. Evaluate both components of FMPYADD and FMPYSUB from the original operands. If either requires an assist, record the instruction in ER2 and set FPSR.T, preserving both destinations and the FPSR exception flags. OpenBSD/hppa's trig_test-3 takes its expected failure path when tanf encounters the assist, and the full msun regression passes with the original Makefile. Signed-off-by: Kirill A. Korinsky --- target/hppa/fpu_helper.c | 116 +++++++++++++++++++++++++++++++++++- target/hppa/helper.h | 6 ++ target/hppa/translate.c | 39 ++++++++++++ tests/qtest/hppa-fpu-test.c | 104 ++++++++++++++++++++++++++++++++ 4 files changed, 264 insertions(+), 1 deletion(-) diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c index 82ad6da34d..1255b4999c 100644 --- a/target/hppa/fpu_helper.c +++ b/target/hppa/fpu_helper.c @@ -240,7 +240,25 @@ float64 HELPER(frem_d)(CPUHPPAState *env, float64 a, f= loat64 b) #ifndef CONFIG_USER_ONLY static void defer_fp_unimplemented(CPUHPPAState *env, uint32_t insn) { - uint32_t code =3D (insn >> 26) =3D=3D 0x0c ? 0x09 : 0x0b; + uint32_t code; + + switch (insn >> 26) { + case 0x06: + code =3D 0x03; + break; + case 0x26: + code =3D 0x23; + break; + case 0x0c: + code =3D 0x09; + break; + case 0x0e: + code =3D 0x0b; + break; + default: + g_assert_not_reached(); + } + uint32_t record =3D deposit32(insn, 26, 6, code); =20 /* PA7300LC records the original operation in exception register 2. */ @@ -248,6 +266,102 @@ static void defer_fp_unimplemented(CPUHPPAState *env,= uint32_t insn) env->fr0_shadow |=3D R_FPSR_T_MASK; env->fr[0] =3D deposit64(env->fr[0], 32, 32, env->fr0_shadow); } + +static float_status pa1_multiply_status(CPUHPPAState *env) +{ + float_status status =3D env->fp_status; + + if (!(env->fr0_shadow & R_FPSR_D_MASK)) { + /* Identify tiny results even when IEEE underflow is not raised. */ + set_flush_to_zero(true, &status); + set_float_ftz_detection(float_ftz_after_rounding, &status); + } + return status; +} + +static bool pa1_multiply_needs_assist(CPUHPPAState *env, + const float_status *status, bool singl= e, + bool multiply, uint64_t a, uint64_t b) +{ + if (env->fr0_shadow & R_FPSR_D_MASK) { + return false; + } + if (get_float_exception_flags(status) & float_flag_output_denormal_flu= shed) { + return true; + } + + uint64_t sign_mask =3D single ? INT32_MAX : INT64_MAX; + uint64_t min_normal =3D single ? 0x00800000 : 0x0010000000000000ULL; + uint64_t infinity =3D single ? 0x7f800000 : 0x7ff0000000000000ULL; + + a &=3D sign_mask; + b &=3D sign_mask; + return (a !=3D 0 && a < min_normal && b !=3D infinity && + (!multiply || b !=3D 0)) || + (b !=3D 0 && b < min_normal && a !=3D infinity && + (!multiply || a !=3D 0)); +} + +static void pa1_multiply_write_result(CPUHPPAState *env, uint32_t reg, + bool single, uint64_t result, + const float_status *status, uintptr_= t ra) +{ + set_float_exception_flags(get_float_exception_flags(status), + &env->fp_status); + update_fr0_op(env, ra); + if (single) { + unsigned shift =3D reg & 32 ? 0 : 32; + + reg &=3D 31; + env->fr[reg] =3D deposit64(env->fr[reg], shift, 32, result); + } else { + env->fr[reg] =3D result; + } +} + +void HELPER(fmpy_pa1)(CPUHPPAState *env, uint64_t a, uint64_t b, + uint32_t reg, uint32_t insn) +{ + bool single =3D !extract32(insn, 11, 1); + float_status status =3D pa1_multiply_status(env); + uint64_t product =3D single ? float32_mul(a, b, &status) + : float64_mul(a, b, &status); + + if (pa1_multiply_needs_assist(env, &status, single, true, a, b)) { + defer_fp_unimplemented(env, insn); + return; + } + pa1_multiply_write_result(env, reg, single, product, &status, GETPC()); +} + +void HELPER(fmpyadd_pa1)(CPUHPPAState *env, uint64_t m1, uint64_t m2, + uint64_t a1, uint64_t a2, uint32_t regs, uint32_t = insn) +{ + bool single =3D extract32(insn, 5, 1); + bool subtract =3D (insn >> 26) =3D=3D 0x26; + float_status multiply_status =3D pa1_multiply_status(env); + float_status add_status =3D multiply_status; + uint64_t product, sum; + + if (single) { + product =3D float32_mul(m1, m2, &multiply_status); + sum =3D subtract ? float32_sub(a1, a2, &add_status) + : float32_add(a1, a2, &add_status); + } else { + product =3D float64_mul(m1, m2, &multiply_status); + sum =3D subtract ? float64_sub(a1, a2, &add_status) + : float64_add(a1, a2, &add_status); + } + + if (pa1_multiply_needs_assist(env, &multiply_status, single, true, m1,= m2) || + pa1_multiply_needs_assist(env, &add_status, single, false, a1, a2)= ) { + defer_fp_unimplemented(env, insn); + return; + } + pa1_multiply_write_result(env, regs & 63, single, product, + &multiply_status, GETPC()); + pa1_multiply_write_result(env, regs >> 6, single, sum, &add_status, GE= TPC()); +} #endif =20 void HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg, uint32_t reg, uint32= _t insn) diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 84937ee73f..a1d1dfffd8 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -24,6 +24,12 @@ DEF_HELPER_FLAGS_4(probe, TCG_CALL_NO_WG, tl, env, tl, i= 32, i32) =20 DEF_HELPER_FLAGS_1(loaded_fr0, TCG_CALL_NO_RWG, void, env) =20 +#ifndef CONFIG_USER_ONLY +DEF_HELPER_FLAGS_5(fmpy_pa1, TCG_CALL_NO_RWG, void, env, i64, i64, i32, i3= 2) +DEF_HELPER_FLAGS_7(fmpyadd_pa1, TCG_CALL_NO_RWG, void, env, i64, i64, i64,= i64, + i32, i32) +#endif + DEF_HELPER_FLAGS_2(fsqrt_s, TCG_CALL_NO_RWG, f32, env, f32) DEF_HELPER_FLAGS_2(frnd_s, TCG_CALL_NO_RWG, f32, env, f32) DEF_HELPER_FLAGS_3(fadd_s, TCG_CALL_NO_RWG, f32, env, f32, f32) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 67670768d1..c8e2b13c8c 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4519,11 +4519,27 @@ static bool trans_fsub_d(DisasContext *ctx, arg_fcl= ass3 *a) =20 static bool trans_fmpy_f(DisasContext *ctx, arg_fclass3 *a) { +#ifndef CONFIG_USER_ONLY + if (!ctx->is_pa20) { + fp_nullify_over(ctx); + gen_helper_fmpy_pa1(tcg_env, load_frw0_i64(a->r1), load_frw0_i64(a= ->r2), + tcg_constant_i32(a->t), tcg_constant_i32(ctx->= insn)); + return nullify_end(ctx); + } +#endif return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_fmpy_s); } =20 static bool trans_fmpy_d(DisasContext *ctx, arg_fclass3 *a) { +#ifndef CONFIG_USER_ONLY + if (!ctx->is_pa20) { + fp_nullify_over(ctx); + gen_helper_fmpy_pa1(tcg_env, load_frd0(a->r1), load_frd0(a->r2), + tcg_constant_i32(a->t), tcg_constant_i32(ctx->= insn)); + return nullify_end(ctx); + } +#endif return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fmpy_d); } =20 @@ -4575,6 +4591,18 @@ static bool do_fmpyadd_s(DisasContext *ctx, arg_mpya= dd *a, bool is_sub) int rm2 =3D fmpyadd_s_reg(a->rm2); int rm1 =3D fmpyadd_s_reg(a->rm1); =20 +#ifndef CONFIG_USER_ONLY + /* A zero addend field in FMPYADD encodes FMPYCFXT on PA7300LC. */ + if (!ctx->is_pa20 && (is_sub || a->ra !=3D 0)) { + fp_nullify_over(ctx); + gen_helper_fmpyadd_pa1(tcg_env, + load_frw0_i64(rm1), load_frw0_i64(rm2), + load_frw0_i64(ta), load_frw0_i64(ra), + tcg_constant_i32((ta << 6) | tm), + tcg_constant_i32(ctx->insn)); + return nullify_end(ctx); + } +#endif nullify_over(ctx); =20 do_fop_weww(ctx, tm, rm1, rm2, gen_helper_fmpy_s); @@ -4596,6 +4624,17 @@ static bool trans_fmpysub_f(DisasContext *ctx, arg_m= pyadd *a) =20 static bool do_fmpyadd_d(DisasContext *ctx, arg_mpyadd *a, bool is_sub) { +#ifndef CONFIG_USER_ONLY + if (!ctx->is_pa20 && (is_sub || a->ra !=3D 0)) { + fp_nullify_over(ctx); + gen_helper_fmpyadd_pa1(tcg_env, + load_frd0(a->rm1), load_frd0(a->rm2), + load_frd0(a->ta), load_frd0(a->ra), + tcg_constant_i32((a->ta << 6) | a->tm), + tcg_constant_i32(ctx->insn)); + return nullify_end(ctx); + } +#endif nullify_over(ctx); =20 do_fop_dedd(ctx, a->tm, a->rm1, a->rm2, gen_helper_fmpy_d); diff --git a/tests/qtest/hppa-fpu-test.c b/tests/qtest/hppa-fpu-test.c index f49d834e31..7ab28efc8a 100644 --- a/tests/qtest/hppa-fpu-test.c +++ b/tests/qtest/hppa-fpu-test.c @@ -510,6 +510,104 @@ static void test_fcnv(const void *opaque) qtest_quit(qts); } =20 +typedef struct FmpyAssistTest { + const char *name; + uint32_t instruction; + uint32_t er2; + uint64_t fr22; + uint64_t fr23; +} FmpyAssistTest; + +static const FmpyAssistTest fmpy_assist_tests[] =3D { + { + .name =3D "scalar-tiny", + .instruction =3D 0x33374617, /* fmpy,sgl fr25,fr23,fr23 */ + .er2 =3D 0x27374617, + .fr22 =3D 0xb79bae5f8cad057cULL, + .fr23 =3D 0x37d95384fd6b8987ULL, + }, + { + .name =3D "compound-trace", + .instruction =3D 0x19263a26, /* fmpyadd,sgl fr25,fr22,fr22,fr24,fr= 23 */ + .er2 =3D 0x0d263a26, + .fr22 =3D 0xb79bae5f8cad057cULL, + .fr23 =3D 0x004a1020fd6b8987ULL, + }, + { + .name =3D "compound-tiny", + .instruction =3D 0x19263a26, + .er2 =3D 0x0d263a26, + .fr22 =3D 0x380000008cad057cULL, /* Exact subnormal product. */ + .fr23 =3D 0x37d95384fd6b8987ULL, + }, + { + .name =3D "double-scalar-tiny", + .instruction =3D 0x33374e17, /* fmpy,dbl fr25,fr23,fr23 */ + .er2 =3D 0x27374e17, + .fr22 =3D 0xb79bae5f8cad057cULL, + .fr23 =3D 0x3850000000000000ULL, /* 2^-122. */ + }, + { + .name =3D "compound-subtract-tiny", + .instruction =3D 0x99263a26, /* fmpysub,sgl fr25,fr22,fr22,fr24,fr= 23 */ + .er2 =3D 0x8d263a26, + .fr22 =3D 0x380000008cad057cULL, + .fr23 =3D 0x37d95384fd6b8987ULL, + }, + { + .name =3D "compound-denormal", + .instruction =3D 0x19263a26, + .er2 =3D 0x0d263a26, + .fr22 =3D 0x3f8000008cad057cULL, /* Multiply by 1.0f. */ + .fr23 =3D 0x004a1020fd6b8987ULL, + }, +}; + +static void test_fmpy_assist(const void *opaque) +{ + const FmpyAssistTest *test =3D opaque; + const uint32_t guest[] =3D { + 0x34011000, /* ldi 0x800,r1 */ + 0x01c11840, /* mtctl r1,iva */ + 0x34103000, /* ldi 0x1800,r16 */ + 0x34113200, /* ldi 0x1900,r17 */ + 0x34010180, /* ldi 0xc0,r1 */ + 0x01411840, /* mtctl r1,ccr */ + 0x2e001016, /* fldd 0(r16),fr22 */ + 0x2e101017, /* fldd 8(r16),fr23 */ + 0x36100020, /* ldo 16(r16),r16 */ + 0x2e001018, /* fldd 0(r16),fr24 */ + 0x2e101019, /* fldd 8(r16),fr25 */ + test->instruction, + 0x2e001200, /* fstd fr0,0(r16) */ + 0x2e101201, /* fstd fr1,8(r16) */ + 0x36100020, /* ldo 16(r16),r16 */ + 0x2e001200, /* fstd fr0,0(r16) */ + 0x2e101216, /* fstd fr22,8(r16) */ + 0x36100020, /* ldo 16(r16),r16 */ + 0x2e001217, /* fstd fr23,0(r16) */ + 0x34010002, /* ldi 1,r1 */ + 0x6a210000, /* stw r1,0(r17): completion */ + }; + QTestState *qts =3D start_guest(false); + uint32_t end =3D CODE + sizeof(guest); + + write_words(qts, CODE, guest, G_N_ELEMENTS(guest)); + qtest_writel(qts, end, branch(end, HALT)); + qtest_writeq(qts, DATA, test->fr22); + qtest_writeq(qts, DATA + 8, test->fr23); + qtest_writeq(qts, DATA + 16, 0x3895c07a1110fe7aULL); + qtest_writeq(qts, DATA + 24, 0x07ae7c429facdab0ULL); + + run_guest(qts, 1); + g_assert_cmphex(qtest_readq(qts, DATA + 16), =3D=3D, 0x000000400000000= 0ULL); + g_assert_cmphex(qtest_readl(qts, DATA + 24), =3D=3D, test->er2); + g_assert_cmphex(qtest_readq(qts, DATA + 32), =3D=3D, 0); + g_assert_cmphex(qtest_readq(qts, DATA + 40), =3D=3D, test->fr22); + g_assert_cmphex(qtest_readq(qts, DATA + 48), =3D=3D, test->fr23); + qtest_quit(qts); +} + static const uint32_t fault_guest[] =3D { 0x34011000, /* ldi 0x800,r1 */ 0x01c11840, /* mtctl r1,iva */ @@ -586,6 +684,12 @@ int main(int argc, char **argv) =20 qtest_add_data_func(name, &fcnv_tests[i], test_fcnv); } + for (size_t i =3D 0; i < G_N_ELEMENTS(fmpy_assist_tests); i++) { + g_autofree char *name =3D g_strdup_printf("fpu/fmpy-assist/%s", + fmpy_assist_tests[i].name); + + qtest_add_data_func(name, &fmpy_assist_tests[i], test_fmpy_assist); + } for (size_t i =3D 0; i < G_N_ELEMENTS(fault_tests); i++) { g_autofree char *name =3D g_strdup_printf("fpu/%s", fault_tests[i]= .name); =20 --=20 2.56.1