::log.2006

[ TOP | Recently ]

La Fonera de NetBSD #2 / La Fonera de NetBSD / sendmsg / raidframe

2006-12-28 La Fonera de NetBSD #2

無線LAN attach完了。

NetBSD 4.99.7 (FONERA) #36: Thu Dec 28 09:59:32 JST 2006
ryo@r9:/usr/src/sys/arch/evbmips/compile/FONERA
Atheros AR2315
total memory = 16384 KB
avail memory = 13624 KB
timecounter: Timecounters tick every 10.000 msec
mainbus0 (root)
cpu0 at mainbus0: 184.00MHz (hz cycles = 920000, delay divisor = 92)
cpu0: MIPS 4KEc (Rev 2) (0x19064) Rev. 100 with software emulated floating point
cpu0: 16KB/16B 4-way set-associative L1 Instruction cache, 16 TLB entries
cpu0: 16KB/16B 4-way set-associative write-back L1 Data cache
wdog0 at mainbus0: 5 second period
arbus0 at mainbus0
com0 at arbus0 addr 0x11100000 cpu irq 0 misc irq 0: ns16550a, working fifo
com0: console
ae0 at arbus0 addr 0x10500000 cpu irq 2: Atheros AR531X 10/100 Ethernet
ae0: Ethernet address 00:18:84:##:##:##
ukphy0 at ae0 phy 0: Generic IEEE 802.3u media interface
ukphy0: AC101L 10/100 media interface (OUI 0x0010a9, model 0x0012), rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ath0 at arbus0 addr 0x10000000 cpu irq 1: Atheros 2315 WiSoC
ath_hal_get_board_config: config addr 0xa87f0000
ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ath0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
ath0: mac 11.0 phy 4.8 radio 7.0
arspi0 at arbus0 addr 0x11300000 cpu irq 0 misc irq 2: Atheros SPI controller
spi0 at arspi0: SPI bus
m25p0 at spi0 slave 0
spiflash0 at m25p0: STMicro M25P64 SPI flash
spiflash0: 8192 KB, 128 sectors of 64 KB each
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
timecounter: Timecounter "mips3_cp0_counter" frequency 92000000 Hz quality 100
root on ae0

動作も確認。

# ifconfig ath0
ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ssid ########## nwkey ##########
powersave off
bssid 00:07:40:##:##:## chan 1
address: 00:18:84:##:##:##
media: IEEE802.11 autoselect mode 11g (OFDM54 mode 11g)
status: active
inet 172.24.0.100 netmask 0xffff0000 broadcast 172.24.255.255
# ping -n 172.24.0.1
PING 172.24.0.1 (172.24.0.1): 56 data bytes
64 bytes from 172.24.0.1: icmp_seq=0 ttl=64 time=2.550 ms
64 bytes from 172.24.0.1: icmp_seq=1 ttl=64 time=2.289 ms
^C
----172.24.0.1 PING Statistics----
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.289/2.419/2.550/0.185 ms
#


Atherosの無線モジュールは、FCCの関係でバイナリコードでしかモジュールが提供されておらず、しかもlinuxで使われているhal(hardware access layer)のバージョンとNetBSDに入っているhal(src/sys/contrib/dev/ath)のバージョンが違っていろいろめんどくさいことになっている。

最新版のhalを http://madwifi.org/ から拾ってくればいいJANとか思ったのだが、Fonera用のhalがどこにも見当たりませんよ…?

Fonera の Linuxカーネル(http://download.fon.com/firmware/fonera/latest/fonera.tar.bz2)で使われている mipsisa32_soc-be-elf.hal の最新版は無いのかね。

2006-12-26 La Fonera de NetBSD


2chのネットワーク板のFONスレとか見ながらシリアルをつけて、あとは evbmips/conf/MERAKI でそのまま bootした。つまらん…


RedBoot> load -r -b 0x80041000 netbsd.meraki.bin
Using default protocol (TFTP)
Raw file loaded 0x80041000-0x802083df, assumed entry at 0x80041000
RedBoot> go 0x80041000
MIPS32/64 params: cpu arch: 32
MIPS32/64 params: TLB entries: 16
MIPS32/64 params: Icache: line = 16, total = 16384, ways = 4
sets = 256
MIPS32/64 params: Dcache: line = 16, total = 16384, ways = 4
sets = 256
picache_stride = 4096
picache_loopcount = 4
pdcache_stride = 4096
pdcache_loopcount = 4
Memory size: 0x01000000
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
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 4.99.7 (MERAKI) #0: Tue Dec 26 06:57:51 JST 2006
ryo@moveq:/usr/src/sys/arch/evbmips/compile/MERAKI
Atheros AR2315
total memory = 16384 KB
avail memory = 13692 KB
timecounter: Timecounters tick every 10.000 msec
mainbus0 (root)
cpu0 at mainbus0: 184.00MHz (hz cycles = 920000, delay divisor = 92)
cpu0: MIPS 4KEc (Rev 2) (0x19064) Rev. 100 with software emulated floating point
cpu0: 16KB/16B 4-way set-associative L1 Instruction cache, 16 TLB entries
cpu0: 16KB/16B 4-way set-associative write-back L1 Data cache
wdog0 at mainbus0: 5 second period
arbus0 at mainbus0
com0 at arbus0 addr 0x11100000 cpu irq 0 misc irq 0: ns16550a, working fifo
com0: console
ae0 at arbus0 addr 0x10500000 cpu irq 2: Atheros AR531X 10/100 Ethernet
ae0: Ethernet address 00:18:84:##:##:##
ukphy0 at ae0 phy 0: Generic IEEE 802.3u media interface
ukphy0: AC101L 10/100 media interface (OUI 0x0010a9, model 0x0012), rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ath0 at arbus0 addr 0x10000000 cpu irq 1: Atheros 2315 WiSoC
ath0: unable to attach hardware; HAL status 5
ath0: ath_attach failed
arspi0 at arbus0 addr 0x11300000 cpu irq 0 misc irq 2: Atheros SPI controller
spi0 at arspi0: SPI bus
m25p0 at spi0 slave 0
spiflash0 at m25p0: STMicro M25P64 SPI flash
spiflash0: 8192 KB, 128 sectors of 64 KB each
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
timecounter: Timecounter "mips3_cp0_counter" frequency 92000000 Hz quality 100
root device:

めんどくさそうなの無線LANだけだな。flashはIPLから任意のイメージを書き込めるっぽいので問題無さげ。

2006-10-13 sendmsg

わかった。必要なチェックが2つ足りない。

sys/kern/uipc_usrreq.c の unp_internalize() に渡したパラメタのチェックが甘くて、cm->cmsg_len に CMSG_ALIGN(sizeof(*cm)) 未満の値を入れると

nfds = (cm->cmsg_len - CMSG_ALIGN(sizeof(*cm))) / sizeof(int);

が負になってカーネルがどっか変なメモリ見てpanicで死んでた。NetBSD/amd64で確認。試してないけどたぶん hw.alignbytes = 7 な arch はアウトだ。ソース見る限りOpenBSDもかなぁ。FreeBSDは知らn


ここに CMSG_ALIGN(sizeof(*cm)) 未満な cm->cmsg_len が来るのがおかしいのが一点目。
もう一つ、nfds が 0 な時でも、panic はしないものの、カーネルスタックがユーザランドに見えてしまうのではじくべき。
これが二点目。ただしこっちは KSTACK_MAGIC が見えるだけっぽいので実害なし。


一つ目のチェックは uipc_syscalls.c の sendit() の

if (mp->msg_control) {
	if (mp->msg_controllen < sizeof(struct cmsghdr)) {
		error = EINVAL;

ここがまずいんだな。正解は

if (mp->msg_controllen < __CMSG_ALIGN(sizeof(struct cmsghdr))) {

だ。

二つめのチェックは uipc_usrreq.c の unp_internalize() の nfds = 〜 の個所。

sendprは週末休めたら…

2006-11-07 raidframe

# raidctl -S raid0
raid0 Status:
Reconstruction is 100% complete.
Parity Re-write is -1270865264% complete.
Copyback is 100% complete.

…ぉ

raidioctl():
	*(int *) data = 100 * raidPtr->parity_rewrite_stripes_done / raidPtr->Layout.numStripe;

parity_rewrite_stripes_done も numStripes も int。
現在numStripesは3244198552。

どうみてもoverflowです。
ありがとうございました。


EOF