On 7.12.2017. 12:59, Martin Pieuchot wrote:
> If believe em_init() should only be called if IFF_RUNNING is still set.
>
> If you agree on that we should generalize this fix.
>
> Index: if_em.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_em.c,v
> retrieving revision 1.336
> diff -u -p -r1.336 if_em.c
> --- if_em.c 25 Jul 2017 20:45:18 -0000 1.336
> +++ if_em.c 7 Dec 2017 11:56:19 -0000
> @@ -775,7 +775,8 @@ em_watchdog(struct ifnet *ifp)
> sc->sc_tx_desc_head, sc->sc_tx_desc_tail,
> E1000_READ_REG(&sc->hw, TDH), E1000_READ_REG(&sc->hw, TDT));
>
> - em_init(sc);
> + if (ifp->if_flags & IFF_RUNNING)
> + em_init(sc);
>
> sc->watchdog_events++;
> }
>
>
I can trigger panic with this diff.
panic: kernel diagnostic assertion "(ifp->if_flags & IFF_RUNNING) == 0"
failed: file "/usr/src/sys/dev/pci/if_em.c", line 1535
Stopped at db_enter+0x5: popq %rbp
TID PID UID PRFLAGS PFLAGS CPU COMMAND
50843 8817 0 0x3 0 1 ifconfig
*338066 90412 0 0x14000 0x200 2K softnet
db_enter() at db_enter+0x5
panic() at panic+0x141
__assert(ffffffff81150c64,ffff800023bc47b0,0,ffff800000504000) at
__assert+0x24
em_stop(ffff800000504000,7) at em_stop+0x118
em_init(ffff800000504048) at em_init+0x25
em_watchdog(0) at em_watchdog+0xd1
if_watchdog_task(ffffffff812739a0) at if_watchdog_task+0xa4
taskq_thread(0) at taskq_thread+0x67
end trace frame: 0x0, count: 7
https://www.openbsd.org/ddb.html describes the minimum info required in
bug reports. Insufficient info makes it difficult to find and fix bugs.
ddb{2}>
ddb{2}> tr /up 0t50843
ffff800023cbddf0(ffffffff81b620f8,0,0,0,80000,1) at 0xffff800023cbddf0
end(uvm_fault(0xffffffff81bc3e20, 0xfffffffffffffff7, 0, 1) -> e
kernel: page fault trap, code=0
Faulted in DDB; continuing...
ddb{2}> tr /p 0t338066
em_devices(32202d206c6961,76615f78743e2d72,7874203d3c207367,65736e5f6d643e2d,70
616d000a212159,4c4554414944454d) at em_devices+0x31c
end of kernel
end trace frame: 0x66693e2d70666928, count: -1
ddb{2}>
ddb{2}> ps
PID TID PPID UID S FLAGS WAIT COMMAND
8817 50843 79736 0 7 0x3 ifconfig
79736 119474 42105 0 3 0x10008b pause sh
42105 75698 16540 0 3 0x10008b pause sh
16540 320225 1 0 3 0x10008b pause ksh
54705 58304 1 0 3 0x100083 ttyin getty
41445 395618 1 0 3 0x100083 ttyin getty
88810 517178 1 0 3 0x100083 ttyin getty
52690 519169 1 0 3 0x100083 ttyin getty
3983 159805 1 0 3 0x100083 ttyin ksh
47350 520409 1 0 3 0x100098 poll cron
58260 219793 77159 95 3 0x100092 kqread smtpd
2918 96352 77159 103 3 0x100092 kqread smtpd
59125 109489 77159 95 3 0x100092 kqread smtpd
91419 460387 77159 95 3 0x100092 kqread smtpd
95750 198350 77159 95 3 0x100092 kqread smtpd
48556 476067 77159 95 3 0x100092 kqread smtpd
77159 424577 1 0 3 0x100080 kqread smtpd
33691 342227 1 0 3 0x80 select sshd
9650 280076 46550 83 3 0x100092 poll ntpd
46550 214882 42207 83 3 0x100092 poll ntpd
42207 103275 1 0 3 0x100080 poll ntpd
27844 173279 23248 73 3 0x100010 ffs_fsync syslogd
23248 210379 1 0 3 0x100082 netio syslogd
69936 360819 0 0 3 0x14200 pgzero zerothread
16075 359676 0 0 3 0x14200 aiodoned aiodoned
49523 31272 0 0 3 0x14200 syncer update
10518 40696 0 0 3 0x14200 cleaner cleaner
99276 218425 0 0 3 0x14200 reaper reaper
35338 47452 0 0 3 0x14200 pgdaemon pagedaemon
51139 188699 0 0 3 0x14200 bored crynlk
39319 332427 0 0 3 0x14200 bored crypto
80252 394584 0 0 3 0x14200 usbtsk usbtask
48071 62837 0 0 3 0x14200 usbatsk usbatsk
32481 237123 0 0 3 0x40014200 acpi0 acpi0
85846 447770 0 0 7 0x40014200 idle11
81457 162415 0 0 7 0x40014200 idle10
16117 94980 0 0 7 0x40014200 idle9
18266 380698 0 0 7 0x40014200 idle8
90780 430964 0 0 7 0x40014200 idle7
10227 221054 0 0 7 0x40014200 idle6
17559 128633 0 0 7 0x40014200 idle5
65429 320888 0 0 7 0x40014200 idle4
48145 270662 0 0 7 0x40014200 idle3
6948 407710 0 0 3 0x40014200 idle2
90544 325413 0 0 3 0x40014200 idle1
94114 101917 0 0 3 0x14200 bored sensors
*90412 338066 0 0 7 0x14200 softnet
95449 344628 0 0 3 0x14200 bored systqmp
93814 150572 0 0 3 0x14200 bored systq
49337 366977 0 0 3 0x40014200 bored softclock
45367 148628 0 0 7 0x40014200 idle0
88971 422009 0 0 3 0x14200 bored sbar
1 73555 0 0 3 0x82 wait init
0 0 -1 0 3 0x10200 scheduler swapper
ddb{2}>