arm なカーネルの DeviceTree を確認すべく (5)

パッチ製造の手を休めてこちらに。なんとなくうだうだすすめます。

  • とりあえず nfs-kernel-server は動いている模様
  • /etc/exports もかくにん

ということで以下を実行。

$ sudo qemu-system-arm -S -gdb tcp::1234 -M vexpress-a9 -kernel /opt/kernel/zImage \
-append "root=/dev/nfs rw nfsroot=10.0.2.2:/opt/export/filesystem.dir ip=dhcp"

で、別端末から以下か。

$ /opt/arm-2010q1/bin/arm-none-linux-gnueabi-gdb ./vmlinux

vmlinux が入る場所で実行してます。当り前ですが。
で、以下な出力。

GNU gdb (Sourcery G++ Lite 2010q1-202) 7.0.50.20100218-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi".
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>...
Reading symbols from /opt/kernel/linux-next/arm.gdb.test/vmlinux...done.
(gdb) 

できれば emacs の中で動いて欲しいのですがそれは無いものねだりだな。ちなみに今はここに居るらしい。

(gdb) l
1       /*
2        *  linux/arch/arm/kernel/head.S
3        *
4        *  Copyright (C) 1994-2002 Russell King
5        *  Copyright (c) 2003 ARM Limited
6        *  All Rights Reserved
7        *
8        * This program is free software; you can redistribute it and/or modify
9        * it under the terms of the GNU General Public License version 2 as
10       * published by the Free Software Foundation.
(gdb) 

むむ、前回どうしたんだったかな。あ、その前に target remote しなきゃ、なのか。

(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x60000000 in ?? ()
(gdb)

このあたりは前回と同様。

(gdb) b setup_arch
Breakpoint 1 at 0x8036acd8: file arch/arm/kernel/setup.c, line 737.
(gdb) c
Continuing.

Breakpoint 1, setup_arch (cmdline_p=0x80391fdc) at arch/arm/kernel/setup.c:737
737             setup_processor();
(gdb) list
732
733     void __init setup_arch(char **cmdline_p)
734     {
735             struct machine_desc *mdesc;
736
737             setup_processor();
738             mdesc = setup_machine_fdt(__atags_pointer);
739             if (!mdesc)
740                     mdesc = setup_machine_tags(__atags_pointer, machine_arch_type);
741             machine_desc = mdesc;
(gdb) 

setup_machine_fdt で b してみるか。

(gdb) b setup_machine_fdt
Breakpoint 2 at 0x8036b71e: file arch/arm/kernel/devtree.c, line 79.
(gdb) c
Continuing.

Breakpoint 2, setup_machine_fdt (dt_phys=1610612992) at arch/arm/kernel/devtree.c:79
79              if (!dt_phys)
(gdb) list
74              struct machine_desc *mdesc, *mdesc_best = NULL;
75              unsigned int score, mdesc_score = ~1;
76              unsigned long dt_root;
77              const char *model;
78
79              if (!dt_phys)
80                      return NULL;
81
82              devtree = phys_to_virt(dt_phys);
83
(gdb) 

ソース見ながら next で云々してみます。

(gdb) p dt_phys
$1 = 1610612992
(gdb) p/x dt_phys
$2 = 0x60000100
(gdb) 

そしてやはりこのあたりの挙動が怪しい。

(gdb) n
85              if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
(gdb) p/x devtree
$3 = 0x0
(gdb) n
82              devtree = phys_to_virt(dt_phys);
(gdb) n
85              if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
(gdb) p devtree
$4 = <value optimized out>
(gdb) p/x devtree
$5 = 0x0
(gdb) 

82 を skip してると見せかけてやはり実行しつつ、devtree の値がアレ。そしてここで return しておりましたorz

(gdb) n
86                      return NULL;
(gdb) 

以下な部分ですね。

	if (!dt_phys)
		return NULL;

	devtree = phys_to_virt(dt_phys);

	/* check device tree validity */
	if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
		return NULL;

む、valid ではないのね、というか 0x0 だしorz
しかも今見てみたら dt_phys が 0x0 だな。

(gdb) p/x dt_phys
$6 = 0x0
(gdb) 

これ、再度イチから、ってのは qemu からなのか。

つうか

これってちゃんと動くの? ってのを確認した方が良いな。