NetBSD Problem Report #57821

From ryo@tetera.org  Fri Jan  5 21:50:18 2024
Return-Path: <ryo@tetera.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 E51931A9238
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  5 Jan 2024 21:50:17 +0000 (UTC)
Message-Id: <46b9c798063b97a9b8602e99adb71eb3.ryo@tetera.org>
Date: Sat, 06 Jan 2024 06:50:09 +0900
From: ryo@tetera.org
Reply-To: ryo@tetera.org
To: gnats-bugs@NetBSD.org
Subject: On some machines, NetBSD/amd64 cannot get correct century data
X-Send-Pr-Version: 3.95

>Number:         57821
>Category:       port-amd64
>Synopsis:       On some machines, NetBSD/amd64 cannot get correct century data
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 05 21:55:00 +0000 2024
>Last-Modified:  Sat Aug 03 00:35:00 +0000 2024
>Originator:     Ryo ONODERA
>Release:        NetBSD 10.99.10
>Organization:
Ryo ONODERA // ryo@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3
>Environment:


System: NetBSD castella 10.99.10 NetBSD 10.99.10 (DTRACE9) #0: Fri Jan 5 17:36:29 JST 2024 ryoon@castella:/usr/world/10.99/amd64/obj/sys/arch/amd64/compile/DTRACE9 amd64
Architecture: x86_64
Machine: amd64
>Description:
On HP Envy 13 ay1000, HP Pavilion Aero 13 be2000 and Hyper-V V2 virtual
machine on Microsoft Windows 11, NetBSD/amd64-current show as follows:

WARNING: NVRAM century is 51 but RTC year is 2024

The number, 51 may vary every boot.

>How-To-Repeat:
Boot NetBSD/amd64-current on the machines.

>Fix:

Apply the following patch:

Index: sys/arch/x86/isa/rtc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/isa/rtc.c,v
retrieving revision 1.2
diff -u -r1.2 rtc.c
--- sys/arch/x86/isa/rtc.c	30 Dec 2022 21:40:20 -0000	1.2
+++ sys/arch/x86/isa/rtc.c	4 Jan 2024 13:12:22 -0000
@@ -275,7 +275,7 @@

 	s = splclock();
 #if NACPICA > 0
-	if (acpi_active)
+	if (acpi_active && AcpiGbl_FADT.Century)
 		cmoscentury = mc146818_read(NULL,
 		    (centb = AcpiGbl_FADT.Century));
 	else


On these machines, AcpiGbl_FADT.Century is always 0.
And cmoscentury = mc146818_read(NULL, 0) returns undefined value.
If AcpiGbl_FADT.Century == 0, mc146818_read(NULL, NVRAM_CENTURY)
should be used for cmoscentury.

>Audit-Trail:
From: Ryo ONODERA <ryo@tetera.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-amd64/57821: On some machines, NetBSD/amd64 cannot get
 correct century data
Date: Thu, 01 Aug 2024 20:06:40 +0900

 Could anyone add comments about this PR?
 My new HP Envy 14 fa0000 laptop has the same problem too.

 -- 
 Ryo ONODERA // ryo@tetera.org
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

From: RVP <rvp@SDF.ORG>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-amd64/57821: On some machines, NetBSD/amd64 cannot get
 correct century data
Date: Sat, 3 Aug 2024 00:30:56 +0000 (UTC)

 On Thu, 1 Aug 2024, Ryo ONODERA wrote:

 > Could anyone add comments about this PR?
 >

 If you do make the change, could you also remove the NVRAM_DIAG check in
 startrtclock()? FreeBSD removed it ages ago:

 https://github.com/freebsd/freebsd-src/commit/2b89f1fc9e8b71154dba0bc5852a24751e411f5e

 It now only produces spurious errors like:

 ```
 [     1.000000] RTC BIOS diagnostic error 0xcb<clock_battery,ROM_cksum,fixed_disk>
 ```

 Thx,

 -RVP

>Unformatted:

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-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.