Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created April 24, 2012 02:09
Show Gist options
  • Save jclulow/2475500 to your computer and use it in GitHub Desktop.
Save jclulow/2475500 to your computer and use it in GitHub Desktop.
MAGICAL BOOT FAIRIES
Solaris prekernel set: http://store0.sys.syd.distra.com/tmp/ipxe/platform0/i86pc/kernel/amd64/unix -B console=ttya,kbm_debug=true,prom_debug=true,map_debug=true -kdv
(uintptr_t)bi is 0xc10100
target_kernel_text is 0xfffffffffb800000
Entered init_mem_alloc()
(uintptr_t)mb_info is 0x9c978
Finding Modules
next_avail_addr is 0xc12000
next_avail_addr is 0x2001000
module #0: http://store0.sys.syd.distra.com/tmp/ipxe/platform0/i86pc/amd64/boot_archive at: 0x2f32f000, len 0x3fccf000
bi->bi_modules is 0xc10040
bi->bi_module_cnt is 0x1
Finding Memory Map
mb_info->flags is 0x24d
mb_info->mmap_addr is 0x9c9d0
mb_info->mmap_length is 0x30
type: 1 0..9f400
type: 1 100000..3fffd000
type: 1 0..9f400
type: 1 100000..3fffd000
pcimemlist entry 0x3fffd000..0xfff00000
bi->bi_pcimem is 0xc10840
################## JMC ###########
mb_info->mmap_addr + mb_info->mmap_length is 0x9ca00
bi->bi_cmdline is 0x9c778
################## JMC ###########
Sorting phys-installed list
Final memlists:
0: addr=0 size=9f000
1: addr=100000 size=3fefd000
bi->bi_phys_install is 0xc10200
bi->bi_rsvdmem is 0xc10ea0
pge_support is 0x1
NX_support is 0x1
largepage_support is 0x1
amd64_support is 0x1
top_level is 0x3
pte_size is 0x8
ptes_per_table is 0x200
lpagesize is 0x200000
Allocating nucleus pages.
Skipping PT_LOAD segment for paddr = 0xc00000
copying 1621824 bytes from ELF offset 0x12000 to physaddr 0x2400000 (va=0xfb800000)
copying 70688 bytes from ELF offset 0x19e000 to physaddr 0x2800000 (va=0xfbc00000)
ktext_phys is 0x2400000
(uintptr_t)top_page_table is 0x2c00000
Mapping kernel
ktext_phys is 0x2400000
target_kernel_text is 0xfffffffffb800000
ksize is 0x800000
psize is 0x200000
mapping ma=0x2400000 va=0xfffffffffb800000 pte=0x24005e3 l=1
new page table lvl=3 paddr=0x2c01000 ptp=0x2c01027
new page table lvl=2 paddr=0x2c02000 ptp=0x2c02027
mapping ma=0x2600000 va=0xfffffffffba00000 pte=0x26005e3 l=1
mapping ma=0x2800000 va=0xfffffffffbc00000 pte=0x28005e3 l=1
mapping ma=0x2a00000 va=0xfffffffffbe00000 pte=0x2a005e3 l=1
bi->bi_pt_window is 0x2c03000
new page table lvl=3 paddr=0x2c04000 ptp=0x2c04027
new page table lvl=2 paddr=0x2c05000 ptp=0x2c05027
new page table lvl=1 paddr=0x2c06000 ptp=0x2c06027
bi->bi_pte_to_pt_window is 0x2c06018
1:1 map pa=0..1Meg
new page table lvl=1 paddr=0x2c07000 ptp=0x2c07027
1:1 map pa=0..9f000
1:1 map pa=100000..3fffd000
new page table lvl=1 paddr=0x2c08000 ptp=0x2c08027
new page table lvl=1 paddr=0x2c09000 ptp=0x2c09027
new page table lvl=1 paddr=0x2c0a000 ptp=0x2c0a027
new page table lvl=1 paddr=0x2c0b000 ptp=0x2c0b027
new page table lvl=1 paddr=0x2c0c000 ptp=0x2c0c027
new page table lvl=1 paddr=0x2c0d000 ptp=0x2c0d027
new page table lvl=1 paddr=0x2c0e000 ptp=0x2c0e027
new page table lvl=1 paddr=0x2c0f000 ptp=0x2c0f027
new page table lvl=1 paddr=0x2c10000 ptp=0x2c10027
new page table lvl=1 paddr=0x2c11000 ptp=0x2c11027
new page table lvl=1 paddr=0x2c12000 ptp=0x2c12027
new page table lvl=1 paddr=0x2c13000 ptp=0x2c13027
new page table lvl=1 paddr=0x2c14000 ptp=0x2c14027
new page table lvl=1 paddr=0x2c15000 ptp=0x2c15027
new page table lvl=1 paddr=0x2c16000 ptp=0x2c16027
new page table lvl=1 paddr=0x2c17000 ptp=0x2c17027
new page table lvl=1 paddr=0x2c18000 ptp=0x2c18027
new page table lvl=1 paddr=0x2c19000 ptp=0x2c19027
new page table lvl=1 paddr=0x2c1a000 ptp=0x2c1a027
new page table lvl=1 paddr=0x2c1b000 ptp=0x2c1b027
new page table lvl=1 paddr=0x2c1c000 ptp=0x2c1c027
Page tables constructed
entry_addr_low is 0xfb800000
bi->bi_next_paddr is 0x2c1d000
bi->bi_next_vaddr is 0x2c1d000
bi->bi_kseg_size is 0x400000
Finished pagetables:
2c00000[0x0] = 2c04027, va=0 physaddr=2c04000
2c04000[0x0] = 2c05027, va=0 physaddr=2c05000
2c05000[0x0] = 2c07027, va=0 physaddr=2c07000
2c07000[0x0] = 473, va=0 physaddr=0
...
2c07000[0x1ff] = 1ff463, va=1ff000 physaddr=1ff000
2c05000[0x1] = 2c08027, va=200000 physaddr=2c08000
2c08000[0x0] = 200463, va=200000 physaddr=200000
...
2c08000[0x1ff] = 3ff463, va=3ff000 physaddr=3ff000
2c05000[0x2] = 2c09027, va=400000 physaddr=2c09000
2c09000[0x0] = 400463, va=400000 physaddr=400000
...
2c09000[0x1ff] = 5ff463, va=5ff000 physaddr=5ff000
2c05000[0x3] = 2c0a027, va=600000 physaddr=2c0a000
2c0a000[0x0] = 600463, va=600000 physaddr=600000
...
2c0a000[0x1ff] = 7ff463, va=7ff000 physaddr=7ff000
2c05000[0x4] = 2c0b027, va=800000 physaddr=2c0b000
2c0b000[0x0] = 800463, va=800000 physaddr=800000
...
2c0b000[0x1ff] = 9ff463, va=9ff000 physaddr=9ff000
2c05000[0x5] = 2c0c027, va=a00000 physaddr=2c0c000
2c0c000[0x0] = a00463, va=a00000 physaddr=a00000
...
2c0c000[0x1ff] = bff463, va=bff000 physaddr=bff000
2c05000[0x6] = 2c0d027, va=c00000 physaddr=2c0d000
2c0d000[0x0] = c00463, va=c00000 physaddr=c00000
...
2c0d000[0x1ff] = dff463, va=dff000 physaddr=dff000
2c05000[0x7] = 2c0e027, va=e00000 physaddr=2c0e000
2c0e000[0x0] = e00463, va=e00000 physaddr=e00000
...
2c0e000[0x1ff] = fff463, va=fff000 physaddr=fff000
2c05000[0x8] = 2c0f027, va=1000000 physaddr=2c0f000
2c0f000[0x0] = 1000463, va=1000000 physaddr=1000000
...
2c0f000[0x1ff] = 11ff463, va=11ff000 physaddr=11ff000
2c05000[0x9] = 2c10027, va=1200000 physaddr=2c10000
2c10000[0x0] = 1200463, va=1200000 physaddr=1200000
...
2c10000[0x1ff] = 13ff463, va=13ff000 physaddr=13ff000
2c05000[0xa] = 2c11027, va=1400000 physaddr=2c11000
2c11000[0x0] = 1400463, va=1400000 physaddr=1400000
...
2c11000[0x1ff] = 15ff463, va=15ff000 physaddr=15ff000
2c05000[0xb] = 2c12027, va=1600000 physaddr=2c12000
2c12000[0x0] = 1600463, va=1600000 physaddr=1600000
...
2c12000[0x1ff] = 17ff463, va=17ff000 physaddr=17ff000
2c05000[0xc] = 2c13027, va=1800000 physaddr=2c13000
2c13000[0x0] = 1800463, va=1800000 physaddr=1800000
...
2c13000[0x1ff] = 19ff463, va=19ff000 physaddr=19ff000
2c05000[0xd] = 2c14027, va=1a00000 physaddr=2c14000
2c14000[0x0] = 1a00463, va=1a00000 physaddr=1a00000
...
2c14000[0x1ff] = 1bff463, va=1bff000 physaddr=1bff000
2c05000[0xe] = 2c15027, va=1c00000 physaddr=2c15000
2c15000[0x0] = 1c00463, va=1c00000 physaddr=1c00000
...
2c15000[0x1ff] = 1dff463, va=1dff000 physaddr=1dff000
2c05000[0xf] = 2c16027, va=1e00000 physaddr=2c16000
2c16000[0x0] = 1e00463, va=1e00000 physaddr=1e00000
...
2c16000[0x1ff] = 1fff463, va=1fff000 physaddr=1fff000
2c05000[0x10] = 2c17027, va=2000000 physaddr=2c17000
2c17000[0x0] = 2000463, va=2000000 physaddr=2000000
...
2c17000[0x1ff] = 21ff463, va=21ff000 physaddr=21ff000
2c05000[0x11] = 2c18027, va=2200000 physaddr=2c18000
2c18000[0x0] = 2200463, va=2200000 physaddr=2200000
...
2c18000[0x1ff] = 23ff463, va=23ff000 physaddr=23ff000
2c05000[0x12] = 2c19027, va=2400000 physaddr=2c19000
2c19000[0x0] = 2400463, va=2400000 physaddr=2400000
...
2c19000[0x1ff] = 25ff463, va=25ff000 physaddr=25ff000
2c05000[0x13] = 2c1a027, va=2600000 physaddr=2c1a000
2c1a000[0x0] = 2600463, va=2600000 physaddr=2600000
...
2c1a000[0x1ff] = 27ff463, va=27ff000 physaddr=27ff000
2c05000[0x14] = 2c1b027, va=2800000 physaddr=2c1b000
2c1b000[0x0] = 2800463, va=2800000 physaddr=2800000
...
2c1b000[0x1ff] = 29ff463, va=29ff000 physaddr=29ff000
2c05000[0x15] = 2c1c027, va=2a00000 physaddr=2c1c000
2c1c000[0x0] = 2a00463, va=2a00000 physaddr=2a00000
...
2c1c000[0x1ff] = 2bff463, va=2bff000 physaddr=2bff000
2c05000[0x16] = 2c06027, va=2c00000 physaddr=2c06000
2c06000[0x0] = 2c00463, va=2c00000 physaddr=2c00000
...
2c06000[0x1c] = 2c1c463, va=2c1c000 physaddr=2c1c000
2c00000[0x1ff] = 2c01027, va=ffffff0000000000 physaddr=2c01000
2c01000[0x1ff] = 2c02027, va=ffffff7fc0000000 physaddr=2c02000
2c02000[0x1dc] = 24005e3, va=ffffff7ffb800000 physaddr=2400000
...
2c02000[0x1df] = 2a005e3, va=ffffff7ffbe00000 physaddr=2a00000
*** DBOOT DONE -- back to asm to jump to kernel
*** Entered Solaris in _start() cmdline is: http://store0.sys.syd.distra.com/tmp/ipxe/platform0/i86pc/kernel/amd64/unix -B console=ttya,kbm_debug=true,prom_debug=true,map_debug=true -kdv
next_phys is 2c1d000
next_virt is 2c1d000
Initializing boot time memory management...done
Initializing boot properties:
Building boot properties
(uintptr_t)propbuf is 2c1e000
(uintptr_t)xbootp is c10100
(uintptr_t)xbootp->bi_module_cnt is 1
(uintptr_t)bm is c10040
(uintptr_t)bm->bm_addr is 2f32f000
bm->bm_size is 109a0000
Parsing command line for boot properties
(uintptr_t)value is 9c778
Boot properties:
0x2c1f420 boot-ncpus = len=2 1
0x2c1f3e0 boot-max-ncpus = len=2 1
0x2c1f3a0 plat-max-ncpus = len=2 1
0x2c1f360 cpu_apicid_array = len=1
0x2c1f320 impl-arch-name = len=6 i86pc
0x2c1f2f0 mfg-name = len=6 i86pc
0x2c1f2c0 stdout = len=4
0x2c1f290 bootargs = len=6 -kdv
0x2c1f260 boot-args = len=6 -kdv
0x2c1f230 map_debug = len=5 true
0x2c1f200 prom_debug = len=5 true
0x2c1f1d0 kbm_debug = len=5 true
0x2c1f1a0 console = len=5 ttya
0x2c1f120 whoami = len=76 http://store0.sys.syd.distra.com/tmp/ipxe/platform0/i86pc/kernel/amd64/unix
0x2c1f0a0 boot-file = len=76 http://store0.sys.syd.distra.com/tmp/ipxe/platform0/i86pc/kernel/amd64/unix
0x2c1f060 ramdisk_end = len=8
0x2c1f020 ramdisk_start = len=8
end Boot properties
jump into krltd...
_kobj_boot
Off to krtld initialization.
384: Entered kobj_init()
388: got prop whoami
420: calling kobj_boot_mountroot
in kobk_boot_mountroot
GETPROPLEN ramdisk_start
ramdisk start len: 8
GETPROPLEN ramdisk_end
ramdisk end len: 8
ramdisk range: 0x2f32f000-3fccf000
top of for loop
inside for loop; i = 0
bfs_ops = 0xfffffffffbc0b2e0
bufs_mountroot)
bkmem_alloc( 0x2010 )
-- !_kmem_ready, so BOP_ALLOC!
-- scratch_max was 0x0
-- BOP_ALLOC returned 0x2c6c000
-- scratch_max IS NOW 0x2c6e010
- ufs_devp = 0xc0f970
bkmem_alloc( 0x6 )
-- !_kmem_ready, so BOP_ALLOC!
-- scratch_max was 0x2c6e010
-- BOP_ALLOC returned 0x2c6f000
-- scratch_max IS NOW 0x2c6f006
- ufs_devp->di_desc = 0xc0f970
bkmem_alloc( 0x2080 )
-- !_kmem_ready, so BOP_ALLOC!
-- scratch_max was 0x2c6f006
-- BOP_ALLOC returned 0x2c70000
-- scratch_max IS NOW 0x2c72080
- head = 0xc0f970
diskread(head) ...
Unexpected trap
error code 0x0
instruction pointer 0xfffffffffb85df0a
code segment 0x28
flags register 0x10006
return %rsp 0xc0fa38
return %ss 0x8
Attempting stack backtrace:
Stack traceback:
Unexpected trap
error code 0x0
instruction pointer 0xfffffffffb82fb60
code segment 0x28
flags register 0x10082
return %rsp 0xfffffffffbc883d0
return %ss 0x8
Attempting stack backtrace:
Stack traceback:
Nested trap
Press any key to reboot.
jclulow@onbld0 unix $ /opt/local/bin/git diff | cat
diff --git a/usr/src/common/fs/ufsops.c b/usr/src/common/fs/ufsops.c
index d4e7826..d8a73a6 100644
--- a/usr/src/common/fs/ufsops.c
+++ b/usr/src/common/fs/ufsops.c
@@ -551,13 +551,23 @@ bufs_mountroot(char *str)
if (ufs_devp) /* already mounted */
return (0);
+ printf("bufs_mountroot( %s )\n", str);
+
ufs_devp = (devid_t *)bkmem_alloc(sizeof (devid_t));
+ printf(" - ufs_devp = 0x%llx\n", ufs_devp);
+
ufs_devp->di_taken = 1;
ufs_devp->di_dcookie = 0;
+
ufs_devp->di_desc = (char *)bkmem_alloc(strlen(str) + 1);
+ printf(" - ufs_devp->di_desc = 0x%llx\n", ufs_devp->di_desc);
+
(void) strcpy(ufs_devp->di_desc, str);
bzero(ufs_devp->un_fs.dummy, SBSIZE);
+
head = (fileid_t *)bkmem_alloc(sizeof (fileid_t));
+ printf(" - head = 0x%x\n", head);
+
head->fi_back = head->fi_forw = head;
head->fi_filedes = 0;
head->fi_taken = 0;
@@ -569,6 +579,7 @@ bufs_mountroot(char *str)
head->fi_memp = (caddr_t)&(ufs_devp->un_fs.di_fs);
head->fi_offset = 0;
+ printf(" diskread(head) ...\n");
if (diskread(head)) {
printf("failed to read superblock\n");
(void) bufs_closeall(1);
@@ -576,11 +587,11 @@ bufs_mountroot(char *str)
}
if (ufs_devp->un_fs.di_fs.fs_magic != FS_MAGIC) {
- dprintf("fs magic = 0x%x\n", ufs_devp->un_fs.di_fs.fs_magic);
+ printf("fs magic = 0x%x\n", ufs_devp->un_fs.di_fs.fs_magic);
(void) bufs_closeall(1);
return (-1);
}
- dprintf("mountroot succeeded\n");
+ printf("mountroot succeeded\n");
return (0);
}
diff --git a/usr/src/uts/common/krtld/bootrd.c b/usr/src/uts/common/krtld/bootrd.c
index 08e5d98..1f3c309 100644
--- a/usr/src/uts/common/krtld/bootrd.c
+++ b/usr/src/uts/common/krtld/bootrd.c
@@ -83,7 +83,28 @@ int
kobj_boot_mountroot()
{
int i;
+ int rd_start_len, rd_end_len;
+ _kobj_printf(ops, "in kobk_boot_mountroot\n");
+
+ _kobj_printf(ops, "GETPROPLEN ramdisk_start\n");
+ rd_start_len = BOP_GETPROPLEN(ops, "ramdisk_start");
+ _kobj_printf(ops, "ramdisk start len: %d\n", rd_start_len);
+
+ _kobj_printf(ops, "GETPROPLEN ramdisk_end\n");
+ rd_end_len = BOP_GETPROPLEN(ops, "ramdisk_end");
+ _kobj_printf(ops, "ramdisk end len: %d\n", rd_end_len);
+
+ if (rd_start_len != 8 || BOP_GETPROP(ops, "ramdisk_start", (void *)&rd_start) != 0) {
+ _kobj_printf(ops, "failed to get ramdisk from boot 1\n");
+ return (-1);
+ }
+ if (rd_end_len != 8 || BOP_GETPROP(ops, "ramdisk_end", (void *)&rd_end) != 0) {
+ _kobj_printf(ops, "failed to get ramdisk from boot 2\n");
+ return (-1);
+ }
+
+#if 0
if (BOP_GETPROPLEN(ops, "ramdisk_start") != 8 ||
BOP_GETPROP(ops, "ramdisk_start", (void *)&rd_start) != 0 ||
BOP_GETPROPLEN(ops, "ramdisk_end") != 8 ||
@@ -92,15 +113,22 @@ kobj_boot_mountroot()
"failed to get ramdisk from boot\n");
return (-1);
}
-#ifdef KOBJ_DEBUG
+#endif
+/*#ifdef KOBJ_DEBUG*/
_kobj_printf(ops,
"ramdisk range: 0x%llx-%llx\n", rd_start, rd_end);
-#endif
+/*#endif*/
+ _kobj_printf(ops, "top of for loop\n");
for (i = 0; bfs_tab[i] != NULL; i++) {
+ _kobj_printf(ops, "inside for loop; i = %d\n", i);
bfs_ops = bfs_tab[i];
- if (BRD_MOUNTROOT(bfs_ops, "dummy") == 0)
+ _kobj_printf(ops, " bfs_ops = 0x%llx\n", bfs_ops);
+ if (BRD_MOUNTROOT(bfs_ops, "dummy") == 0) {
+ _kobj_printf(ops, " selected bootfs = %s\n",
+ bfs_ops->fsw_name);
return (0);
+ }
}
_kobj_printf(ops, "failed to mount ramdisk from boot\n");
return (-1);
@@ -128,16 +156,27 @@ bkmem_alloc(size_t size)
/* allocate from boot scratch memory */
void *addr;
- if (_kmem_ready)
- return (kobj_alloc(size, 0));
+ _kobj_printf(ops, " # bkmem_alloc( 0x%llx )\n", size);
+
+ if (_kmem_ready) {
+ void *x;
+ _kobj_printf(ops, " # _kmem_ready, so kobj_alloc!\n");
+ x = kobj_alloc(size, 0);
+ _kobj_printf(ops, " # returned 0x%llx\n", x);
+ return (x);
+ }
/*
* Remember the highest BOP_ALLOC allocated address and don't free
* anything below it.
*/
+ _kobj_printf(ops, " # !_kmem_ready, so BOP_ALLOC!\n");
addr = BOP_ALLOC(ops, 0, size, 0);
+ _kobj_printf(ops, " # BOP_ALLOC returned 0x%llx\n", addr);
+ _kobj_printf(ops, " # scratch_max was 0x%llx\n", scratch_max);
if (scratch_max < (uintptr_t)addr + size)
scratch_max = (uintptr_t)addr + size;
+ _kobj_printf(ops, " # scratch_max IS NOW 0x%llx\n", scratch_max);
return (addr);
}
diff --git a/usr/src/uts/common/krtld/kobj.c b/usr/src/uts/common/krtld/kobj.c
index 17e27b2..ce313c5 100644
--- a/usr/src/uts/common/krtld/kobj.c
+++ b/usr/src/uts/common/krtld/kobj.c
@@ -161,7 +161,7 @@ extern char stubs_end[];
* D_LOADING - display information about each module as it
* is loaded.
*/
-int kobj_debug = 0;
+int kobj_debug = D_DEBUG | D_SYMBOLS | D_RELOCATIONS | D_LOADING;
#define KOBJ_MARK(s) if (kobj_debug & D_DEBUG) \
(_kobj_printf(ops, "%d", __LINE__), _kobj_printf(ops, ": %s\n", s))
@@ -385,6 +385,8 @@ kobj_init(
(void) BOP_GETPROP(ops, "whoami", filename);
+ KOBJ_MARK("got prop whoami");
+
/*
* We don't support standalone debuggers anymore. The use of kadb
* will interfere with the later use of kmdb. Let the user mend
@@ -415,13 +417,17 @@ kobj_init(
#else
{
/* on x86, we always boot with a ramdisk */
+ KOBJ_MARK("calling kobj_boot_mountroot");
(void) kobj_boot_mountroot();
+ KOBJ_MARK("returned kobj_boot_mountroot");
/*
* Now that the ramdisk is mounted, finish boot property
* initialization.
*/
+ KOBJ_MARK("calling boot_prop_finish");
boot_prop_finish();
+ KOBJ_MARK("returned boot_prop_finish");
}
#if !defined(_UNIX_KRTLD)
diff --git a/usr/src/uts/common/sys/kobj_impl.h b/usr/src/uts/common/sys/kobj_impl.h
index 1dd7da9..c458ef7 100644
--- a/usr/src/uts/common/sys/kobj_impl.h
+++ b/usr/src/uts/common/sys/kobj_impl.h
@@ -113,9 +113,9 @@ typedef struct kobj_notify_list {
#define ALIGN(x, a) ((a) == 0 ? (uintptr_t)(x) : \
(((uintptr_t)(x) + (uintptr_t)(a) - 1l) & ~((uintptr_t)(a) - 1l)))
-#ifdef DEBUG
+/*#ifdef DEBUG*/
#define KOBJ_DEBUG
-#endif
+/*#endif*/
#ifdef KOBJ_DEBUG
/*
diff --git a/usr/src/uts/i86pc/dboot/dboot_startkern.c b/usr/src/uts/i86pc/dboot/dboot_startkern.c
index 8e69766..2f7835c 100644
--- a/usr/src/uts/i86pc/dboot/dboot_startkern.c
+++ b/usr/src/uts/i86pc/dboot/dboot_startkern.c
@@ -809,6 +809,7 @@ init_mem_alloc(void)
*/
DBG_MSG("\nFinding Modules\n");
check_higher((paddr_t)(uintptr_t)&_end);
+ check_higher(0x2000000);
for (mod = (mb_module_t *)(mb_info->mods_addr), i = 0;
i < mb_info->mods_count;
++mod, ++i) {
@@ -824,7 +825,7 @@ init_mem_alloc(void)
}
modules[i].bm_size = mod->mod_end - mod->mod_start;
- check_higher(mod->mod_end);
+ // XXX check_higher(mod->mod_end);
}
bi->bi_modules = (native_ptr_t)(uintptr_t)modules;
DBG(bi->bi_modules);
@@ -843,7 +844,7 @@ init_mem_alloc(void)
DBG(mb_info->mmap_addr);
DBG(mb_info->mmap_length);
- check_higher(mb_info->mmap_addr + mb_info->mmap_length);
+ // XXX check_higher(mb_info->mmap_addr + mb_info->mmap_length);
for (mmap = (mb_memory_map_t *)mb_info->mmap_addr;
(uint32_t)mmap < mb_info->mmap_addr + mb_info->mmap_length;
@@ -917,7 +918,12 @@ init_mem_alloc(void)
dboot_panic("No memory info from boot loader!!!");
}
- check_higher(bi->bi_cmdline);
+ // XXX check_higher(bi->bi_cmdline);
+ DBG_MSG("\n################## JMC ###########\n");
+ DBG(mb_info->mmap_addr + mb_info->mmap_length);
+ DBG(bi->bi_cmdline);
+ //check_higher(1024*1024*512);
+ DBG_MSG( "################## JMC ###########\n");
/*
* finish processing the physinstall list
@@ -931,6 +937,21 @@ init_mem_alloc(void)
}
#endif /* !__xpv */
+static int
+regions_overlap(uint64_t start1, uint64_t size1, uint64_t start2,
+ uint64_t size2)
+{
+ uint64_t end1 = start1 + size1;
+ uint64_t end2 = start2 + size2;
+
+ if ((start1 >= start2 && start1 <= end2) ||
+ (end1 >= start2 && end1 <= end2) ||
+ (start2 >= start1 && start2 <= end1) ||
+ (end2 >= start1 && end2 <= end1))
+ return (1);
+ return (0);
+}
+
/*
* Simple memory allocator, allocates aligned physical memory.
* Note that startup_kernel() only allocates memory, never frees.
@@ -939,7 +960,7 @@ init_mem_alloc(void)
static void *
do_mem_alloc(uint32_t size, uint32_t align)
{
- uint_t i;
+ uint_t i, j;
uint64_t best;
uint64_t start;
uint64_t end;
@@ -966,6 +987,42 @@ do_mem_alloc(uint32_t size, uint32_t align)
end = start + memlists[i].size;
/*
+ * do we overlap with mb_info? if so, skip it.
+ */
+ if (regions_overlap(next_avail_addr, size,
+ (uintptr_t)mb_info, PAGESIZE)) {
+ DBG_MSG("******** SKIPPING mb_info\n");
+ next_avail_addr = RNDUP(next_avail_addr + PAGESIZE,
+ align);
+ DBG(next_avail_addr);
+ }
+
+ /*
+ * do we overlap with cmd_line? if so, skip it.
+ */
+ if (regions_overlap(next_avail_addr, size,
+ (uintptr_t)bi->bi_cmdline, PAGESIZE)) {
+ DBG_MSG("******** SKIPPING cmd_line\n");
+ next_avail_addr = RNDUP(next_avail_addr + PAGESIZE,
+ align);
+ DBG(next_avail_addr);
+ }
+
+ /*
+ * do we overlap with any module? if so, skip them.
+ */
+ for (j = 0; j < bi->bi_module_cnt; j++) {
+ if (regions_overlap(next_avail_addr, size,
+ (uintptr_t)modules[j].bm_addr,
+ modules[j].bm_size)) {
+ DBG_MSG("******** SKIPPING module\n");
+ next_avail_addr = RNDUP(modules[j].bm_addr +
+ modules[j].bm_size, align);
+ DBG(next_avail_addr);
+ }
+ }
+
+ /*
* did we find the desired address?
*/
if (start <= next_avail_addr && next_avail_addr + size <= end) {
diff --git a/usr/src/uts/i86pc/os/fakebop.c b/usr/src/uts/i86pc/os/fakebop.c
index d38bcb0..71df4a6 100644
--- a/usr/src/uts/i86pc/os/fakebop.c
+++ b/usr/src/uts/i86pc/os/fakebop.c
@@ -74,7 +74,7 @@ static char *boot_args = "";
/*
* Debugging macros
*/
-static uint_t kbm_debug = 0;
+static uint_t kbm_debug = 1;
#define DBG_MSG(s) { if (kbm_debug) bop_printf(NULL, "%s", s); }
#define DBG(x) { if (kbm_debug) \
bop_printf(NULL, "%s is %" PRIx64 "\n", #x, (uint64_t)(x)); \
@@ -1183,8 +1183,13 @@ build_boot_properties(void)
DBG_MSG("Building boot properties\n");
propbuf = do_bsys_alloc(NULL, NULL, MMU_PAGESIZE, 0);
DBG((uintptr_t)propbuf);
+ DBG((uintptr_t)xbootp);
+ DBG((uintptr_t)xbootp->bi_module_cnt);
if (xbootp->bi_module_cnt > 0) {
bm = xbootp->bi_modules;
+ DBG((uintptr_t)bm);
+ DBG((uintptr_t)bm->bm_addr);
+ DBG(bm->bm_size);
bsetprop64("ramdisk_start", (uint64_t)(uintptr_t)bm->bm_addr);
bsetprop64("ramdisk_end", (uint64_t)(uintptr_t)bm->bm_addr +
bm->bm_size);
@@ -1192,6 +1197,7 @@ build_boot_properties(void)
DBG_MSG("Parsing command line for boot properties\n");
value = xbootp->bi_cmdline;
+ DBG((uintptr_t)value);
/*
* allocate memory to collect boot_args into
@@ -1833,11 +1839,13 @@ _start(struct xboot_info *xbp)
}
bop_printf(NULL, "\n");
}
+ DBG_MSG("\nend Boot properties\n");
}
/*
* jump into krtld...
*/
+ DBG_MSG("\njump into krltd...\n");
_kobj_boot(&bop_sysp, NULL, bops, NULL);
}
diff --git a/usr/src/uts/intel/amd64/krtld/kobj_boot.c b/usr/src/uts/intel/amd64/krtld/kobj_boot.c
index b63486f..394da24 100644
--- a/usr/src/uts/intel/amd64/krtld/kobj_boot.c
+++ b/usr/src/uts/intel/amd64/krtld/kobj_boot.c
@@ -58,6 +58,8 @@ _kobj_boot(
val_t bootaux[BA_NUM];
int i;
+ bop_printf(NULL, "%s", "_kobj_boot\n");
+
for (i = 0; i < BA_NUM; i++)
bootaux[i].ba_val = NULL;
@@ -68,5 +70,6 @@ _kobj_boot(
/*
* Off to krtld initialization.
*/
+ bop_printf(NULL, "%s", "Off to krtld initialization.\n");
kobj_init(syscallp, dvec, bootops, bootaux);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment