Top Banner
Boaz Taitler KERNEL INIT PROCESS
32

Linux Kernel Init Process

Jan 14, 2017

Download

Software

Kernel TLV
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linux Kernel Init Process

Boaz Taitler

KERNEL INIT PROCESS

Page 2: Linux Kernel Init Process

Boaz Taitler

About me

Page 3: Linux Kernel Init Process

On the menu

• Module Init

• Initcalls Sections

• Init pages clean up

• Run init process

Page 4: Linux Kernel Init Process

Module Init/Exit

But how?!

Page 5: Linux Kernel Init Process

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

Page 6: Linux Kernel Init Process

Sections - example

Symbol group 3

Symbol group 2

Symbol group 1

Symbol group 4

Page 7: Linux Kernel Init Process

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

Page 8: Linux Kernel Init Process

The gathering - Initcall

Page 9: Linux Kernel Init Process

The gathering - Initcall

Page 10: Linux Kernel Init Process

The Result:System.map

Page 11: Linux Kernel Init Process

Example:

Page 12: Linux Kernel Init Process

Let’s call ‘em!

Init/main.c (v3.2)

Page 13: Linux Kernel Init Process

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

Page 14: Linux Kernel Init Process

Include/linux/init.h

Demonstration: part 2

Page 15: Linux Kernel Init Process

Arch/arm/kernel/vmlinux.lds.S

Demonstration: part 3

Page 16: Linux Kernel Init Process

Demonstration: part 4

Page 17: Linux Kernel Init Process

Do it yourself: ResultSystem.map

Page 18: Linux Kernel Init Process

Cons / Pros:• Cons:

• Require more memory

• Architecture dependent

• Pros:• Easy for maintenance

• Generic Calls

• Looks cool :D

Page 19: Linux Kernel Init Process

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.

Page 20: Linux Kernel Init Process

Init examples:

U-boot VS Barebox

Page 21: Linux Kernel Init Process

U-boot

U-boot 2009Lib_app/board.c

Page 22: Linux Kernel Init Process

Barebox

Page 23: Linux Kernel Init Process

Conclusions

1. Init calls can be called __barebox_cmd

2. Summing 2 pictures result in a big picture

Page 24: Linux Kernel Init Process

Finishing touches

• Clean init pages

• Run init process

Page 25: Linux Kernel Init Process

Clear init pages

Free_initmem()

Page 26: Linux Kernel Init Process

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

From demonstration: part 3

Clear init pages

Page 27: Linux Kernel Init Process

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

A bit more

Page 28: Linux Kernel Init Process

Clear init pagesSystem.map

Page 29: Linux Kernel Init Process

One last thing

Run init process

Page 30: Linux Kernel Init Process

Run init processInit/main.c

Page 31: Linux Kernel Init Process

Questions?

Page 32: Linux Kernel Init Process

Thank you

Contact:• Boaz taitler• [email protected]