X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..bd504ef0e0b883cdd7917b73b3574eb9ce669905:/osfmk/kern/startup.c?ds=sidebyside diff --git a/osfmk/kern/startup.c b/osfmk/kern/startup.c index 47290e3d8..e17631376 100644 --- a/osfmk/kern/startup.c +++ b/osfmk/kern/startup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2009 Apple Inc. All rights reserved. + * Copyright (c) 2000-2010 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -69,7 +69,6 @@ #include #include #include -#include #include #include @@ -119,6 +118,7 @@ #include #endif +#include static void kernel_bootstrap_thread(void); static void load_context( @@ -143,6 +143,7 @@ extern int serverperfmode; /* size of kernel trace buffer, disabled by default */ unsigned int new_nkdbufs = 0; +unsigned int wake_nkdbufs = 0; /* mach leak logging */ int log_leaks = 0; @@ -178,6 +179,8 @@ kernel_bootstrap(void) PE_parse_boot_argn("trace", &new_nkdbufs, sizeof (new_nkdbufs)); + PE_parse_boot_argn("trace_wake", &wake_nkdbufs, sizeof (wake_nkdbufs)); + /* i386_vm_init already checks for this ; do it aagin anyway */ if (PE_parse_boot_argn("serverperfmode", &serverperfmode, sizeof (serverperfmode))) { serverperfmode = 1; @@ -226,13 +229,11 @@ kernel_bootstrap(void) kernel_bootstrap_kprintf("calling clock_init\n"); clock_init(); + ledger_init(); /* * Initialize the IPC, task, and thread subsystems. */ - kernel_bootstrap_kprintf("calling ledger_init\n"); - ledger_init(); - kernel_bootstrap_kprintf("calling task_init\n"); task_init(); @@ -250,13 +251,6 @@ kernel_bootstrap(void) thread->state = TH_RUN; thread_deallocate(thread); - /* transfer statistics from init thread to kernel */ - thread_t init_thread = current_thread(); - kernel_task->tkm_private.alloc = init_thread->tkm_private.alloc; - kernel_task->tkm_private.free = init_thread->tkm_private.free; - kernel_task->tkm_shared.alloc = init_thread->tkm_shared.alloc; - kernel_task->tkm_shared.free = init_thread->tkm_shared.free; - kernel_bootstrap_kprintf("calling load_context - done\n"); load_context(thread); /*NOTREACHED*/ @@ -264,6 +258,8 @@ kernel_bootstrap(void) int kth_started = 0; +vm_offset_t vm_kernel_addrperm; + /* * Now running in a thread. Kick off other services, * invoke user bootstrap, enter pageout loop. @@ -326,11 +322,6 @@ kernel_bootstrap_thread(void) device_service_create(); kth_started = 1; - -#if MACH_KDP - kernel_bootstrap_kprintf("calling kdp_init\n"); - kdp_init(); -#endif #if (defined(__i386__) || defined(__x86_64__)) && NCOPY_WINDOWS > 0 /* @@ -340,6 +331,13 @@ kernel_bootstrap_thread(void) cpu_physwindow_init(0); #endif + vm_kernel_reserved_entry_init(); + +#if MACH_KDP + kernel_bootstrap_kprintf("calling kdp_init\n"); + kdp_init(); +#endif + #if CONFIG_COUNTERS pmc_bootstrap(); #endif @@ -347,7 +345,7 @@ kernel_bootstrap_thread(void) #if (defined(__i386__) || defined(__x86_64__)) if (turn_on_log_leaks && !new_nkdbufs) new_nkdbufs = 200000; - start_kern_tracing(new_nkdbufs); + start_kern_tracing(new_nkdbufs, FALSE); if (turn_on_log_leaks) log_leaks = 1; #endif @@ -372,7 +370,7 @@ kernel_bootstrap_thread(void) #if (!defined(__i386__) && !defined(__x86_64__)) if (turn_on_log_leaks && !new_nkdbufs) new_nkdbufs = 200000; - start_kern_tracing(new_nkdbufs); + start_kern_tracing(new_nkdbufs, FALSE); if (turn_on_log_leaks) log_leaks = 1; #endif @@ -382,11 +380,21 @@ kernel_bootstrap_thread(void) */ vm_shared_region_init(); vm_commpage_init(); + vm_commpage_text_init(); #if CONFIG_MACF mac_policy_initmach(); #endif + /* + * Initialize the global used for permuting kernel + * addresses that may be exported to userland as tokens + * using VM_KERNEL_ADDRPERM(). Force the random number + * to be odd to avoid mapping a non-zero + * word-aligned address to zero via addition. + */ + vm_kernel_addrperm = (vm_offset_t)early_random() | 1; + /* * Start the user bootstrap. */ @@ -495,7 +503,7 @@ load_context( * should never occur since the thread is expected * to have reserved stack. */ - load_context_kprintf("stack %x, stackptr %x\n", + load_context_kprintf("thread %p, stack %x, stackptr %x\n", thread, thread->kernel_stack, thread->machine.kstackptr); if (!thread->kernel_stack) { load_context_kprintf("calling stack_alloc_try\n"); @@ -559,7 +567,6 @@ scale_setup() bsd_scale_setup(scale); ipc_space_max = SPACE_MAX; - ipc_tree_entry_max = ITE_MAX; ipc_port_max = PORT_MAX; ipc_pset_max = SET_MAX; semaphore_max = SEMAPHORE_MAX;