NetBSD Problem Report #59312

From www@netbsd.org  Thu Apr 17 14:07:12 2025
Return-Path: <www@netbsd.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)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D33E11A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 17 Apr 2025 14:07:12 +0000 (UTC)
Message-Id: <20250417140711.9AE431A923D@mollari.NetBSD.org>
Date: Thu, 17 Apr 2025 14:07:11 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: t_timerfd tests are failing because isQEMU is broken
X-Send-Pr-Version: www-1.0

>Number:         59312
>Category:       port-sparc64
>Synopsis:       t_timerfd tests are failing because isQEMU is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 17 14:10:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The SparqemuBSD Lostation
>Environment:
>Description:
Test case: lib/libc/sys/t_timerfd/timerfd_abstime

Duration: 2.120843 seconds
Termination reason

FAILED: /tmp/build/2025.04.16.12.05.52-sparc64/src/tests/lib/libc/sys/t_timerfd.c:411: then=7816.751641753 now=7818.759207383 delta=2.007565630
Standard output stream

val 2 not in [ 1, 1 ]

Test case: lib/libc/sys/t_timerfd/timerfd_repeating

Duration: 2.116827 seconds
Termination reason

FAILED: /tmp/build/2025.04.16.12.05.52-sparc64/src/tests/lib/libc/sys/t_timerfd.c:362: check_value_against_bounds(val, 3, 5) not met
Standard output stream

val 10 not in [ 3, 5 ]

https://releng.netbsd.org/b5reports/sparc64/2025/2025.04.16.12.05.52/test.html#lib_libc_sys_t_timerfd_timerfd_abstime

These tests are supposed to have some slop for qemu:

     83 	/*
     84 	 * If running under QEMU make sure the upper bound is large
     85 	 * enough for the effect of kern/43997
     86 	 */
     87 	if (isQEMU()) {
     88 		upper *= 4;
     89 	}

https://nxr.netbsd.org/xref/src/tests/lib/libc/sys/t_timerfd.c?r=1.12#83

But the output shows the slop is not getting applied, so presumably isQEMU is not working.

The definition relies on detecting a qemufwcfg0 autoconf instance with drvctl(4):

     46 static __inline bool
     47 isQEMU(void) {
     48        struct devlistargs dla = {
     49 	       .l_devname = "qemufwcfg0",
     50 	       .l_childname = NULL,
     51 	       .l_children = 0,
     52        };
     53        int fd = open(DRVCTLDEV, O_RDONLY, 0);
     54        if (fd == -1)
     55 	       return false;
     56        if (ioctl(fd, DRVLISTDEV, &dla) == -1) {
     57 	       close(fd);
     58 	       return false;
     59        }
     60        close(fd);
     61        return true;
     62 }

https://nxr.netbsd.org/xref/src/tests/lib/libc/gen/isqemu.h?r=1.6#46

But it looks like sparc64 doesn't have a qemufwcfg* attachment at all.  On x86, arm, and riscv, it attaches via acpi or fdt, but there's no acpi or fdt on sparc/sparc64.

Curiously, the tests don't seem to be failing on 32-bit sparc, even though it doesn't have qemufwcfg* either.
>How-To-Repeat:
Under qemu-system-sparc64:

>Fix:
Either:

1. find how to attach qemufwcfg(4) on sparc64, or
2. find another way to detect qemu in tests on sparc64, or
3. implement proper high-resolution timers.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.