05_start_kernel - ned0000/Linux-kernel-notes GitHub Wiki
Analysis to function start_kernel(). The routines called in this function are explained one by one.
set_task_stack_end_magic()
The routine sets the end of the init task's stack to a magic number, it's for overflow detection.
smp_setup_processor_id()
Empty routine.
debug_objects_early_init()
The routine is only available when DEBUG_OBJECTS (Kernel hacking > Memory Debugging > Debug object operations) is enabled. When enabled, additional code is inserted into the kernel to track the life time of various objects and validate the operations on those objects.
cgroup_init_early()
The routine is only available when CGROUPS (General setup > Control Group support) is enabled. When enabled, kernel can support for grouping sets of processes together, for use with process control subsystems such as cpusets, CFS, memory and etc.
local_irq_disable()
Disable irq on current CPU.
early_boot_irqs_disabled
Set this global variable to true. The variable is defined in init/main.c.
boot_cpu_init()
The routine marks the boot CPU “online“, “active”, “present” and “possible”.
page_address_init()
The routine is only available when HIGHMEM is enabled. In our configuration, 64-bit kernel is used and HIGHMEM is disabled.
pr_notice()
Call printk to print linux banner like below. It’s the first log in the kernel ring buffer.
Linux version 4.15.0-54-generic ……
setup_arch()
Architecture-specific boot-time initializations. The process is complex and it will be explained later.
add_latent_entropy()
The routine is only available when GCC_PLUGIN_LATENT_ENTROPY (General architecture-dependent options > GCC plugins) is enabled. When enabled, the routine adds latent entropy to kernel. The latent entropy tries to generate entropy from the kernel’s execution at early boot.
add_device_randomness()
Add randomness to random device. The entropy is from init command_line.
boot_init_stack_canary()
The routine is only available when STACKPROTECTOR (General architecture-dependent options > Stack Protector buffer overflow detection) is enabled. When enabled, the routine initialize the stack protector canary value. The stack protector feature puts a canary value on the stack just before the return address, and validates the value just before actually returning.
mm_init_cpumask()
Clear the bitmap cpu_bitmap in global variable init_mm, the variable’s type is mm_struct data structure.
setup_command_line()
Store the untouched command line for future reference. Store the touched command line also since the parameter parsing is performed in place.