This manual is for program, version version.
| • overview: | ||
| • set_task_stack_end_magic: | ||
| • smp_setup_processor_id: | ||
| • cgroup_init_early: |
Next: set_task_stack_end_magic, Previous: Top, Up: Top [Contents]
// CPP init/main.c source code
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=../out init/main.i
__attribute__((externally_visible)) void __attribute__ ((__section__(".init.text"))) __attribute__((__cold__)) __attribute__((no_instrument_function)) start_kernel(void)
{
char *command_line;
char *after_dashes;
do { } while (0);
set_task_stack_end_magic(&init_task);
smp_setup_processor_id();
debug_objects_early_init();
boot_init_stack_canary();
cgroup_init_early();
do { arch_local_irq_disable(); } while (0);
early_boot_irqs_disabled = true;
boot_cpu_init();
do { } while(0);
printk("\001" "5" "%s", linux_banner);
setup_arch(&command_line);
mm_init_cpumask(&init_mm);
setup_command_line(command_line);
setup_nr_cpu_ids();
setup_per_cpu_areas();
smp_prepare_boot_cpu();
build_all_zonelists(((void *)0), ((void *)0));
page_alloc_init();
printk("\001" "5" "Kernel command line: %s\n", boot_command_line);
parse_early_param();
after_dashes = parse_args("Booting kernel",
static_command_line, __start___param,
__stop___param - __start___param,
-1, -1, &unknown_bootoption);
if (!IS_ERR_OR_NULL(after_dashes))
parse_args("Setting init args", after_dashes, ((void *)0), 0, -1, -1,
set_init_arg);
jump_label_init();
setup_log_buf(0);
pidhash_init();
vfs_caches_init_early();
sort_main_extable();
trap_init();
mm_init();
sched_init();
do { __preempt_count_add(1); __asm__ __volatile__("": : :"memory"); } while (0);
if (({ int __ret_warn_on = !!(!({ unsigned long _flags;
do { ({ unsigned long __dummy; typeof(_flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); _flags = arch_local_save_flags(); } while (0);
({ ({ unsigned long __dummy; typeof(_flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_irqs_disabled_flags(_flags); }); }));
if (__builtin_expect(!!(__ret_warn_on), 0)) warn_slowpath_fmt(
"/home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c"
567 "/home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c"
,
568
567 "/home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c"
, "Interrupts were enabled *very* early, fixing it\n"); __builtin_expect(!!(__ret_warn_on), 0); })
)
do { arch_local_irq_disable(); } while (0);
idr_init_cache();
rcu_init();
trace_init();
context_tracking_init();
radix_tree_init();
early_irq_init();
init_IRQ();
tick_init();
rcu_init_nohz();
init_timers();
hrtimers_init();
softirq_init();
timekeeping_init();
time_init();
sched_clock_postinit();
perf_event_init();
profile_init();
call_function_init();
({ int __ret_warn_on = !!(!({ unsigned long _flags;
do { ({ unsigned long __dummy; typeof(_flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); _flags = arch_local_save_flags(); }
while (0); ({ ( { unsigned long __dummy; typeof(_flags) __dummy2; (void)(&__dummy == &__dummy2); 1; });
arch_irqs_disabled_flags(_flags); }); })); if (__builtin_expect(!!(__ret_warn_on), 0))
warn_slowpath_fmt("/home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c", 592, "Interrupts were enabled early\n");
__builtin_expect(!!(__ret_warn_on), 0); });
early_boot_irqs_disabled = false;
do { arch_local_irq_enable(); } while (0);
kmem_cache_init_late();
console_init();
if (panic_later)
panic("Too many boot %s vars at `%s'", panic_later,
panic_param);
do { } while (0);
do { } while (0);
if (initrd_start && !initrd_below_start_ok &&
(unsigned long)(((((struct page *)((((0xffffffffffffffffUL) << ((39) - 1)) - (1UL << ((12 - 3) * 3 + 3)) -
(((((1UL << ((39) - 12)) * sizeof(struct page))) + ((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1))
& ~((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1)) - 0x00010000) + 0x00010000)) +
((((phys_addr_t)((unsigned long)((void *)initrd_start)) - ((0xffffffffffffffffUL) << ((39) - 1)) + ({ memstart_addr; }))) >> 12))) -
((struct page *)((((0xffffffffffffffffUL) << ((39) - 1)) - (1UL << ((12 - 3) * 3 + 3)) - (((((1UL << ((39) - 12)) * sizeof(struct page))) +
((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1))
& ~((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1)) - 0x00010000) + 0x00010000))) < min_low_pfn)
{
printk("\001" "2" "initrd overwritten (0x%08lx < 0x%08lx) - disabling it.\n",
(unsigned long)(((((struct page *)((((0xffffffffffffffffUL) << ((39) - 1)) - (1UL << ((12 - 3) * 3 + 3)) -
(((((1UL << ((39) - 12)) * sizeof(struct page))) + ((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1))
& ~((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1)) - 0x00010000) + 0x00010000)) +
((((phys_addr_t)((unsigned long)((void *)initrd_start)) - ((0xffffffffffffffffUL) << ((39) - 1)) + ({ memstart_addr; }))) >> 12))) -
((s truct page *)((((0xffffffffffffffffUL) << ((39) - 1)) - (1UL << ((12 - 3) * 3 + 3)) - (((((1UL << ((39) - 12)) * sizeof(struct page))) +
((typeof(((1UL << ((39) - 12)) * sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1)) & ~((typeof(((1UL << ((39) - 12)) *
sizeof(struct page))))(((1UL << ((12 - 3) * 3 + 3)))) - 1)) - 0x00010000) + 0x00010000))), min_low_pfn)
;
initrd_start = 0;
}
page_ext_init();
debug_objects_mem_init();
kmemleak_init();
setup_per_cpu_pageset();
numa_policy_init();
if (late_time_init)
late_time_init();
sched_clock_init();
calibrate_delay();
pidmap_init();
anon_vma_init();
acpi_early_init();
646 "/home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c"
thread_info_cache_init();
cred_init();
fork_init();
proc_caches_init();
buffer_init();
key_init();
security_init();
;
vfs_caches_init(totalram_pages);
signals_init();
page_writeback_init();
proc_root_init();
nsfs_init();
cpuset_init();
cgroup_init();
taskstats_init_early();
delayacct_init();
check_bugs();
acpi_subsystem_init();
sfi_init_late();
if (efi_enabled(3)) {
efi_late_init();
efi_free_boot_services();
}
ftrace_init();
rest_init();
}
Next: smp_setup_processor_id, Previous: overview, Up: Top [Contents]
start_kernel
(gdb) bt
#0 set_task_stack_end_magic (tsk=<optimized out>) at /home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/kernel/fork.c:326
#1 0xffffffc0007ee5f8 in start_kernel () at /home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c:502
init/main.c
492 asmlinkage __visible void __init start_kernel(void)
502 set_task_stack_end_magic(&init_task);
kernel/fork.c
320 void set_task_stack_end_magic(struct task_struct *tsk)
321 {
322 unsigned long *stackend;
323
324 stackend = end_of_stack(tsk);
325 *stackend = STACK_END_MAGIC; /* for overflow detection */
326 }
...
include/uapi/linux/magic.h
59 #define STACK_END_MAGIC 0x57AC6E9D
...
2702 /*
2703 * Return the address of the last usable long on the stack.
2704 *
2705 * When the stack grows down, this is just above the thread
2706 * info struct. Going any lower will corrupt the threadinfo.
2707 *
2708 * When the stack grows up, this is the highest address.
2709 * Beyond that position, we corrupt data on the next page.
2710 */
2711 static inline unsigned long *end_of_stack(struct task_struct *p)
2712 {
2713 #ifdef CONFIG_STACK_GROWSUP
2714 return (unsigned long *)((unsigned long)task_thread_info(p) + THREAD_SIZE) - 1;
2715 #else
2716 return (unsigned long *)(task_thread_info(p) + 1); <=== here
2717 #endif
2718 }
...
2693 #define task_thread_info(task) ((struct thread_info *)(task)->stack)
...
(gdb) p init_task
$3 = {state = 0, stack = 0xffffffc000ac8000 <init_thread_union>, usage = {counter = 2}, flags = 2097152, ptrace = 0,
wake_entry = {next = 0x0}, on_cpu = 0, last_wakee = 0x0,
wakee_flips = 0, wakee_flip_decay_ts = 0, wake_cpu = 0, on_rq = 0, prio = 120, static_prio = 120,
normal_prio = 120, rt_priority = 0, sched_class = 0x0, se = {load = {weight = 0,
inv_weight = 0}, run_node = {__rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0},
group_node = {next = 0xffffffc000ad4d00 <init_task+144>,
prev = 0xffffffc000ad4d00 <init_task+144>}, on_rq = 0, exec_start = 0, sum_exec_runtime = 0, vruntime = 0,
prev_sum_exec_runtime = 0, nr_migrations = 0, depth = 0, parent = 0x0,
cfs_rq = 0x0, my_q = 0x0, avg = {last_runnable_update = 0, decay_count = 0, load_avg_contrib = 0,
utilization_avg_contrib = 0, runnable_avg_sum = 0, avg_period = 0,
running_avg_sum = 0}}, rt = {run_list = {next = 0xffffffc000ad4d90 <init_task+288>, prev = 0xffffffc000ad4d90 <init_task+288>},
timeout = 0, watchdog_stamp = 0, time_slice = 10,
back = 0x0}, sched_task_group = 0xffffffc000b3a860 <root_task_group>, dl = {rb_node = {__rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0},
dl_runtime = 0, dl_deadline = 0,
dl_period = 0, dl_bw = 0, runtime = 0, deadline = 0, flags = 0, dl_throttled = 0, dl_new = 0,
dl_boosted = 0, dl_yielded = 0, dl_timer = {node = {node = {__rb_parent_color = 0,
rb_right = 0x0, rb_left = 0x0}, expires = {tv64 = 0}}, _softexpires = {tv64 = 0},
function = 0x0, base = 0x0, state = 0}}, preempt_notifiers = {first = 0x0}, policy = 0,
nr_cpus_allowed = 64, cpus_allowed = {bits = {18446744073709551615}}, rcu_read_lock_nesting = 0,
rcu_read_unlock_special = {b = {blocked = false, need_qs = false}, s = 0},
rcu_node_entry = {next = 0xffffffc000ad4e88 <init_task+536>, prev = 0xffffffc000ad4e88 <init_task+536>},
rcu_blocked_node = 0x0, sched_info = {pcount = 0, run_delay = 0, last_arrival = 0,
last_queued = 0}, tasks = {next = 0xffffffc000ad4ec0 <init_task+592>, prev = 0xffffffc000ad4ec0 <init_task+592>},
pushable_tasks = {prio = 140, prio_list = {
next = 0xffffffc000ad4ed8 <init_task+616>, prev = 0xffffffc000ad4ed8 <init_task+616>},
node_list = {next = 0xffffffc000ad4ee8 <init_task+632>,
prev = 0xffffffc000ad4ee8 <init_task+632>}}, pushable_dl_tasks = {__rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0},
mm = 0x0, active_mm = 0xffffffc000ae29e8 <init_mm>,
vmacache_seqnum = 0, vmacache = {0x0, 0x0, 0x0, 0x0}, rss_stat = {events = 0, count = {0, 0, 0}},
exit_state = 0, exit_code = 0, exit_signal = 0, pdeath_signal = 0, jobctl = 0,
personality = 0, in_execve = 0, in_iowait = 0, sched_reset_on_fork = 0, sched_contributes_to_load = 0, memcg_kmem_skip_account = 0,
atomic_flags = 0, restart_block = {
fn = 0xffffffc0000c065c <do_no_restart_syscall>, {futex = {uaddr = 0x0, val = 0, flags = 0, bitset = 0, time = 0, uaddr2 = 0x0},
nanosleep = {clockid = 0, rmtp = 0x0, compat_rmtp = 0x0,
expires = 0}, poll = {ufds = 0x0, nfds = 0, has_timeout = 0, tv_sec = 0, tv_nsec = 0}}},
pid = 0, tgid = 0, real_parent = 0xffffffc000ad4c70 <init_task>,
parent = 0xffffffc000ad4c70 <init_task>, children = {next = 0xffffffc000ad4fc8 <init_task+856>, prev = 0xffffffc000ad4fc8 <init_task+856>},
sibling = {
next = 0xffffffc000ad4fd8 <init_task+872>, prev = 0xffffffc000ad4fd8 <init_task+872>}, group_leader = 0xffffffc000ad4c70 <init_task>, ptraced = {
next = 0xffffffc000ad4ff0 <init_task+896>, prev = 0xffffffc000ad4ff0 <init_task+896>}, ptrace_entry = {next = 0xffffffc000ad5000 <init_task+912>,
prev = 0xffffffc000ad5000 <init_task+912>}, pids = {{node = {next = 0x0, pprev = 0x0}, pid = 0xffffffc000adc5b8 <init_struct_pid>},
{node = {next = 0x0, pprev = 0x0},
pid = 0xffffffc000adc5b8 <init_struct_pid>}, {node = {next = 0x0, pprev = 0x0}, pid = 0xffffffc000adc5b8 <init_struct_pid>}},
thread_group = {
next = 0xffffffc000ad5058 <init_task+1000>, prev = 0xffffffc000ad5058 <init_task+1000>},
thread_node = {next = 0xffffffc000ad5fb8 <init_signals+16>,
prev = 0xffffffc000ad5fb8 <init_signals+16>}, vfork_done = 0x0, set_child_tid = 0x0, clear_child_tid = 0x0, utime = 0, stime = 0,
utimescaled = 0, stimescaled = 0, gtime = 0,
prev_cputime = {utime = 0, stime = 0}, nvcsw = 0, nivcsw = 0, start_time = 0, real_start_time = 0, min_flt = 0, maj_flt = 0,
cputime_expires = {utime = 0, stime = 0,
sum_exec_runtime = 0}, cpu_timers = {{next = 0xffffffc000ad5110 <init_task+1184>, prev = 0xffffffc000ad5110 <init_task+1184>},
{next = 0xffffffc000ad5120 <init_task+1200>,
prev = 0xffffffc000ad5120 <init_task+1200>}, {next = 0xffffffc000ad5130 <init_task+1216>, prev = 0xffffffc000ad5130 <init_task+1216>}},
real_cred = 0xffffffc000adc9e8 <init_cred>,
cred = 0xffffffc000adc9e8 <init_cred>, comm = "swapper\000\000\000\000\000\000\000\000", link_count = 0, total_link_count = 0,
sysvsem = {undo_list = 0x0}, sysvshm = {shm_clist = {
next = 0x0, prev = 0x0}}, last_switch_count = 0, thread = {cpu_context = {x19 = 0, x20 = 0, x21 = 0, x22 = 0,
x23 = 0, x24 = 0, x25 = 0, x26 = 0, x27 = 0, x28 = 0, fp = 0, sp = 0,
pc = 0}, tp_value = 0, fpsimd_state = {{user_fpsimd = {vregs = {0 <repeats 32 times>}, fpsr = 0, fpcr = 0},
{vregs = {0 <repeats 32 times>}, fpsr = 0, fpcr = 0}}, cpu = 0},
fault_address = 0, fault_code = 0, debug = {suspended_step = 0, bps_disabled = 0, wps_disabled = 0, hbp_break = {0x0 <repeats 16 times>},
hbp_watch = {0x0 <repeats 16 times>}}},
---Type <return> to continue, or q <return> to quit---
fs = 0xffffffc000ae69a0 <init_fs>, files = 0xffffffc000ae65c0 <init_files>, nsproxy = 0xffffffc000adc860 <init_nsproxy>,
signal = 0xffffffc000ad5fa8 <init_signals>,
sighand = 0xffffffc000ad5780 <init_sighand>, blocked = {sig = {0}},
real_blocked = {sig = {0}}, saved_sigmask = {sig = {0}}, pending = {list = {next = 0xffffffc000ad5580 <init_task+2320>,
prev = 0xffffffc000ad5580 <init_task+2320>},
signal = {sig = {0}}}, sas_ss_sp = 0, sas_ss_size = 0, notifier = 0x0, notifier_data = 0x0, notifier_mask = 0x0, task_works = 0x0,
audit_context = 0x0, seccomp = {<No data fields>}, parent_exec_id = 0, self_exec_id = 0,
alloc_lock = {{rlock = {raw_lock = {owner = 0, next = 0}}}}, pi_lock = {raw_lock = {owner = 0,
next = 0}}, pi_waiters = {rb_node = 0x0},
pi_waiters_leftmost = 0x0, pi_blocked_on = 0x0, journal_info = 0x0, bio_list = 0x0, plug = 0x0, reclaim_state = 0x0, backing_dev_info = 0x0,
io_context = 0x0, ptrace_message = 0, last_siginfo = 0x0,
ioac = {rchar = 0, wchar = 0, syscr = 0, syscw = 0, read_bytes = 0, write_bytes = 0, cancelled_write_bytes = 0},
acct_rss_mem1 = 0, acct_vm_mem1 = 0, acct_timexpd = 0, cgroups = 0x0, cg_list = {next = 0x0, prev = 0x0},
robust_list = 0x0, compat_robust_list = 0x0, pi_state_list = {next = 0x0,
prev = 0x0}, pi_state_cache = 0x0, perf_event_ctxp = {0x0, 0x0}, perf_event_mutex = {count = {counter = 1},
wait_lock = {{rlock = {raw_lock = {owner = 0, next = 0}}}}, wait_list = {
next = 0xffffffc000ad56e0 <init_task+2672>, prev = 0xffffffc000ad56e0 <init_task+2672>},
owner = 0x0, osq = {tail = {counter = 0}}}, perf_event_list = {
next = 0xffffffc000ad5700 <init_task+2704>, prev = 0xffffffc000ad5700 <init_task+2704>},
rcu = {next = 0x0, func = 0x0}, splice_pipe = 0x0, task_frag = {page = 0x0, offset = 0,
size = 0}, delays = 0x0, nr_dirtied = 0, nr_dirtied_pause = 0,
dirty_paused_when = 0, timer_slack_ns = 50000, default_timer_slack_ns = 0, memcg_oom = {memcg = 0x0, gfp_mask = 0,
order = 0, may_oom = 0}}
...
(gdb) p sizeof(struct thread_info)
$4 = 32
...
(gdb) x/8gx 0xffffffc000ac8000
0xffffffc000ac8000 <init_thread_union>: 0x0000000000000000 0xffffffffffffffff
0xffffffc000ac8010 <init_thread_union+16>: 0xffffffc000ad4c70 0x0000000000200001
0xffffffc000ac8020 <init_thread_union+32>: 0x0000000057ac6e9d 0x0000000000000000
0xffffffc000ac8030 <init_thread_union+48>: 0x0000000000000000 0x0000000000000000
Next: cgroup_init_early, Previous: set_task_stack_end_magic, Up: Top [Contents]
start_kernel
set_task_stack_end_magic(&init_task);
smp_setup_processor_id();
(gdb) bt
#0 smp_setup_processor_id () at /home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/arch/arm64/kernel/setup.c:127
#1 0xffffffc0007ee5fc in start_kernel () at /home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c:503
...
125 void __init smp_setup_processor_id(void)
126 {
127 u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
128 cpu_logical_map(0) = mpidr;
129
130 /*
131 * clear __my_cpu_offset on boot CPU to avoid hang caused by
132 * using percpu variable early, for example, lockdep will
133 * access percpu variable inside lock_release
134 */
135 set_my_cpu_offset(0);
136 pr_info("Booting Linux on physical CPU 0x%lx\n", (unsigned long)mpidr);
137 }
...
arch/arm64/include/asm/cputype.h
99 static inline u64 __attribute_const__ read_cpuid_mpidr(void)
100 {
101 return read_cpuid(MPIDR_EL1);
102 }
...
arch/arm64/include/asm/cputype.h
35 #define read_cpuid(reg) ({ \
36 u64 __val; \
37 asm("mrs %0, " #reg : "=r" (__val)); \
38 __val; \
39 })
Previous: smp_setup_processor_id, Up: Top [Contents]
start_kernel set_task_stack_end_magic(&init_task); smp_setup_processor_id(); cgroup_init_early(); (gdb) bt #0 cgroup_init_early () at /home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/kernel/cgroup.c:4957 #1 0xffffffc0007ee600 in start_kernel () at /home/zzy/sdb/01study/kern4.1_arm64_env/linux-4.1.16/init/main.c:511 ...