NetBSD Problem Report #50206
From mrg@eterna.com.au Fri Sep 4 09:41:49 2015
Return-Path: <mrg@eterna.com.au>
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 1BFF9A5864
for <gnats-bugs@gnats.NetBSD.org>; Fri, 4 Sep 2015 09:41:49 +0000 (UTC)
Message-Id: <20150904094144.6E12CB37E@splode.eterna.com.au>
Date: Fri, 4 Sep 2015 19:41:44 +1000 (AEST)
From: mrg@eterna.com.au
Reply-To: mrg@eterna.com.au
To: gnats-bugs@gnats.NetBSD.org
Subject: panic: mii_anar -- setting media for alc(4)
X-Send-Pr-Version: 3.95
>Number: 50206
>Category: kern
>Synopsis: panic: mii_anar -- setting media for alc(4)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: msaitoh
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Sep 04 09:45:00 +0000 2015
>Closed-Date: Mon Nov 16 06:20:47 +0000 2015
>Last-Modified: Thu Nov 21 14:05:00 +0000 2019
>Originator: matthew green
>Release: NetBSD 7.99.21
>Organization:
people's front against (bozotic) www (softwar foundation)
>Environment:
System: NetBSD splode.eterna.com.au 6.1_STABLE NetBSD 6.1_STABLE (_splode_) #3: Sun Jul 26 21:53:08 EST 2015 mrg@splode.eterna.com.au:/var/obj/sparc64/usr/src/sys/arch/sparc64/compile/_splode_ sparc64
Architecture: sparc64
Machine: sparc64
actually my kernel is an amd64 laptop, the above is my send-pr host.
>Description:
i installed -current kernel on an asus laptop with a recent alc(4)
chipset:
alc0 at pci3 dev 0 function 0: Atheros AR8162 PCIe Fast Ethernet
alc0: interrupting at ioapic0 pin 19
atphy0 at alc0 phy 0: Atheros AR8035 10/100/1000 PHY, rev. 9
i tried to run "ifconfig alc0 media 100baseTX mediaopt full-duplex"
and i got the following panic:
System panicked: mii_anar
Backtrace from time of crash is available.
crash> bt
_KERNEL_OPT_NVGA_RASTERCONSOLE() at 0
?() at fffffe807864fdd8
panic() at panic
snprintf() at snprintf
mii_anar() at mii_anar+0x17
atphy_service() at atphy_service+0x134
mii_mediachg() at mii_mediachg+0x31
ifmedia_ioctl() at ifmedia_ioctl+0x96
alc_ioctl() at alc_ioctl+0x3a
doifioctl() at doifioctl+0x56e
soo_ioctl() at soo_ioctl+0x23e
sys_ioctl() at sys_ioctl+0x253
syscall() at syscall+0xd2
--- syscall (number 54) ---
7f7ff6ccf7ba:
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: Masanobu SAITOH <msaitoh@execsw.org>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: msaitoh@execsw.org
Subject: Re: kern/50206: panic: mii_anar -- setting media for alc(4)
Date: Fri, 4 Sep 2015 19:27:48 +0900
On 2015/09/04 18:45, mrg@eterna.com.au wrote:
>> Number: 50206
>> Category: kern
>> Synopsis: panic: mii_anar -- setting media for alc(4)
>> Confidential: no
>> Severity: serious
>> Priority: medium
>> Responsible: kern-bug-people
>> State: open
>> Class: sw-bug
>> Submitter-Id: net
>> Arrival-Date: Fri Sep 04 09:45:00 +0000 2015
>> Originator: matthew green
>> Release: NetBSD 7.99.21
>> Organization:
> people's front against (bozotic) www (softwar foundation)
>> Environment:
> System: NetBSD splode.eterna.com.au 6.1_STABLE NetBSD 6.1_STABLE (_splode_) #3: Sun Jul 26 21:53:08 EST 2015 mrg@splode.eterna.com.au:/var/obj/sparc64/usr/src/sys/arch/sparc64/compile/_splode_ sparc64
> Architecture: sparc64
> Machine: sparc64
>
> actually my kernel is an amd64 laptop, the above is my send-pr host.
>
>> Description:
>
> i installed -current kernel on an asus laptop with a recent alc(4)
> chipset:
>
> alc0 at pci3 dev 0 function 0: Atheros AR8162 PCIe Fast Ethernet
> alc0: interrupting at ioapic0 pin 19
> atphy0 at alc0 phy 0: Atheros AR8035 10/100/1000 PHY, rev. 9
>
> i tried to run "ifconfig alc0 media 100baseTX mediaopt full-duplex"
> and i got the following panic:
>
> System panicked: mii_anar
> Backtrace from time of crash is available.
> crash> bt
> _KERNEL_OPT_NVGA_RASTERCONSOLE() at 0
> ?() at fffffe807864fdd8
> panic() at panic
> snprintf() at snprintf
> mii_anar() at mii_anar+0x17
> atphy_service() at atphy_service+0x134
> mii_mediachg() at mii_mediachg+0x31
> ifmedia_ioctl() at ifmedia_ioctl+0x96
> alc_ioctl() at alc_ioctl+0x3a
> doifioctl() at doifioctl+0x56e
> soo_ioctl() at soo_ioctl+0x23e
> sys_ioctl() at sys_ioctl+0x253
> syscall() at syscall+0xd2
> --- syscall (number 54) ---
> 7f7ff6ccf7ba:
>
>> How-To-Repeat:
>> Fix:
>
Could you try with the following diff?
I have no any atphy(4) device.
Index: atphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/atphy.c,v
retrieving revision 1.16
diff -u -r1.16 atphy.c
--- atphy.c 16 Jun 2014 12:36:41 -0000 1.16
+++ atphy.c 4 Sep 2015 10:26:43 -0000
@@ -228,7 +228,7 @@
return EINVAL;
}
- anar = mii_anar(ife->ifm_media);
+ anar = mii_anar(IFM_SUBTYPE(ife->ifm_media));
if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
bmcr |= BMCR_FDX;
/* Enable pause. */
--
-----------------------------------------------
SAITOH Masanobu (msaitoh@execsw.org
msaitoh@netbsd.org)
From: Leonardo Taccari <iamleot@gmail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/50206: panic: mii_anar -- setting media for alc(4)
Date: Fri, 04 Sep 2015 15:05:21 +0200
Hello Masanobu and matthew,
Masanobu SAITOH writes:
> Could you try with the following diff?
> I have no any atphy(4) device.
>
> Index: atphy.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/mii/atphy.c,v
> retrieving revision 1.16
> diff -u -r1.16 atphy.c
> --- atphy.c 16 Jun 2014 12:36:41 -0000 1.16
> +++ atphy.c 4 Sep 2015 10:26:43 -0000
> @@ -228,7 +228,7 @@
> return EINVAL;
> }
>
> - anar = mii_anar(ife->ifm_media);
> + anar = mii_anar(IFM_SUBTYPE(ife->ifm_media));
> if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
> bmcr |= BMCR_FDX;
> /* Enable pause. */
I can confirm that applying your patch fixes the issue!
I have first reproduced the problem, then applied the patch and tested
on another alc(4) chipset:
alc0 at pci2 dev 0 function 0: Atheros AR8171 PCIe Gigabit Ethernet
Thank you very much for the quick fix!
Ciao,
L.
From: matthew green <mrg@eterna.com.au>
To: Masanobu SAITOH <msaitoh@execsw.org>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: re: kern/50206: panic: mii_anar -- setting media for alc(4)
Date: Sat, 05 Sep 2015 05:45:34 +1000
> Could you try with the following diff?
> I have no any atphy(4) device.
>
> Index: atphy.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/mii/atphy.c,v
> retrieving revision 1.16
> diff -u -r1.16 atphy.c
> --- atphy.c 16 Jun 2014 12:36:41 -0000 1.16
> +++ atphy.c 4 Sep 2015 10:26:43 -0000
> @@ -228,7 +228,7 @@
> return EINVAL;
> }
>
> - anar = mii_anar(ife->ifm_media);
> + anar = mii_anar(IFM_SUBTYPE(ife->ifm_media));
> if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
> bmcr |= BMCR_FDX;
> /* Enable pause. */
thanks.
this stops the panic, but my alc(4) is dead in the water after
i've set any media it seems. aah, after setting back to
"autoselect" it does eventually regain the link (though this
takes a good 20+ seconds.)
so, this patch helps the original PR. please commit it and i
will file a PR on the new issues :)
.mrg.
From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: src/sys/dev/mii
Date: Tue, 8 Sep 2015 10:16:53 +0000
Module Name: src
Committed By: msaitoh
Date: Tue Sep 8 10:16:53 UTC 2015
Modified Files:
src/sys/dev/mii: atphy.c
Log Message:
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Masanobu SAITOH <msaitoh@execsw.org>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, mrg@eterna.com.au
Cc: msaitoh@execsw.org
Subject: Re: kern/50206: panic: mii_anar -- setting media for alc(4)
Date: Tue, 8 Sep 2015 19:17:32 +0900
On 2015/09/05 4:50, matthew green wrote:
> The following reply was made to PR kern/50206; it has been noted by GNATS.
>
> From: matthew green <mrg@eterna.com.au>
> To: Masanobu SAITOH <msaitoh@execsw.org>
> Cc: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
> gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> Subject: re: kern/50206: panic: mii_anar -- setting media for alc(4)
> Date: Sat, 05 Sep 2015 05:45:34 +1000
>
> > Could you try with the following diff?
> > I have no any atphy(4) device.
> >
> > Index: atphy.c
> > ===================================================================
> > RCS file: /cvsroot/src/sys/dev/mii/atphy.c,v
> > retrieving revision 1.16
> > diff -u -r1.16 atphy.c
> > --- atphy.c 16 Jun 2014 12:36:41 -0000 1.16
> > +++ atphy.c 4 Sep 2015 10:26:43 -0000
> > @@ -228,7 +228,7 @@
> > return EINVAL;
> > }
> >
> > - anar = mii_anar(ife->ifm_media);
> > + anar = mii_anar(IFM_SUBTYPE(ife->ifm_media));
> > if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
> > bmcr |= BMCR_FDX;
> > /* Enable pause. */
>
> thanks.
>
> this stops the panic, but my alc(4) is dead in the water after
> i've set any media it seems. aah, after setting back to
> "autoselect" it does eventually regain the link (though this
> takes a good 20+ seconds.)
>
> so, this patch helps the original PR. please commit it and i
> will file a PR on the new issues :)
Done and will be pulled up to netbsd-[567]
>
> .mrg.
>
>
--
-----------------------------------------------
SAITOH Masanobu (msaitoh@execsw.org
msaitoh@netbsd.org)
Responsible-Changed-From-To: kern-bug-people->msaitoh
Responsible-Changed-By: msaitoh@NetBSD.org
Responsible-Changed-When: Tue, 08 Sep 2015 10:42:56 +0000
Responsible-Changed-Why:
mine
State-Changed-From-To: open->pending-pullups
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Tue, 08 Sep 2015 11:01:24 +0000
State-Changed-Why:
pullup requests were sent.
From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-7] src/sys/dev/mii
Date: Wed, 4 Nov 2015 18:19:58 +0000
Module Name: src
Committed By: riz
Date: Wed Nov 4 18:19:58 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-7]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #971):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.2.1 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-7-0] src/sys/dev/mii
Date: Wed, 4 Nov 2015 18:21:07 +0000
Module Name: src
Committed By: riz
Date: Wed Nov 4 18:21:07 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-7-0]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #971):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.6.1 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-5] src/sys/dev/mii
Date: Sat, 7 Nov 2015 20:35:53 +0000
Module Name: src
Committed By: snj
Date: Sat Nov 7 20:35:53 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-5]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1978):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.5.2.2 -r1.5.2.3 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-5-1] src/sys/dev/mii
Date: Sat, 7 Nov 2015 20:36:42 +0000
Module Name: src
Committed By: snj
Date: Sat Nov 7 20:36:42 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-5-1]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1978):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
To generate a diff of this commit:
cvs rdiff -u -r1.5.2.2 -r1.5.2.2.2.1 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-5-2] src/sys/dev/mii
Date: Sat, 7 Nov 2015 20:37:09 +0000
Module Name: src
Committed By: snj
Date: Sat Nov 7 20:37:09 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-5-2]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1978):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
To generate a diff of this commit:
cvs rdiff -u -r1.5.2.2 -r1.5.2.2.6.1 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-6] src/sys/dev/mii
Date: Sun, 15 Nov 2015 17:45:44 +0000
Module Name: src
Committed By: bouyer
Date: Sun Nov 15 17:45:44 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-6]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1325):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.11.8.2 -r1.11.8.3 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-6-0] src/sys/dev/mii
Date: Sun, 15 Nov 2015 17:45:50 +0000
Module Name: src
Committed By: bouyer
Date: Sun Nov 15 17:45:50 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-6-0]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1325):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.12.1 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: [netbsd-6-1] src/sys/dev/mii
Date: Sun, 15 Nov 2015 17:45:59 +0000
Module Name: src
Committed By: bouyer
Date: Sun Nov 15 17:45:59 UTC 2015
Modified Files:
src/sys/dev/mii [netbsd-6-1]: atphy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1325):
sys/dev/mii/atphy.c: revision 1.17
Fix incorrect argument of mii_anar(). Fixes PR#50206.
XXX pullup -[567]
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.14.1 src/sys/dev/mii/atphy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Mon, 16 Nov 2015 06:20:47 +0000
State-Changed-Why:
Pulled up.
Thanks.
From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50206 CVS commit: src/sys/dev/mii
Date: Wed, 20 Nov 2019 08:51:00 +0000
Module Name: src
Committed By: msaitoh
Date: Wed Nov 20 08:51:00 UTC 2019
Modified Files:
src/sys/dev/mii: atphy.c mii_physubr.c miivar.h
Log Message:
Fix a bug that atphy(4) can't negotiate correctly when the media setting is
neither auto nor 1000baseT. Use correct index for mii_media_table[].
History: mii_anar() is first added in OpenBSD and ported to NetBSD. On NetBSD,
only atphy(4) use this function. mii_physubr.c rev. 1.75 changed mii_anar()
for simplify. It changed the argument from the ifmedia word to ifm_data used
in our MII API, but the caller have not been changed. And then, PR kern/50206
was reported and the caller was modified by me to prevent panic but it was not
correct fix.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.87 -r1.88 src/sys/dev/mii/mii_physubr.c
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/mii/miivar.h
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/50206 CVS commit: [netbsd-9] src/sys/dev/mii
Date: Thu, 21 Nov 2019 14:00:49 +0000
Module Name: src
Committed By: martin
Date: Thu Nov 21 14:00:49 UTC 2019
Modified Files:
src/sys/dev/mii [netbsd-9]: atphy.c mii_physubr.c miivar.h
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #459):
sys/dev/mii/atphy.c: revision 1.23
sys/dev/mii/atphy.c: revision 1.25
sys/dev/mii/miivar.h: revision 1.69
sys/dev/mii/mii_physubr.c: revision 1.88
s/etphy/atphy/. No functional change.
Fix a bug that atphy(4) can't negotiate correctly when the media setting is
neither auto nor 1000baseT. Use correct index for mii_media_table[].
History: mii_anar() is first added in OpenBSD and ported to NetBSD. On NetBSD,
only atphy(4) use this function. mii_physubr.c rev. 1.75 changed mii_anar()
for simplify. It changed the argument from the ifmedia word to ifm_data used
in our MII API, but the caller have not been changed. And then, PR kern/50206
was reported and the caller was modified by me to prevent panic but it was not
correct fix.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.87 -r1.87.4.1 src/sys/dev/mii/mii_physubr.c
cvs rdiff -u -r1.68 -r1.68.4.1 src/sys/dev/mii/miivar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.45 2018/12/21 14:23:33 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.