Subject: Re: Wavelan (wi) card fails in Z50: Kernel Panic
To: DP <dp@recycled.net>
From: Castor Fu <castor@geocast.com>
List: port-hpcmips
Date: 12/09/2000 10:38:20
Try changing 

	/* nwid is pointed at by ifr.ifr_data */
	struct ieee80211_nwid {
		u_int8_t        i_len;
		u_int8_t        i_nwid[IEEE80211_NWID_LEN]; 
	};

to
	/* nwid is pointed at by ifr.ifr_data */
	struct ieee80211_nwid {
		u_int16_t        i_len;
		u_int8_t        i_nwid[IEEE80211_NWID_LEN]; 
	};

in net/if_ieee80211.h.

I think that should fix it by making the structures align properly.
It's somewhat ad-hoc.  I hope people think it's a reasonable thing to do.


On Sat, 9 Dec 2000, DP wrote:

> Date: Sat, 09 Dec 2000 11:33:33 -0600 (CST)
> From: DP <dp@recycled.net>
> To: Castor Fu <castor@geocast.com>
> Subject: Re: Wavelan (wi) card fails in Z50: Kernel Panic
> 
> Here we go... serial console helps things greatly. :)
> Still want the kernel? It's at http://www.recycled.net/tmp/netbsd.wi.test.gz
> 
> Thanks,
> 
> dan
> 
> db> x/i 0x8017f0d0,80
> 0x8017f0d0:     addiu   sp,sp,-56
> 0x8017f0d4:     sw      s4,32(sp)
> 0x8017f0d8:     lw      s4,72(sp)
> 0x8017f0dc:     sw      s3,28(sp)
> 0x8017f0e0:     move    s3,a0
> 0x8017f0e4:     sw      s6,40(sp)
> 0x8017f0e8:     move    s6,a1
> 0x8017f0ec:     sw      s5,36(sp)
> 0x8017f0f0:     move    s5,a2
> 0x8017f0f4:     sw      s7,44(sp)
> 0x8017f0f8:     move    s7,a3
> 0x8017f0fc:     sw      ra,48(sp)
> 0x8017f100:     sw      s2,24(sp)
> 0x8017f104:     sw      s1,20(sp)
> 0x8017f108:     sw      s0,16(sp)
> 0x8017f10c:     move    a0,s3
> 0x8017f110:     move    a1,s6
> 0x8017f114:     move    a2,s5
> 0x8017f118:     jal     0x8017ef1c
>                 bdslot: 0x8017f11c:     li      a3,54
> 0x8017f120:     bne     v0,zero,0x8017f1e4
>                 bdslot: 0x8017f124:     li      v0,5
> 0x8017f128:     sra     s2,s4,31
> 0x8017f12c:     subu    v0,s4,s2
> 0x8017f130:     sra     v0,v0,1
> 0x8017f134:     blez    v0,0x8017f16c
>                 bdslot: 0x8017f138:     move    s1,zero
> 0x8017f13c:     move    s0,s7
> 0x8017f140:     lw      v0,344(s3)
> 0x8017f144:     lhu     v1,0(s0)
> 0x8017f148:     sh      v1,54(v0)
> 0x8017f14c:     jal     0x80031be8
>                 bdslot: 0x8017f150:     addiu   s0,s0,2
> 0x8017f154:     addiu   s1,s1,1
> 0x8017f158:     subu    v0,s4,s2
> 0x8017f15c:     sra     v0,v0,1
> 0x8017f160:     slt     v0,s1,v0
> 0x8017f164:     bnel    v0,zero,0x8017f144
>                 bdslot: 0x8017f168:     lw      v0,344(s3)
> 0x8017f16c:     lw      v1,344(s3)
> 0x8017f170:     li      v0,4660
> 0x8017f174:     jal     0x80031be8
>                 bdslot: 0x8017f178:     sh      v0,54(v1)
> 0x8017f17c:     lw      v1,344(s3)
> 0x8017f180:     li      v0,22136
> 0x8017f184:     jal     0x80031be8
>                 bdslot: 0x8017f188:     sh      v0,54(v1)
> 0x8017f18c:     move    a0,s3
> 0x8017f190:     move    a1,s6
> 0x8017f194:     addu    a2,s5,s4
> 0x8017f198:     jal     0x8017ef1c
>                 bdslot: 0x8017f19c:     li      a3,54
> 0x8017f1a0:     bne     v0,zero,0x8017f1e4
>                 bdslot: 0x8017f1a4:     li      v0,5
> 0x8017f1a8:     jal     0x80031be8
>                 bdslot: 0x8017f1ac:     nop
> 0x8017f1b0:     lw      v0,344(s3)
> 0x8017f1b4:     lhu     v1,54(v0)
> 0x8017f1b8:     li      v0,4660
> 0x8017f1bc:     bne     v1,v0,0x8017f110
>                 bdslot: 0x8017f1c0:     move    a0,s3
> 0x8017f1c4:     jal     0x80031be8
>                 bdslot: 0x8017f1c8:     nop
> 0x8017f1cc:     lw      v0,344(s3)
> 0x8017f1d0:     lhu     v1,54(v0)
> 0x8017f1d4:     li      v0,22136
> 0x8017f1d8:     bne     v1,v0,0x8017f110
>                 bdslot: 0x8017f1dc:     move    a0,s3
> 0x8017f1e0:     move    v0,zero
> 0x8017f1e4:     lw      ra,48(sp)
> 0x8017f1e8:     lw      s7,44(sp)
> 0x8017f1ec:     lw      s6,40(sp)
> 0x8017f1f0:     lw      s5,36(sp)
> 0x8017f1f4:     lw      s4,32(sp)
> 0x8017f1f8:     lw      s3,28(sp)
> 0x8017f1fc:     lw      s2,24(sp)
> 0x8017f200:     lw      s1,20(sp)
> 0x8017f204:     lw      s0,16(sp)
> 0x8017f208:     jr      ra
>                 bdslot: 0x8017f20c:     addiu   sp,sp,56
> 0x8017f210:     addiu   sp,sp,-40
> 0x8017f214:     sw      s2,24(sp)
> 0x8017f218:     move    s2,a0
> 0x8017f21c:     sw      s3,28(sp)
> 0x8017f220:     move    s3,a1
> 0x8017f224:     li      a1,10
> 0x8017f228:     sw      s1,20(sp)
> 0x8017f22c:     move    s1,a2
> 0x8017f230:     move    a2,s3
> 0x8017f234:     sw      ra,32(sp)
> 0x8017f238:     jal     0x8017e9fc
>                 bdslot: 0x8017f23c:     sw      s0,16(sp)
> 0x8017f240:     beq     v0,zero,0x8017f260
>                 bdslot: 0x8017f244:     addiu   a1,s2,20
> 0x8017f248:     lui     a0,0x8019
> 0x8017f24c:     addiu   a0,a0,32140
> 0x8017f250:     jal     0x80065054
>                 bdslot: 0x8017f254:     move    a2,s3
> 0x8017f258:     j       0x8017f344
>                 bdslot: 0x8017f25c:     li      v0,12
> 0x8017f260:     move    s0,zero
> 0x8017f264:     jal     0x80031be8
>                 bdslot: 0x8017f268:     nop
> 0x8017f26c:     lw      v1,344(s2)
> 0x8017f270:     lhu     v0,48(v1)
> 0x8017f274:     andi    v0,v0,0x8
> 0x8017f278:     bne     v0,zero,0x8017f290
>                 bdslot: 0x8017f27c:     li      v0,0xffff
> 0x8017f280:     addiu   s0,s0,1
> 0x8017f284:     slt     v0,v0,s0
> 0x8017f288:     beq     v0,zero,0x8017f264
>                 bdslot: 0x8017f28c:     nop
> 0x8017f290:     lui     v0,0x1
> 0x8017f294:     bne     s0,v0,0x8017f2b4
>                 bdslot: 0x8017f298:     li      v0,8
> 0x8017f29c:     lui     a0,0x8019
> 0x8017f2a0:     addiu   a0,a0,32180
> 0x8017f2a4:     jal     0x80065054
>                 bdslot: 0x8017f2a8:     addiu   a1,s2,20
> 0x8017f2ac:     j       0x8017f344
>                 bdslot: 0x8017f2b0:     li      v0,60
> 0x8017f2b4:     sh      v0,52(v1)
> 0x8017f2b8:     jal     0x80031be8
>                 bdslot: 0x8017f2bc:     nop
> 0x8017f2c0:     jal     0x80031be8
>                 bdslot: 0x8017f2c4:     nop
> 0x8017f2c8:     lw      v0,344(s2)
> 0x8017f2cc:     move    a0,s2
> 0x8017f2d0:     lhu     v0,34(v0)
> 0x8017f2d4:     move    a2,zero
> 0x8017f2d8:     li      a3,54
> 0x8017f2dc:     andi    v0,v0,0xffff
> 0x8017f2e0:     move    a1,v0
> 0x8017f2e4:     jal     0x8017ef1c
>                 bdslot: 0x8017f2e8:     sw      v0,0(s1)
> 0x8017f2ec:     beq     v0,zero,0x8017f30c
>                 bdslot: 0x8017f2f0:     sra     s1,s3,31
> 0x8017f2f4:     lui     a0,0x8019
> 0x8017f2f8:     addiu   a0,a0,32204
> 0x8017f2fc:     jal     0x80065054
>                 bdslot: 0x8017f300:     addiu   a1,s2,20
> 0x8017f304:     j       0x8017f344
>                 bdslot: 0x8017f308:     li      v0,5
> 0x8017f30c:     subu    v0,s3,s1
> 0x8017f310:     sra     v0,v0,1
> 0x8017f314:     blez    v0,0x8017f340
>                 bdslot: 0x8017f318:     move    s0,zero
> 0x8017f31c:     lw      v0,344(s2)
> 0x8017f320:     sh      zero,54(v0)
> 0x8017f324:     jal     0x80031be8
>                 bdslot: 0x8017f328:     addiu   s0,s0,1
> 0x8017f32c:     subu    v0,s3,s1
> 0x8017f330:     sra     v0,v0,1
> 0x8017f334:     slt     v0,s0,v0
> 0x8017f338:     bnel    v0,zero,0x8017f320
>                 bdslot: 0x8017f33c:     lw      v0,344(s2)
> 0x8017f340:     move    v0,zero
> 0x8017f344:     lw      ra,32(sp)
> 0x8017f348:     lw      s3,28(sp)
> 0x8017f34c:     lw      s2,24(sp)
> 0x8017f350:     lw      s1,20(sp)
> 
> 
> 
> db> x/i 0x801801a8,80
> 0x801801a8:     addiu   sp,sp,-128
> 0x801801ac:     sw      s4,112(sp)
> 0x801801b0:     move    s4,a0
> 0x801801b4:     sw      ra,124(sp)
> 0x801801b8:     sw      s6,120(sp)
> 0x801801bc:     sw      s5,116(sp)
> 0x801801c0:     sw      s3,108(sp)
> 0x801801c4:     sw      s2,104(sp)
> 0x801801c8:     sw      s1,100(sp)
> 0x801801cc:     sw      s0,96(sp)
> 0x801801d0:     lhu     v0,48(s4)
> 0x801801d4:     andi    v0,v0,0x400
> 0x801801d8:     bne     v0,zero,0x80180404
>                 bdslot: 0x801801dc:     lw      s3,0(s4)
> 0x801801e0:     lw      s1,212(s4)
> 0x801801e4:     beq     s1,zero,0x80180408
>                 bdslot: 0x801801e8:     lw      ra,124(sp)
> 0x801801ec:     lw      v0,4(s1)
> 0x801801f0:     bne     v0,zero,0x801801fc
>                 bdslot: 0x801801f4:     sw      v0,212(s4)
> 0x801801f8:     sw      zero,216(s4)
> 0x801801fc:     addiu   s6,sp,24
> 0x80180200:     move    a0,s6
> 0x80180204:     sw      zero,4(s1)
> 0x80180208:     lw      v0,220(s4)
> 0x8018020c:     move    a1,zero
> 0x80180210:     li      a2,68
> 0x80180214:     addiu   v0,v0,-1
> 0x80180218:     jal     0x80183a40
>                 bdslot: 0x8018021c:     sw      v0,220(s4)
> 0x80180220:     lw      s2,8(s1)
> 0x80180224:     lbu     a0,13(s2)
> 0x80180228:     lbu     v0,12(s2)
> 0x8018022c:     sll     a0,a0,8
> 0x80180230:     jal     0x80183720
>                 bdslot: 0x80180234:     or      a0,a0,v0
> 0x80180238:     move    v1,v0
> 0x8018023c:     li      v0,2048
> 0x80180240:     beq     v1,v0,0x8018026c
>                 bdslot: 0x80180244:     lw      s5,428(s3)
> 0x80180248:     li      v0,2054
> 0x8018024c:     beql    v1,v0,0x80180270
>                 bdslot: 0x80180250:     addiu   a0,sp,42
> 0x80180254:     li      v0,0x8035
> 0x80180258:     beql    v1,v0,0x80180270
>                 bdslot: 0x8018025c:     addiu   a0,sp,42
> 0x80180260:     li      v0,0x86dd
> 0x80180264:     bnel    v1,v0,0x80180358
>                 bdslot: 0x80180268:     lhu     v0,24(s1)
> 0x8018026c:     addiu   a0,sp,42
> 0x80180270:     move    a1,s2
> 0x80180274:     jal     0x801835ec
>                 bdslot: 0x80180278:     li      a2,6
> 0x8018027c:     addiu   a0,sp,48
> 0x80180280:     addiu   s0,s2,6
> 0x80180284:     move    a1,s0
> 0x80180288:     jal     0x801835ec
>                 bdslot: 0x8018028c:     li      a2,6
> 0x80180290:     addiu   a0,sp,70
> 0x80180294:     move    a1,s2
> 0x80180298:     jal     0x801835ec
>                 bdslot: 0x8018029c:     li      a2,6
> 0x801802a0:     addiu   a0,sp,76
> 0x801802a4:     move    a1,s0
> 0x801802a8:     jal     0x801835ec
>                 bdslot: 0x801802ac:     li      a2,6
> 0x801802b0:     lhu     v1,24(s1)
> 0x801802b4:     li      a0,0xaaaa
> 0x801802b8:     li      v0,8
> 0x801802bc:     sh      v0,38(sp)
> 0x801802c0:     addiu   v1,v1,-6
> 0x801802c4:     jal     0x80183720
>                 bdslot: 0x801802c8:     sh      v1,68(sp)
> 0x801802cc:     li      a0,768
> 0x801802d0:     jal     0x80183720
>                 bdslot: 0x801802d4:     sh      v0,84(sp)
> 0x801802d8:     sh      v0,86(sp)
> 0x801802dc:     lhu     a0,24(s1)
> 0x801802e0:     addiu   a0,a0,-6
> 0x801802e4:     jal     0x80183720
>                 bdslot: 0x801802e8:     andi    a0,a0,0xffff
> 0x801802ec:     move    a0,s1
> 0x801802f0:     sh      v0,82(sp)
> 0x801802f4:     lbu     v0,13(s2)
> 0x801802f8:     lbu     v1,12(s2)
> 0x801802fc:     li      a1,14
> 0x80180300:     sll     v0,v0,8
> 0x80180304:     or      v0,v0,v1
> 0x80180308:     sh      v0,90(sp)
> 0x8018030c:     lw      a2,24(s1)
> 0x80180310:     addiu   s0,s3,559
> 0x80180314:     move    a3,s0
> 0x80180318:     jal     0x80070e64
>                 bdslot: 0x8018031c:     addiu   a2,a2,-14
> 0x80180320:     move    a0,s3
> 0x80180324:     move    a1,s5
> 0x80180328:     move    a2,zero
> 0x8018032c:     addiu   a3,sp,24
> 0x80180330:     li      v0,68
> 0x80180334:     jal     0x8017f0d0
>                 bdslot: 0x80180338:     sw      v0,16(sp)
> 0x8018033c:     move    a0,s3
> 0x80180340:     move    a1,s5
> 0x80180344:     lw      v0,24(s1)
> 0x80180348:     li      a2,68
> 0x8018034c:     move    a3,s0
> 0x80180350:     j       0x801803a8
>                 bdslot: 0x80180354:     addiu   v0,v0,-12
> 0x80180358:     move    a0,s1
> 0x8018035c:     move    a1,zero
> 0x80180360:     sh      v0,68(sp)
> 0x80180364:     lw      a2,24(s1)
> 0x80180368:     addiu   s0,s3,559
> 0x8018036c:     jal     0x80070e64
>                 bdslot: 0x80180370:     move    a3,s0
> 0x80180374:     move    a0,s3
> 0x80180378:     move    a1,s5
> 0x8018037c:     move    a2,zero
> 0x80180380:     move    a3,s6
> 0x80180384:     li      v0,68
> 0x80180388:     jal     0x8017f0d0
>                 bdslot: 0x8018038c:     sw      v0,16(sp)
> 0x80180390:     move    a0,s3
> 0x80180394:     move    a1,s5
> 0x80180398:     lw      v0,24(s1)
> 0x8018039c:     li      a2,46
> 0x801803a0:     move    a3,s0
> 0x801803a4:     addiu   v0,v0,2
> 0x801803a8:     jal     0x8017f0d0
>                 bdslot: 0x801803ac:     sw      v0,16(sp)
> 0x801803b0:     lw      a0,40(s4)
> 0x801803b4:     beq     a0,zero,0x801803c4
>                 bdslot: 0x801803b8:     nop
> 0x801803bc:     jal     0x800a719c
>                 bdslot: 0x801803c0:     move    a1,s1
> 0x801803c4:     jal     0x80070430
>                 bdslot: 0x801803c8:     move    a0,s1
> 0x801803cc:     move    a0,s3
> 0x801803d0:     li      a1,267
> 0x801803d4:     jal     0x8017e9fc
>                 bdslot: 0x801803d8:     move    a2,s5
> 0x801803dc:     beql    v0,zero,0x801803f4
>                 bdslot: 0x801803e0:     lhu     v0,48(s4)
> 0x801803e4:     addiu   a0,gp,6836
> 0x801803e8:     jal     0x80065054
>                 bdslot: 0x801803ec:     addiu   a1,s3,20
> 0x801803f0:     lhu     v0,48(s4)
> 0x801803f4:     li      v1,5
> 0x801803f8:     sh      v1,46(s4)
> 0x801803fc:     ori     v0,v0,0x400
> 0x80180400:     sh      v0,48(s4)
> 0x80180404:     lw      ra,124(sp)
> 0x80180408:     lw      s6,120(sp)
> 0x8018040c:     lw      s5,116(sp)
> 0x80180410:     lw      s4,112(sp)
> 0x80180414:     lw      s3,108(sp)
> 
> 
> 
> Quoting Castor Fu <castor@geocast.com>:
> 
> > The other possibility is to just put this kernel somewhere where
> > I can disassemble it.  That might be easier. . . .
> > 
> > 	-castor
> > 
> > > For this amount of info I'm going to need to recompile a kernel with
> > serial
> > > debugger support... I've been hand-typing up til now and this will be
> > a little
> > > tedious to say the least. Let me see what I can do...
> > > 
> > > Dan
> > > 
> > > Quoting Castor Fu <castor@geocast.com>:
> > > 
> > > > Hmm, I was hoping for function names in the trace. . . .
> > > > 
> > > > If you could perhaps disassemble a few of the routines we might
> > > > be able to identify them.
> > > > 
> > > > e.g.
> > > > 
> > > > 	x/i 0x8017f0d0,80
> > > > 	x/i 0x801801a8,80
> > > > 
> > > > Probably not such a good idea to spam the whole list.
> > > > 
> > > > 	-castor
> > > > > 
> > > > > Okay, here we go... 
> > > > > 
> > > > > # ifconfig wi0 172.16.0.27
> > > > > Dec 9 06:17:00 hostname /netbsd: pcmcia0: card irq 3
> > > > > trap: address error (load or I-fetch) in kernel mode
> > > > > status=0x7803, cause=0x510, epc=0x8017f144, vaddr=0xc001822f
> > > > > pid=156 cmd=ifconfig usp=0x7fffec40 ksp=0xc3cdf6a8
> > > > > Stopped in ifconfig at  0x8017f144      lhu      v1,0(s0)
> > > > > db> trace
> > > > > 8017f0d0+74 (c0018000,d4,36,36) ra 801803b0 sz 56
> > > > > 801801a8+208 (c0018000,d4,36,36) ra 800a98cc sz 128
> > > > > 800a9320+5ac (c0018000,d4,36,36) ra 800b74cc sz 88
> > > > > 800b7398+134 (c0018000,d4,36,36) ra 800b81dc sz 64
> > > > > 800b8184+58 (c0018000,d4,36,36) ra 8017fad0 sz 40
> > > > > 8017f938+198 (c0018000,d4,36,36) ra 800ba934 sz 1120
> > > > > 800ba7b0+184 (c0018000,d4,36,36) ra 800ba10c sz 80
> > > > > 800b9a4c+6c0 (c0018000,d4,36,36) ra 800da198 sz 72
> > > > > 800da134+64 (c0018000,d4,36,36) ra 800a915c sz 72
> > > > > 800a8da4+3b8 (c0018000,d4,36,36) ra 800692b4 sz 56
> > > > > 80069150+164 (c0018000,d4,36,36) ra 80068100 sz 32
> > > > > 80067d8c+374 (c0018000,d4,36,36) ra 80141ce8 sz 192
> > > > > 80141b2c+1bc (c0018000,d4,36,36) ra 80030fac sz 96
> > > > > mips3_SystemCall+d0 (c0018000,d4,36,36) ra 444330 sz 0
> > > > > PC 0x444330: not in kernel space
> > > > > 0+444330 (c0018000,d4,36,36) ra 0 sz 0
> > > > > User-level: pid 156
> > > > > db>
> > > > > 
> > > > > Hope this helps! Let me know if there's more I can do.
> > > > > 
> > > > > Dan
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > Quoting Castor Fu <castor@geocast.com>:
> > > > > 
> > > > > > > If there's something I can do in the debugger which will
> > provide
> > > > more
> > > > > > info,
> > > > > > > please let me know.
> > > > > > 
> > > > > > > > # ifconfig wi0 172.16.0.27 netmask 0xffffff00 up
> > > > > > > > pcmica: card irq 3
> > > > > > > > trap: address error (load or I-fetch) in kernel mode
> > > > > > > > status=0x7803, cause=0x510, epc=0x8016c804,
> > vaddr=0xc001622f
> > > > > > > > pid=185 cmd=ifconfig usp=0x7fffec18 ksp=0xc3cdf6a8
> > > > > > > > Stopped in ifconfig at  0x8016c804:        lhu     
> > vi,0(s0)
> > > > > > > > db>
> > > > > > 
> > > > > > In the debugger, if you could get a stack trace with the
> > 'trace'
> > > > > > command that would be helpful.  
> > > > > > 
> > > > > > What's happening here is an unaligned address access.  'lhu' is
> > a
> > > > > > 16-bit load and the address used, 0xc001622f, is on an odd byte
> > > > > > boundary
> > > > > > which is perfectly legal on processors like the x86 family, but
> > not
> > > > ok
> > > > > > on the mips.
> > > > > > 
> > > > > > 	-castor
> > > > > > 
> > > > > > 
> > > > > 
> > > > 
> > > > 
> > > 
> > 
> > 
>