NetBSD Problem Report #56528

From gson@gson.org  Mon Nov 29 11:37:58 2021
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 154261A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 29 Nov 2021 11:37:58 +0000 (UTC)
Message-Id: <20211129113748.9EEBE254286@guava.gson.org>
Date: Mon, 29 Nov 2021 13:37:48 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: x86_fpregs_fpu_write, x86_xstate_fpu_write test cases fail
X-Send-Pr-Version: 3.95

>Number:         56528
>Category:       port-i386
>Synopsis:       x86_fpregs_fpu_write, x86_xstate_fpu_write test cases fail
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 29 11:40:00 +0000 2021
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current
>Organization:
>Environment:
System: NetBSD
Architecture: i386
Machine: i386
>Description:

When I run the ATF tests on NetBSD/i386 under "qemu -accel nvmm" on my
own testbed, the x86_fpregs_fpu_write and x86_xstate_fpu_write test
cases of multiple lib/libc/sys/t_ptrace_wait* tests fail, and have
done so ever since the tests in case were created.  Logs from a recent
failure are here:

  https://www.gson.org/netbsd/bugs/build/i386/2021/2021.11.28.10.01.36/test.html#failed-tcs-summary

The error messages is:

  t_ptrace_wait: /tmp/build/2021.11.28.10.01.36-i386/src/tests/lib/libc/sys/t_ptrace_x86_wait.h:3327 x86_register_test(): Assertion failed for: vals_fpu.ip.fa_64 == expected_fpu.ip.fa_64: Undefined error: 0

Strangely, they do not fail on the TNF testbed even though it's a fairly
similar setup.  Some of the differences are:

  My testbed:  NetBSD/amd64 9.2, qemu-6.1.0nb4, Intel Xeon E5-2678 v3
  TNF testbed: NetBSD/amd64 9.0_STABLE, qemu-6.0.0nb2, AMD EPYC 7402P

To see the unexpectedly-unequal values, I applied this patch:

Index: t_ptrace_x86_wait.h
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/sys/t_ptrace_x86_wait.h,v
retrieving revision 1.31
diff -u -r1.31 t_ptrace_x86_wait.h
--- t_ptrace_x86_wait.h	27 Oct 2020 08:32:36 -0000	1.31
+++ t_ptrace_x86_wait.h	29 Nov 2021 11:25:49 -0000
@@ -3324,8 +3324,8 @@
 				FORKEE_ASSERT(vals_fpu.tw == expected_fpu.tw);
 				FORKEE_ASSERT(vals_fpu.tw_abridged
 				    == expected_fpu.tw_abridged);
-				FORKEE_ASSERT(vals_fpu.ip.fa_64
-				    == expected_fpu.ip.fa_64);
+				FORKEE_ASSERT_EQ(vals_fpu.ip.fa_64,
+				    expected_fpu.ip.fa_64);
 				FORKEE_ASSERT(vals_fpu.dp.fa_64
 				    == expected_fpu.dp.fa_64);

This gives a slightly more informative error message:

  t_ptrace_wait: /tmp/build/2021.11.28.10.01.36-i386-run-000033/src/tests/lib/libc/sys/t_ptrace_x86_wait.h:3327 x86_register_test(): Assertion failed for: vals_fpu.ip.fa_64(1985229328) == expected_fpu.ip.fa_64(11649936536080)

Converting the values to hex:

  (gdb) print /x 1985229328
  $1 = 0x76543210
  (gdb) print /x 11649936536080
  $2 = 0xa9876543210

it looks like the top half of the 64-bit value is being unexpectedly cleared.

>How-To-Repeat:

>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.