Linux Kernel Init Process

Post on 14-Jan-2017

380 views 0 download

transcript

Boaz Taitler

KERNEL INIT PROCESS

Boaz Taitler

About me

On the menu

• Module Init

• Initcalls Sections

• Init pages clean up

• Run init process

Module Init/Exit

But how?!

The Magic - SectionsInclude/asm-generic/vmlinux.lds.h

Sections - example

Symbol group 3

Symbol group 2

Symbol group 1

Symbol group 4

Sections - example

Con_initcall

Init_calls

Init_setup

Security_initcall

__setup_start

__setup_end

__initcall_start

__initcall_end

__con_initcall_start

__con_initcall_end

__security_initcall_start

__security_initcall_end

The gathering - Initcall

The gathering - Initcall

The Result:System.map

Example:

Let’s call ‘em!

Init/main.c (v3.2)

Demonstration: part 1Include/asm-generic/vmlinux.lds.h

Include/linux/init.h

Demonstration: part 2

Arch/arm/kernel/vmlinux.lds.S

Demonstration: part 3

Demonstration: part 4

Do it yourself: ResultSystem.map

Cons / Pros:• Cons:

• Require more memory

• Architecture dependent

• Pros:• Easy for maintenance

• Generic Calls

• Looks cool :D

When to use

When you:

• Need to add new calls

• Don’t want to affect the function where you summon the calls

• Want to iterate over functions.

Init examples:

U-boot VS Barebox

U-boot

U-boot 2009Lib_app/board.c

Barebox

Conclusions

1. Init calls can be called __barebox_cmd

2. Summing 2 pictures result in a big picture

Finishing touches

• Clean init pages

• Run init process

Clear init pages

Free_initmem()

<- Remember this?Arch/arm/kernel/vmlinux.lds.S

From demonstration: part 3

Clear init pages

Clear init pagesArch/arm/kernel/vmlinux.lds.S

A bit more

Clear init pagesSystem.map

One last thing

Run init process

Run init processInit/main.c

Questions?

Thank you

Contact:• Boaz taitler• boaztait@gmail.com