Debugging early in boot

When things go wrong in the startup code, there are a few options to determine what's going on. Dan Mick has a discussion about firing up with kmdb, which you can use to set breakpoints (using -d) in the debugger. This is often enough to get you going if you have some idea where the problem lies -- but if you don't know where the problem is, it can be slow to isolate the failing code section, so another hidden feature of the kernel may help determine where the system is tipping over.

There is a "PROM debug" facility which provides simple printf-style debugging for the startup code. This facility is available on SPARC and x86/x64 (on SPARC you can #include <prom_debug.h> in any machine dependent file to use this facility). The PRM_DEBUG() macro can be invoked for early printf-style debugging before cmn_err() is available, as cmn_err() relies on STREAMS and the VM subsystem to function. The kernel has a whole wad of these PRM_DEBUG() statements already defined at various points in the startup code, which can help to isolate where the problem system is tipping over. It can also be a nice aid for learning the flow of the startup code. The PRM_DEBUG()macro calls are activated by setting prom_debug to 1 using the kernel debugger. These statements are compiled into both DEBUG and non-DEBUG kernels (so they work with stock Solaris, too!).

Here is a trimmed example from my AMD64 box booting the 64-bit kernel:

<< selected Solaris entry in GRUB menu and press "e" to edit >>
grub edit> kernel /platform/i86pc/multiboot -kd
<< enter, b >>
root (hd0,1,a)
 Filesystem type is ufs, partition type 0x000000bf
kernel /platform/i86pc/multiboot -kd
   [Multiboot-elf, <0x1000000:0x141cb:0x3941d>, shtab=0x104e258, entry=0x100000
0]
...
Welcome to kmdb
Loaded modules: [ unix krtld genunix ]
[0]> prom_debug/W 1
prom_debug:     0               =       0x1
[0]> :c
startup.c:600: startup_init() starting...
startup.c:637: startup_init() done
startup.c:828: startup_memlist() starting...
startup.c:871: 'modtext' is 0xfffffffffbbb2000
startup.c:872: 'e_modtext' is 0xfffffffffbc00000
startup.c:873: 'moddata' is 0xfffffffffbcf7000
startup.c:874: 'e_moddata' is 0xfffffffffbd42000
startup.c:875: 'econtig' is 0xfffffffffbd42000
startup.c:883: 'cr4_value' is 0xb0
MEMLIST: boot physinstalled:
        Address 0x0, size 0x9b000
        Address 0x100000, size 0xfbe70000
startup.c:896: 'physmax' is 0xfbf6f
startup.c:897: 'physinstalled' is 0xfbf0b
startup.c:898: 'memblocks' is 0x2
MEMLIST: boot physavail:
        Address 0x0, size 0x9b000
        Address 0x100000, size 0xf00000
        Address 0x1050000, size 0xb000
        Address 0x17621000, size 0x1df000
        Address 0x18000000, size 0xe3f70000
startup.c:944: 'mmu.pt_nx' is 0x8000000000000000
startup.c:961: 'npages' is 0xfb30a
startup.c:962: 'obp_pages' is 0x600
startup.c:973: 'physmem' is 0xfb30a
...
startup.c:1212: kphysm_init() done
startup.c:1213: 'boot_npages' is 0xfb309
SunOS Release 5.11 Version onnv_clone 64-bit
Copyright 1983-2005 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
DEBUG enabled
startup.c:1250: startup_memlist() done
startup.c:1260: startup_modules() starting...
startup.c:1342: startup_modules() done
startup.c:1348: startup_bop_gone() starting...
startup.c:1354: Calling hat_kern_alloc()...
startup.c:1356: hat_kern_alloc() done
startup.c:1362: startup_bop_gone() done
startup.c:1413: startup_vm() starting...
...
startup.c:1769: startup_vm() done
startup.c:1777: startup_end() starting...
startup.c:1804: Calling configure()...
startup.c:1806: configure() done
startup.c:1820: zeroing out bootops
startup.c:1824: Enabling interrupts
startup.c:1831: startup_end() done
startup.c:1920: Unmapping lower boot pages
startup.c:1923: Unmapping upper boot pages
startup.c:1941: Releasing boot pages
startup.c:1978: Returning boot's VA space to kernel heap
Hostname: rutamaya
NIS domain name is austincampus.Central.Sun.COM

rutamaya console login:

And another example, from a SPARC box:

ok boot -kd
...
Welcome to kmdb
kmdb: unable to determine terminal type: assuming `vt100'
Loaded modules: [ unix krtld genunix sparc ]
[0]> prom_debug/W 1
prom_debug:     0               =       0x1
[0]> :c
../../sun4/os/mlsetup.c:210: mlsetup: now ok to call prom_printf
../../sun4/os/mlsetup.c:228: 'panicbuf' is 0x70002000
../../sun4/os/mlsetup.c:229: 'pa' is 0x3e000000
../../sun4/os/startup.c:805: 'moddata' is 0x190e000
../../sun4/os/startup.c:806: 'nalloc_base' is 0x194e000
../../sun4/os/startup.c:807: 'nalloc_end' is 0x1c00000
../../sun4/os/startup.c:808: 'sdata' is 0x1800000
../../sun4/os/startup.c:813: 'e_text' is 0x1396ef8
../../sun4/os/startup.c:819: 'modtext' is 0x1398000
../../sun4/os/startup.c:820: 'modtext_sz' is 0x68000
../../sun4/os/startup.c:832: 'physinstalled' is 0x20000
../../sun4/os/startup.c:833: 'physmax' is 0x1ffff
../../sun4/os/startup.c:864: 'extra_etpg' is 0x0
../../sun4/os/startup.c:865: 'modtext_sz' is 0x68000
../../sun4/os/startup.c:867: 'extra_etva' is 0x1400000
../../sun4/os/startup.c:874: 'npages' is 0x1f2ae
../../sun4/vm/sfmmu.c:692: 'npages' is 0x1f2ae
../../sun4/vm/sfmmu.c:751: 'ktsb_base' is 0x1a00000
...
../../sun4/os/startup.c:1489: 'memlist_sz' is 0x2000
../../sun4/os/startup.c:1490: 'memspace' is 0x3000002a000
../../sun4/os/startup.c:1495: 'pp_base' is 0x70002000000
../../sun4/os/startup.c:1496: 'memseg_base' is 0x19ebc00
../../sun4/os/startup.c:1497: 'npages' is 0x1e611
../../sun4/os/startup.c:1505: 'availrmem' is 0x1ded0
SunOS Release 5.11 Version onnv-gate:2005-06-22 64-bit
Copyright 1983-2005 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
DEBUG enabled
misc/forthdebug (494488 bytes) loaded
../../sun4/vm/sfmmu.c:170: 'ktsb_pbase' is 0x3f600000
../../sun4/vm/sfmmu.c:171: 'ktsb4m_pbase' is 0x3f54e000
../../sun4/vm/sfmmu.c:370: 'translen' is 0x4000
Hostname: pacha
SUNW,eri0 : 100 Mbps full duplex link up
NIS domain name is austincampus.Central.Sun.COM
TSI: gfxp0 is GFX8P @ 1152x900

pacha console login:

Happy hacking.


Technorati Tags: [ ]
Comments:

Post a Comment:
Comments are closed for this entry.
About

elowe

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today