NetBSD Problem Report #49104
From jarle@darling.urc.uninett.no Tue Aug 12 13:51:40 2014
Return-Path: <jarle@darling.urc.uninett.no>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1D708ACE15
for <gnats-bugs@gnats.NetBSD.org>; Tue, 12 Aug 2014 13:51:40 +0000 (UTC)
Message-Id: <20140812135130.E650AA83E@darling.urc.uninett.no>
Date: Tue, 12 Aug 2014 15:51:29 +0200 (CEST)
From: jarle@uninett.no
Reply-To: jarle@uninett.no
To: gnats-bugs@NetBSD.org
Subject: panic in cpu_init() on real i486 processor
X-Send-Pr-Version: 3.95
>Number: 49104
>Category: port-i386
>Synopsis: panic in cpu_init on real i486 processor
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: port-i386-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 12 13:55:00 +0000 2014
>Closed-Date: Wed Jan 14 05:28:02 +0000 2015
>Last-Modified: Wed Jan 14 05:28:02 +0000 2015
>Originator: Jarle Greipsland
>Release: NetBSD 6.99.47 (source from 2014-07-22)
>Organization:
>Environment:
System: NetBSD darling.urc.uninett.no 6.99.28 NetBSD 6.99.28 (DARLING) #0: Thu Jan 2 20:17:15 CET 2014 jarle@darling.urc.uninett.no:/usr/obj/sys/arch/i386/compile/DARLING i386
Architecture: i386
Machine: i386
>Description:
I tried to boot a 6.99.47 kernel on my trusty old i486 system, but the
kernel paniced early in the autoconf process.
The kernel messages (copied by hand):
...
total memory = 127 MB
avail memory = 121 MB
mainbus0 (root)
cpu0 at mainbus0fatal privileged instruction fault in supervisor mode
trap type 0 code 0 eip c012e570 cs c0490008 eflags 10282 cr2 0 ilevel 8 esp c012c543
curlwp 0xc04584c0 pid 0 lid 1 lowest kstack 0xc05022c0
kernel: supervisor trap privileged instruction fault, code=0
stopped in pid 0.1 (system) at netbsd:rcr4: movl %cr4, %eax
A backtrace shows the call stack as (partial):
rcr4 <- cpu_init <- cpu_attach <- config_attach <- "more autoconf goop"
I believe the problem to be the introduction of unconditional calls to
rcr4() in cpu_init() in revision 1.110 of sys/arch/x86/x86/cpu.c. The
Intel 486 series of processors do not have a CR4 register, and thus
the attempt to read said register causes the processor trap and
subsequent kernel panic.
>How-To-Repeat:
Try to run a current kernel on a real i486 series processor.
>Fix:
>Release-Note:
>Audit-Trail:
From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-i386/49104: panic in cpu_init() on real i486 processor
Date: Fri, 15 Aug 2014 07:12:53 -0500 (CDT)
I'm seeing something similar on my Soekris net4501:
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
NetBSD 7.99.1 (NET4501) #1: Wed Aug 13 12:14:29 CDT 2014
sysop@verthandi.technoskunk.fur:/d0/build/current/obj/i386/sys/arch/i386/compile/NET4501
total memory = 65148 KB
avail memory = 59884 KB
fatal privileged instruction fault in supervisor mode
trap type 0 code 0 eip c0155690 cs 8 eflags 10286 cr2 0 ilevel 8 esp c02164d8
curlwp 0xc03dd9a0 pid 0 lid 1 lowest kstack 0xc04ff2c0
kernel: supervisor trap privileged instruction fault, code=0
Stopped in pid 0.1 (system) at netbsd:cpu_counter32: rdtsc
db{0}> bt
cpu_counter32(c03f135a,2,6,0,c04fe00c,504000,c0500fa0,c030b5b9,5,0) at netbsd:cp
u_counter32
rnd_init(5,0,0,ffff,c04fe00c,4fe000,504000,0,c01002de,0) at netbsd:rnd_init+0x2b
[machine reboots]
In this case, I think it is a change made in the last week or so as I
recently booted a 6.99.49 kernel without problems. Just for completeness,
I'll try a GENERIC kernel as well.
--
|/"\ John D. Baker, KN5UKS NetBSD Darwin/MacOS X
|\ / jdbaker[snail]mylinuxisp[flyspeck]com OpenBSD FreeBSD
| X No HTML/proprietary data in email. BSD just sits there and works!
|/ \ GPGkeyID: D703 4A7E 479F 63F8 D3F4 BD99 9572 8F23 E4AD 1645
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49104 CVS commit: src/sys/kern
Date: Thu, 8 Jan 2015 11:13:07 -0500
Module Name: src
Committed By: christos
Date: Thu Jan 8 16:13:07 UTC 2015
Modified Files:
src/sys/kern: kern_rndq.c
Log Message:
PR/49104: Jarle Greipsland: Don't use cpu_counter32() unconditionally.
XXX: pullup-7
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/kern/kern_rndq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49104 CVS commit: [netbsd-7] src/sys/kern
Date: Fri, 9 Jan 2015 14:06:55 +0000
Module Name: src
Committed By: martin
Date: Fri Jan 9 14:06:55 UTC 2015
Modified Files:
src/sys/kern [netbsd-7]: kern_rndq.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #397):
sys/kern/kern_rndq.c: revision 1.29
PR 49104: Jarle Greipsland: Don't use cpu_counter32() unconditionally.
PR 49124: Soekris net4501 panics during boot after merge of "tls-earlyentropy" to HEAD
To generate a diff of this commit:
cvs rdiff -u -r1.26.2.2 -r1.26.2.3 src/sys/kern/kern_rndq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Jarle Greipsland <jarle@uninett.no>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: PR/49104 CVS commit: src/sys/kern
Date: Mon, 12 Jan 2015 11:46:55 +0100 (CET)
"Christos Zoulas" <christos@netbsd.org> writes:
> The following reply was made to PR port-i386/49104; it has been noted by GNATS.
>
> From: "Christos Zoulas" <christos@netbsd.org>
> To: gnats-bugs@gnats.NetBSD.org
> Cc:
> Subject: PR/49104 CVS commit: src/sys/kern
> Date: Thu, 8 Jan 2015 11:13:07 -0500
>
> Module Name: src
> Committed By: christos
> Date: Thu Jan 8 16:13:07 UTC 2015
>
> Modified Files:
> src/sys/kern: kern_rndq.c
>
> Log Message:
> PR/49104: Jarle Greipsland: Don't use cpu_counter32() unconditionally.
> XXX: pullup-7
Unfortunately, this only fixes the second bug in PR49104, where
cpu_counter32 is called. The original problem still persists,
i.e. where cpu_init unconditionally calls the rcr4 function.
-jarle
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, port-i386-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, jarle@uninett.no
Cc:
Subject: Re: PR/49104 CVS commit: src/sys/kern
Date: Mon, 12 Jan 2015 09:15:58 -0500
On Jan 12, 10:50am, jarle@uninett.no (Jarle Greipsland) wrote:
-- Subject: Re: PR/49104 CVS commit: src/sys/kern
| Unfortunately, this only fixes the second bug in PR49104, where
| cpu_counter32 is called. The original problem still persists,
| i.e. where cpu_init unconditionally calls the rcr4 function.
Does this fix the problem?
Index: cpu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/cpu.c,v
retrieving revision 1.111
diff -u -u -r1.111 cpu.c
--- cpu.c 12 May 2014 11:56:02 -0000 1.111
+++ cpu.c 12 Jan 2015 14:15:22 -0000
@@ -552,11 +552,10 @@
void
cpu_init(struct cpu_info *ci)
{
- uint32_t cr4;
+ uint32_t cr4 = 0;
lcr0(rcr0() | CR0_WP);
- cr4 = rcr4();
/*
* On a P6 or above, enable global TLB caching if the
* hardware supports it.
@@ -581,7 +580,10 @@
if (cpu_feature[1] & CPUID2_XSAVE)
cr4 |= CR4_OSXSAVE;
- lcr4(cr4);
+ if (cr4) {
+ cr4 |= rcr4();
+ lcr4(cr4);
+ }
/* If xsave is enabled, enable all fpu features */
if (cr4 & CR4_OSXSAVE)
From: Jarle Greipsland <jarle@uninett.no>
To: gnats-bugs@NetBSD.org
Cc: christos@zoulas.com
Subject: Re: PR/49104 CVS commit: src/sys/kern
Date: Mon, 12 Jan 2015 16:32:34 +0100 (CET)
christos@zoulas.com (Christos Zoulas) writes:
> On Jan 12, 10:50am, jarle@uninett.no (Jarle Greipsland) wrote:
> -- Subject: Re: PR/49104 CVS commit: src/sys/kern
>
> | Unfortunately, this only fixes the second bug in PR49104, where
> | cpu_counter32 is called. The original problem still persists,
> | i.e. where cpu_init unconditionally calls the rcr4 function.
>
> Does this fix the problem?
>
> Index: cpu.c
> ===================================================================
> RCS file: /cvsroot/src/sys/arch/x86/x86/cpu.c,v
> retrieving revision 1.111
> diff -u -u -r1.111 cpu.c
> --- cpu.c 12 May 2014 11:56:02 -0000 1.111
> +++ cpu.c 12 Jan 2015 14:15:22 -0000
[ ... ]
Much better! With this patch applied, it boots all the way to
multi-user state.
-jarle
--
"The Knights who say "LETNi" demand... A SEGMENT REGISTER!!!"
"A what?"
"LETNi! LETNi! LETNi!"
-- 1983 (uhclem@nemesis.uucp)
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49104 CVS commit: src/sys/arch/x86/x86
Date: Mon, 12 Jan 2015 11:34:39 -0500
Module Name: src
Committed By: christos
Date: Mon Jan 12 16:34:39 UTC 2015
Modified Files:
src/sys/arch/x86/x86: cpu.c
Log Message:
PR/49104: Jarle Greipsland: Don't touch cr4 in cpus that don't have it.
XXX: pullup-7
To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/x86/x86/cpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, port-i386-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, jarle@uninett.no
Cc:
Subject: Re: PR/49104 CVS commit: src/sys/kern
Date: Mon, 12 Jan 2015 11:35:14 -0500
On Jan 12, 3:35pm, jarle@uninett.no (Jarle Greipsland) wrote:
-- Subject: Re: PR/49104 CVS commit: src/sys/kern
| Much better! With this patch applied, it boots all the way to
| multi-user state.
Excellent, I've committed the change and I will ask for a pullup.
christos
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49104 CVS commit: [netbsd-7] src/sys/arch/x86/x86
Date: Mon, 12 Jan 2015 21:06:42 +0000
Module Name: src
Committed By: snj
Date: Mon Jan 12 21:06:42 UTC 2015
Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: cpu.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #414):
sys/arch/x86/x86/cpu.c: revision 1.113
PR/49104: Jarle Greipsland: Don't touch cr4 in cpus that don't have it.
To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.111.2.1 src/sys/arch/x86/x86/cpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Wed, 14 Jan 2015 05:28:02 +0000
State-Changed-Why:
Fixed and pulled up.
Thanks.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.