SlideShare a Scribd company logo
1 of 61
Download to read offline
Linux: the first second
Alison Chaiken
alison@she-devel.com
January 25, 2018
All code for demos
Related blog post at opensource.com
Fast boot: US gov't requires reverse-video in 2s
Panic Concern ensues among automakers shipping Linux.
3
Slow boot: Linux boot on 8-bit AVR
“uARM is certainly no speed
demon. It takes about 2 hours
to boot to bash prompt”.
System:
8-bit micro,
external storage,
external RAM,
32-bit ARMv5 emulation.
How Linux starts
● What precisely does “off” mean?
● Fun with bootloaders
● ACPI vs DTB
● The kernel as PID 0
● How does PID 1 start?
● What is an initrd?
http://spartakirada.com/lawnmower-pullcord/
kernel/smp.c
smp_init()
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
cpu_idle
head_64.S
“Kernel startup
entry point”
Decompress
start of
zImage
arch/arm/kernel/smp.c
secondary_start_kernel()
main.c start_kernel()
Boot
secondary
cores
init
kernel_init
do_initcalls()
rest_init()
device drivers
probe
devices
start
userspace
spawn
2nd
thread
6
Applying power
https://www.flickr.com/photos/nicknormal/11939558655/in/album-72157644792628117/
7
x86_64: Never genuinely off
Source: Intel
IPMI: run from Baseboard Management Controller
AMT: run from Platform Controller Hub
8
Source: Minnich et al., ELCE2017
on PCH
GRUB (x86)
or
u-boot (ARM)
{
on CPU
9
Purism, System76, Dell turn AMT off
Source: ExtremeTech, December 2017
10
ARM Bootloader:
u-boot
11
Fun with u-boot's sandbox
(demo placeholder)
● How-to:
make ARCH=sandbox defconfig
make
./u-boot
● Even more fun:
make_test_disk.sh
file test.raw; gdisk -l test.raw
./u-boot
host bind 0 test.raw
printenv
gpt read host 0
fatls host 0:1
fdt addr $fdt_addr_
fdt header
12
demo placeholder
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
head_64.S
“Kernel startup
entry point”
Decompress
start of
zImage
How the system reaches the kernel initialization stage
Pass cmdline +
device-tree or ACPI
14
Kernel's “address book”: ACPI or Device-tree
● ACPI tables in SPI-NOR flash.
● At boot:
'dmesg | grep DT'
● Examine:
'acpidump | grep Windows'
● Get source: run iasl to extract
● Modify: boot-time 'BIOS' menu.
● device-tree in /boot.
● At boot:
each driver reads the DTB.
● Examine:
'strings /boot/foo.dtb'
● Get source: from kernel
● Modify: edit source, run dtc,
copy to /boot.
15
Starting up
the kernel
https://www.flickr.com/photos/nicknormal/11939856433/in/album-72157644792628117/
16
The kernel is an ELF binary
● Extract vmlinux from vmlinuz:
– <path-to-kernel-source>/scripts/extract-vmlinux 
/boot/vmlinuz-$(uname -r) > vmlinux
● vmlinux is a regular ELF binary:
– file vmlinux; file /bin/ls
– readelf -e vmlinux; readelf -e /bin/ls
https://flic.kr/p/6xuhiK
17
Quiz:
How do ELF binaries
start?
?
?
?
?
?? ??
?
18
Quiz:
Where do argc and argv
come from?
?
?
?
?
?? ??
?
19
demo placeholder
Inspecting the start of ls with GDB
20
Examining ELF binary start with GDB
(results depend on toolchain and libc)
● Compile your C program with '-ggdb'.
● gdb <some-binary-executable>
● set backtrace past-main
on
● set backtrace past-entry
on
● Type 'run'
● frame 1; list
● Type 'info files'
● Find 'Entry point'.
● Type 'l *(hex address)'
● Type 'l 1,80'
● Type 'info functions' or
'info sources'
demo placeholder
21
The kernel as PID 0
● Userspace processes need to start need:
– stack,
– heap,
– STD* file descriptors
– environment
● glibc and libgcc allocate these resources.
– Source is in start.S (ARM) and libc-start.c.
● Corresponding kernel resources provided via inline ASM.
– Reads cmdline, device-tree or ACPI.
22
Examining ARM32 kernel start with GDB
(demo placeholder)
1 Type 'file vmlinux'. (If zImage, extract with linux/scripts/extract-vmlinux).
2 Type:
arm-linux-gnueabihf-gdb vmlinux
3 Type:
info files
4 Find 'Entry point'.
5 Type:
l *(hex address)
6 Type
l 1,80
23
What's in ARM's head.S?
● Type 'file vmlinux.o'
● Try 'arm-linux-gnueabihf-gdb vmlinux.o'
● Type 'info files'
● Type 'l *(0x0)' <---- actually works!
demo placeholder
Kernel starts in head.S,
not start.S.
24
Examining x86_64 kernel with GDB
(demo placeholder)
1 Type 'file vmlinux'. (If zImage, extract with linux/scripts/extract-vmlinux).
2 Type:
gdb vmlinux
3 Type:
info files
4 Find '.init.text'.
5 Type:
l *(hex address)
6 Type
l 200,290
25
What's in x86_64 head_64.S?
demo placeholder
26
The kernel's main() function
● start_kernel() {:
boot_cpu_init();
setup_arch(&command_line);
page_alloc_init();
pr_notice("Kernel command line: );
mm_init();
sched_init();
init_IRQ();
init_timers(); timekeeping_init();
console_init();
rest_init();
● }
“Activate the first processor.”
process the device-tree
All timestamps before
are [0.000000]
setup page tables
and start virtual memory
start
userspace
All on
one core!
cpu_idle
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
head_64.S
“Kernel startup
entry point”
Decompress
start of
zImage
main.c start_kernel()
kernel_init
rest_init()
Finish core kernel bringup
spawn
2nd
thread
kernel/smp.c
smp_init()
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
cpu_idle
head_64.S
“Kernel startup
entry point”
Decompress
start of
zImage
arch/arm/kernel/smp.c
secondary_start_kernel()
main.c start_kernel()
kernel_init
rest_init()
Boot
secondary
cores
Bring up symmetric
multiprocessing (SMP)
spawn
2nd
thread
29
Kernel boot via BCC
Stack for CPU0
Stack for 2nd
core
x86_64_start_kernel: head_64.S
demo placeholder
kernel/smp.c
smp_init()
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
cpu_idle
head_64.S
“Kernel startup
entry point”
Decompress
spawn
2nd
thread
start of
zImage
arch/arm/kernel/smp.c
secondary_start_kernel()
main.c start_kernel()
kernel_init
do_initcalls()
rest_init()
device drivers
probe
devices
Boot
secondary
cores
Bring up
devices,
filesystems . . .
kernel/smp.c
smp_init()
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
cpu_idle
head_64.S
“Kernel startup
entry point”
Decompress
init
start of
zImage
arch/arm/kernel/smp.c
secondary_start_kernel()
main.c start_kernel()
kernel_init
do_initcalls()
rest_init()
device drivers
probe
devices
start
userspace
Boot
secondary
cores
Finally,
userspace.
spawn
2nd
thread
kernel/smp.c
smp_init()
Boot
ROM in
CPU
bootloader
(u-boot,
GRUB)
cpu_idle
head_64.S
“Kernel startup
entry point”
Decompress
init
start of
zImage
arch/arm/kernel/smp.c
secondary_start_kernel()
main.c start_kernel()
kernel_init
do_initcalls()
rest_init()
device drivers
probe
devices
start
userspace
Boot
secondary
cores
spawn
2nd
thread
33
Summary
● Practicing with u-boot sandbox is comparatively
relaxing.
● Viewing the kernel as ELF helps to understand early
boot.
● Several processors and SW components participate in
boot.
● Until the scheduler and SMP start, the boot process is
relatively simple.
34
Acknowledgements
● Big thanks to Joel Fernandes and Akkana Peck for suggestions.
● Shout-out to Linaro for making ARM so much easier than x86.
35
Major References
● Embedded Linux Primer by Chris Hallinan and
Essential Linux Device Drivers by Sreekrishnan Venkateswaran (books)
● Booting ARM Linux by Russell King and THE LINUX/x86 BOOT PROTOCOL
(Documentation/)
● Program startup process in userspace at linux-insides blog, Michael Kerrisk's
TLPI (book)
● Matthew Garrett's comprehensive series on UEFI
● Status of Intel Management Engine on various laptops (Coreboot) and
servers (FSF)
● Nov, 2017 Intel Management Engine exploits and vulnerability detection tool
● All about ACPI talk by Darren Hart, ELCE 2013, Arch Wiki on
hacking ACPI tables
● 'apt-get install debian-kernel-handbook'; GDB docs chapter 8
36
Cold-boot may become rare
Source: Micron
● Non-volatile RAM  suspend even for brief
inactivity.
● Minimal diff between 'suspend' and 'hibernate'?
● Linux drivers: Matthew Wilcox, XIP DAX
AKA,
'Optane'
by Intel
Specs:
ArsTechnica
37
About Initrds
38
Booting into Rescue Shell
39
What is an initrd anyway?
● 'init ramdisk' = filesystem that is loaded into memory by the
kernel before the rootfs mounts.
● Why?
– To provide a 'rescue shell' in case rootfs doesn't mount.
– To provide modules that don't fit in zImage.
– To provide a safe environment to run agressive tests.
– To facilitate software updates on devices with limited
storage.
40
Exploring initramfs
41
What's in an initrd and why?
● Boot into the rescue shell by providing a broken cmdline in
/boot/grub/grub.cfg
– Type 'ls'
● Or try 'lsinitramfs /boot/$(uname -r)'
● initrd is a gzipped cpio archive:
cp /boot/initrd-$(uname -r) /tmp/initrd.gz
gunzip /tmp/initrd.gz
cpio -t < /tmp/initrd
42
OMG! My life is over! (rescue shell tips)
Inhale on a 4-count, then exhale on a 10-count.
● Oh no! 'help' scrolls pages of unreadable crap!
Relax your jaw. Make circles with your neck.
● Read 'man busybox'.
● 'help | grep' works in busybox.
● Look in /bin and /sbin. There's fsck!!
● You have sed and vi (but not emacs ;-( )
● Type 'reboot -f' or 'exit' when you are bored.
43
How to create your own initrd
● Unpack one that already works with gunzip and 'cpio -i'
● Copy in your binary.
● Use gen_initramfs.h from kernel source tree:
– scripts/gen_initramfs_list.sh -o <archive> <path to source>
● Run 'lsinitramfs <archive>' to check the result.
● cp <archive> /boot; edit /boot/grub/grub.cfg
CAUTION: your system boots fine, right? You're crazy to mess
with the bootloader, you moron.
● Run grub-script-check.
44
The magnificent result!
45
The Lenovo laptop on which the slides were created has
known IME vulnerabilities described by unpatched CVEs. This
has nothing to do with Meltdown and Spectre.
46
Bootloaders according to Intel
Read
device-tree
(ARM)
47
Coming soon to a system near youSource:
Anandtech
48
Investigating your laptop's PCH
● Try:
lsmod | grep pch
● Try:
find /lib/modules/$(uname -r)/ -name “*pch*”
● Then (for example):
EG20T = Intel Topcliff PCH
49
Why bootloaders have two parts
● ARM: “SPL”, “XLoader” or “MLO” in addition to u-boot.img.
● Problem: DRAM controller must be initialized.
● Solution: load into SRAM ('OCRAM' in i.MX6, 'l2ram' for TI).
– Why this works: SRAM (and pNOR) are mapped memory.
● Problem: SRAM is little! (256K on i.MX6, 2 MB on DRA7x).
● Solution: start with a tiny SPL.
50
Warm vs. power-on reset
Clears memory?
Restarts clocks?
Pros Cons Examples
Power-on Reset Yes, then reads
boot-mode pins.
Won't fail. Slightly slower. Plug-in device
Warm Reset DDR set to 'self-
refresh', then
reset clocks and
jump to stored
address.
Faster; retains
'reset reason'
and RAM data.
Can fail. 'reboot';
watchdog;
JTAG
51
Advanced Configuration and Power Interface
Source: Intel
do_bootm_states = u-boot state machine
bootm.c<lib>
“Main Entry point for arm
bootm implementation”
BootROM
(internal EEPROM)
resume?
Read Reset
Controller registers
No
Yes
Jump to
stored image
bootm_start() bootm_find_os()
bootm_load_os() bootm_os_get_boot_func()
boot_selected_os
do_bootm_linux()
bootm_jump_linux()
bootm.c<common>
Das U-boot
***
53
Where do messages originate?
[ 54.590327] Starting kernel ...
[ 54.593459]
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.35-2508-g54750ff (gcc version 4.6.3 #1 SMP PREEMPT
CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Freescale i.MX 6Quad/DualLite/Solo Sabre-SD Board
Memory policy: ECC disabled, Data cache writealloc
CPU identified as i.MX6Q, silicon rev 1.1
PERCPU: Embedded 7 pages/cpu @8c008000 s5440 r8192 d15040 u32768
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 227328
Kernel command line: console=ttymxc1,115200 ip=dhcp rootwait root=/dev/nfs
nfsroot=172.17.0.1:/tftpboot/alison/mx6q/fsl-mx6,v3,tcp
u-boot misc.c
in
zImage
header
from kernel
proper
from CPU
from
kernel
passed from u-boot
}
54
Getting more detailed kernel messages at boot
● Remove 'quiet' from the kernel command line.
● How to keep 'quiet' from coming back:
– edit /etc/grub.d/10_linux and add:
export GRUB_DISABLE_SUBMENU=y
export GRUB_CMDLINE_LINUX_DEFAULT=""
CAUTION: your system boots fine, right? You're crazy to mess
with the bootloader, you moron.
● Always run 'grub-script-check /boot/grub/grub.cfg' afterwards.
55
Learning more with systemd-bootchart
● Make sure kernel is compiled with CONFIG_SCHEDSTATS=y.
● 'apt-get install systemd-bootchart'
● Interrupt grub by typing 'e'
● Append 'init=/lib/systemd/systemd-bootchart' to the line that
starts with 'linux'
● After boot, open the SVG image in /run/log/ with a browser.
A change in compiling your own kernel
57
Appendix: running QEMU
#!/bin/bash
ROOTDIR=/home/alison/ISOs
HDNAME=debian-testing
VERSION=4.9.5
# Load kernel via GRUB; console shows in QEMU window.
#qemu-system-x86_64 -machine accel=kvm -name ${HDNAME} -boot c -drive file=$
{ROOTDIR}/${HDNAME}.raw,format=raw -m 4096 -smp cpus=1 -net nic,model=e1000
-net user,hostfwd=tcp:127.0.0.1:6666-:22 -localtime -serial stdio
# Load kernel from external file; console shows in xterm; GRUB doesn't run.
qemu-system-x86_64 -machine accel=kvm -name ${HDNAME} -initrd
/home/alison/embedded/SCALE2017/kernel/initrd.img-${VERSION} -kernel
/home/alison/embedded/SCALE2017/kernel/vmlinuz-${VERSION} -boot c -drive file=$
{ROOTDIR}/${HDNAME}.raw,format=raw -m 4096 -smp cpus=1 -net nic,model=e1000
-net user,hostfwd=tcp:127.0.0.1:6666-:22 -localtime -serial stdio -append
"console=ttyAMA0 console=ttyS0 root=UUID=8e6a1c7e-b3c4-4a37-8e21-56a137c9dded
ro"
58
Findingu-bootstartwithGDB
The ARM bootloader
● Read fundamental configuration from fuses, switches and
GPIOs.
● Then, for ARM:
1. Setup and initialise the RAM.
2. Initialise one serial port.
3. Detect the machine type.
4. Setup the kernel tagged list. device-tree
5. Load initramfs.
6. Call the kernel image.
Code in the SPL: board_init_f() and jump_to_image_linux()
60
Image, zImage, uImage, vmlinux, vmlinuz?
● Image is the raw executable.
● zImage is compressed version of Image with prepended
uncompression instructions in ASM.
● uImage is a zImage with a u-boot header.
● vmlinux is ELF executable containing Image in .text section.
● vmlinuz is a stripped version of vmlinux.
61Source: https://recon.cx/2014/slides/Recon%202014%20Skochinsky.pdf
Older x86 had ARC processor as
GMCH instead of PCH.

More Related Content

What's hot

Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!Anne Nicolas
 
One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesLeszek Godlewski
 
Kernel_Crash_Dump_Analysis
Kernel_Crash_Dump_AnalysisKernel_Crash_Dump_Analysis
Kernel_Crash_Dump_AnalysisBuland Singh
 
Advanced Linux Game Programming
Advanced Linux Game ProgrammingAdvanced Linux Game Programming
Advanced Linux Game ProgrammingLeszek Godlewski
 
[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler CollectionMoabi.com
 
“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”GlobalLogic Ukraine
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Anne Nicolas
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embeddedAlison Chaiken
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011pundiramit
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLeszek Godlewski
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
“Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems” “Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems” GlobalLogic Ukraine
 
Hardware backdooring is practical : slides
Hardware backdooring is practical : slidesHardware backdooring is practical : slides
Hardware backdooring is practical : slidesMoabi.com
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practicalMoabi.com
 
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander NasonovMultiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonoveurobsdcon
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation Jiann-Fuh Liaw
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - ErrataLeszek Godlewski
 

What's hot (20)

Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
Kernel Recipes 2014 - Writing Code: Keep It Short, Stupid!
 
SystemV vs systemd
SystemV vs systemdSystemV vs systemd
SystemV vs systemd
 
One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launches
 
Kernel_Crash_Dump_Analysis
Kernel_Crash_Dump_AnalysisKernel_Crash_Dump_Analysis
Kernel_Crash_Dump_Analysis
 
Advanced Linux Game Programming
Advanced Linux Game ProgrammingAdvanced Linux Game Programming
Advanced Linux Game Programming
 
[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection[Defcon24] Introduction to the Witchcraft Compiler Collection
[Defcon24] Introduction to the Witchcraft Compiler Collection
 
“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
“Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems” “Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems”
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Hardware backdooring is practical : slides
Hardware backdooring is practical : slidesHardware backdooring is practical : slides
Hardware backdooring is practical : slides
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical
 
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander NasonovMultiplatform JIT Code Generator for NetBSD by Alexander Nasonov
Multiplatform JIT Code Generator for NetBSD by Alexander Nasonov
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - Errata
 

Similar to Linux: the first second

Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Jian-Hong Pan
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and InsightsGlobalLogic Ukraine
 
01 linux-quick-start
01 linux-quick-start01 linux-quick-start
01 linux-quick-startNguyen Vinh
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modulesEddy Reyes
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013dotCloud
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Docker, Inc.
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Grub and dracut ii
Grub and dracut iiGrub and dracut ii
Grub and dracut iiplarsen67
 
The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)plarsen67
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...Yandex
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyLinaro
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux AwarenessPeter Griffin
 
Kernel entrance to-geek-
Kernel entrance to-geek-Kernel entrance to-geek-
Kernel entrance to-geek-mao999
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudAndrea Righi
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilersAnastasiaStulova
 
Practical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profilingPractical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profilingLubomir Rintel
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011Opersys inc.
 

Similar to Linux: the first second (20)

Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
 
Understanding The Boot Process
Understanding The Boot ProcessUnderstanding The Boot Process
Understanding The Boot Process
 
01 linux-quick-start
01 linux-quick-start01 linux-quick-start
01 linux-quick-start
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Grub and dracut ii
Grub and dracut iiGrub and dracut ii
Grub and dracut ii
 
The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case study
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
 
Kernel entrance to-geek-
Kernel entrance to-geek-Kernel entrance to-geek-
Kernel entrance to-geek-
 
Beagleboard xm-setup
Beagleboard xm-setupBeagleboard xm-setup
Beagleboard xm-setup
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilers
 
Practical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profilingPractical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profiling
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011
 

More from Alison Chaiken

Not breaking userspace: the evolving Linux ABI
Not breaking userspace: the evolving Linux ABINot breaking userspace: the evolving Linux ABI
Not breaking userspace: the evolving Linux ABIAlison Chaiken
 
Supporting SW Update via u-boot and GPT/EFI
Supporting SW Update via u-boot and GPT/EFISupporting SW Update via u-boot and GPT/EFI
Supporting SW Update via u-boot and GPT/EFIAlison Chaiken
 
Two C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsTwo C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsAlison Chaiken
 
V2X Communications: Getting our Cars Talking
V2X Communications: Getting our Cars TalkingV2X Communications: Getting our Cars Talking
V2X Communications: Getting our Cars TalkingAlison Chaiken
 
Practical Challenges to Deploying Highly Automated Vehicles
Practical Challenges to Deploying Highly Automated VehiclesPractical Challenges to Deploying Highly Automated Vehicles
Practical Challenges to Deploying Highly Automated VehiclesAlison Chaiken
 
Functional AI and Pervasive Networking in Automotive
 Functional AI and Pervasive Networking in Automotive Functional AI and Pervasive Networking in Automotive
Functional AI and Pervasive Networking in AutomotiveAlison Chaiken
 
Flash in Vehicles: an End-User's Perspective
Flash in Vehicles: an End-User's PerspectiveFlash in Vehicles: an End-User's Perspective
Flash in Vehicles: an End-User's PerspectiveAlison Chaiken
 
Automotive Linux, Cybersecurity and Transparency
Automotive Linux, Cybersecurity and TransparencyAutomotive Linux, Cybersecurity and Transparency
Automotive Linux, Cybersecurity and TransparencyAlison Chaiken
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager Alison Chaiken
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemdAlison Chaiken
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developersAlison Chaiken
 
Developing Automotive Linux
Developing Automotive LinuxDeveloping Automotive Linux
Developing Automotive LinuxAlison Chaiken
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveAlison Chaiken
 
Technology, Business and Regulation of the Connected Car
Technology, Business and Regulation of the Connected CarTechnology, Business and Regulation of the Connected Car
Technology, Business and Regulation of the Connected CarAlison Chaiken
 
Best practices for long-term support and security of the device-tree
Best practices for long-term support and security of the device-treeBest practices for long-term support and security of the device-tree
Best practices for long-term support and security of the device-treeAlison Chaiken
 
The “Telematics Horizon” V2V and V2I Networking
The “Telematics Horizon” V2V and V2I NetworkingThe “Telematics Horizon” V2V and V2I Networking
The “Telematics Horizon” V2V and V2I NetworkingAlison Chaiken
 
Developing automotive Linux
Developing automotive LinuxDeveloping automotive Linux
Developing automotive LinuxAlison Chaiken
 
Automotive Free Software 2013: "Right to Repair" and Privacy
Automotive Free Software 2013: "Right to Repair" and PrivacyAutomotive Free Software 2013: "Right to Repair" and Privacy
Automotive Free Software 2013: "Right to Repair" and PrivacyAlison Chaiken
 
Addressing the hard problems of automotive Linux: networking and IPC
Addressing the hard problems of automotive Linux: networking and IPCAddressing the hard problems of automotive Linux: networking and IPC
Addressing the hard problems of automotive Linux: networking and IPCAlison Chaiken
 
Tier X and the Coming of the Whitebox Car
Tier X and the Coming of the Whitebox CarTier X and the Coming of the Whitebox Car
Tier X and the Coming of the Whitebox CarAlison Chaiken
 

More from Alison Chaiken (20)

Not breaking userspace: the evolving Linux ABI
Not breaking userspace: the evolving Linux ABINot breaking userspace: the evolving Linux ABI
Not breaking userspace: the evolving Linux ABI
 
Supporting SW Update via u-boot and GPT/EFI
Supporting SW Update via u-boot and GPT/EFISupporting SW Update via u-boot and GPT/EFI
Supporting SW Update via u-boot and GPT/EFI
 
Two C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsTwo C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp Insights
 
V2X Communications: Getting our Cars Talking
V2X Communications: Getting our Cars TalkingV2X Communications: Getting our Cars Talking
V2X Communications: Getting our Cars Talking
 
Practical Challenges to Deploying Highly Automated Vehicles
Practical Challenges to Deploying Highly Automated VehiclesPractical Challenges to Deploying Highly Automated Vehicles
Practical Challenges to Deploying Highly Automated Vehicles
 
Functional AI and Pervasive Networking in Automotive
 Functional AI and Pervasive Networking in Automotive Functional AI and Pervasive Networking in Automotive
Functional AI and Pervasive Networking in Automotive
 
Flash in Vehicles: an End-User's Perspective
Flash in Vehicles: an End-User's PerspectiveFlash in Vehicles: an End-User's Perspective
Flash in Vehicles: an End-User's Perspective
 
Automotive Linux, Cybersecurity and Transparency
Automotive Linux, Cybersecurity and TransparencyAutomotive Linux, Cybersecurity and Transparency
Automotive Linux, Cybersecurity and Transparency
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemd
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
Developing Automotive Linux
Developing Automotive LinuxDeveloping Automotive Linux
Developing Automotive Linux
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Technology, Business and Regulation of the Connected Car
Technology, Business and Regulation of the Connected CarTechnology, Business and Regulation of the Connected Car
Technology, Business and Regulation of the Connected Car
 
Best practices for long-term support and security of the device-tree
Best practices for long-term support and security of the device-treeBest practices for long-term support and security of the device-tree
Best practices for long-term support and security of the device-tree
 
The “Telematics Horizon” V2V and V2I Networking
The “Telematics Horizon” V2V and V2I NetworkingThe “Telematics Horizon” V2V and V2I Networking
The “Telematics Horizon” V2V and V2I Networking
 
Developing automotive Linux
Developing automotive LinuxDeveloping automotive Linux
Developing automotive Linux
 
Automotive Free Software 2013: "Right to Repair" and Privacy
Automotive Free Software 2013: "Right to Repair" and PrivacyAutomotive Free Software 2013: "Right to Repair" and Privacy
Automotive Free Software 2013: "Right to Repair" and Privacy
 
Addressing the hard problems of automotive Linux: networking and IPC
Addressing the hard problems of automotive Linux: networking and IPCAddressing the hard problems of automotive Linux: networking and IPC
Addressing the hard problems of automotive Linux: networking and IPC
 
Tier X and the Coming of the Whitebox Car
Tier X and the Coming of the Whitebox CarTier X and the Coming of the Whitebox Car
Tier X and the Coming of the Whitebox Car
 

Recently uploaded

tourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdftourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdfchess188chess188
 
Substation Automation SCADA and Gateway Solutions by BRH
Substation Automation SCADA and Gateway Solutions by BRHSubstation Automation SCADA and Gateway Solutions by BRH
Substation Automation SCADA and Gateway Solutions by BRHbirinder2
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectGayathriM270621
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...shreenathji26
 
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxCurve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxRomil Mishra
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfShreyas Pandit
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
The Satellite applications in telecommunication
The Satellite applications in telecommunicationThe Satellite applications in telecommunication
The Satellite applications in telecommunicationnovrain7111
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 

Recently uploaded (20)

tourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdftourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdf
 
Substation Automation SCADA and Gateway Solutions by BRH
Substation Automation SCADA and Gateway Solutions by BRHSubstation Automation SCADA and Gateway Solutions by BRH
Substation Automation SCADA and Gateway Solutions by BRH
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subject
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
Introduction to Artificial Intelligence: Intelligent Agents, State Space Sear...
 
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptxCurve setting (Basic Mine Surveying)_MI10412MI.pptx
Curve setting (Basic Mine Surveying)_MI10412MI.pptx
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdf
 
Versatile Engineering Construction Firms
Versatile Engineering Construction FirmsVersatile Engineering Construction Firms
Versatile Engineering Construction Firms
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
The Satellite applications in telecommunication
The Satellite applications in telecommunicationThe Satellite applications in telecommunication
The Satellite applications in telecommunication
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 

Linux: the first second

  • 1. Linux: the first second Alison Chaiken alison@she-devel.com January 25, 2018 All code for demos Related blog post at opensource.com
  • 2. Fast boot: US gov't requires reverse-video in 2s Panic Concern ensues among automakers shipping Linux.
  • 3. 3 Slow boot: Linux boot on 8-bit AVR “uARM is certainly no speed demon. It takes about 2 hours to boot to bash prompt”. System: 8-bit micro, external storage, external RAM, 32-bit ARMv5 emulation.
  • 4. How Linux starts ● What precisely does “off” mean? ● Fun with bootloaders ● ACPI vs DTB ● The kernel as PID 0 ● How does PID 1 start? ● What is an initrd? http://spartakirada.com/lawnmower-pullcord/
  • 5. kernel/smp.c smp_init() Boot ROM in CPU bootloader (u-boot, GRUB) cpu_idle head_64.S “Kernel startup entry point” Decompress start of zImage arch/arm/kernel/smp.c secondary_start_kernel() main.c start_kernel() Boot secondary cores init kernel_init do_initcalls() rest_init() device drivers probe devices start userspace spawn 2nd thread
  • 7. 7 x86_64: Never genuinely off Source: Intel IPMI: run from Baseboard Management Controller AMT: run from Platform Controller Hub
  • 8. 8 Source: Minnich et al., ELCE2017 on PCH GRUB (x86) or u-boot (ARM) { on CPU
  • 9. 9 Purism, System76, Dell turn AMT off Source: ExtremeTech, December 2017
  • 11. 11 Fun with u-boot's sandbox (demo placeholder) ● How-to: make ARCH=sandbox defconfig make ./u-boot ● Even more fun: make_test_disk.sh file test.raw; gdisk -l test.raw ./u-boot host bind 0 test.raw printenv gpt read host 0 fatls host 0:1 fdt addr $fdt_addr_ fdt header
  • 13. Boot ROM in CPU bootloader (u-boot, GRUB) head_64.S “Kernel startup entry point” Decompress start of zImage How the system reaches the kernel initialization stage Pass cmdline + device-tree or ACPI
  • 14. 14 Kernel's “address book”: ACPI or Device-tree ● ACPI tables in SPI-NOR flash. ● At boot: 'dmesg | grep DT' ● Examine: 'acpidump | grep Windows' ● Get source: run iasl to extract ● Modify: boot-time 'BIOS' menu. ● device-tree in /boot. ● At boot: each driver reads the DTB. ● Examine: 'strings /boot/foo.dtb' ● Get source: from kernel ● Modify: edit source, run dtc, copy to /boot.
  • 16. 16 The kernel is an ELF binary ● Extract vmlinux from vmlinuz: – <path-to-kernel-source>/scripts/extract-vmlinux /boot/vmlinuz-$(uname -r) > vmlinux ● vmlinux is a regular ELF binary: – file vmlinux; file /bin/ls – readelf -e vmlinux; readelf -e /bin/ls https://flic.kr/p/6xuhiK
  • 17. 17 Quiz: How do ELF binaries start? ? ? ? ? ?? ?? ?
  • 18. 18 Quiz: Where do argc and argv come from? ? ? ? ? ?? ?? ?
  • 19. 19 demo placeholder Inspecting the start of ls with GDB
  • 20. 20 Examining ELF binary start with GDB (results depend on toolchain and libc) ● Compile your C program with '-ggdb'. ● gdb <some-binary-executable> ● set backtrace past-main on ● set backtrace past-entry on ● Type 'run' ● frame 1; list ● Type 'info files' ● Find 'Entry point'. ● Type 'l *(hex address)' ● Type 'l 1,80' ● Type 'info functions' or 'info sources' demo placeholder
  • 21. 21 The kernel as PID 0 ● Userspace processes need to start need: – stack, – heap, – STD* file descriptors – environment ● glibc and libgcc allocate these resources. – Source is in start.S (ARM) and libc-start.c. ● Corresponding kernel resources provided via inline ASM. – Reads cmdline, device-tree or ACPI.
  • 22. 22 Examining ARM32 kernel start with GDB (demo placeholder) 1 Type 'file vmlinux'. (If zImage, extract with linux/scripts/extract-vmlinux). 2 Type: arm-linux-gnueabihf-gdb vmlinux 3 Type: info files 4 Find 'Entry point'. 5 Type: l *(hex address) 6 Type l 1,80
  • 23. 23 What's in ARM's head.S? ● Type 'file vmlinux.o' ● Try 'arm-linux-gnueabihf-gdb vmlinux.o' ● Type 'info files' ● Type 'l *(0x0)' <---- actually works! demo placeholder Kernel starts in head.S, not start.S.
  • 24. 24 Examining x86_64 kernel with GDB (demo placeholder) 1 Type 'file vmlinux'. (If zImage, extract with linux/scripts/extract-vmlinux). 2 Type: gdb vmlinux 3 Type: info files 4 Find '.init.text'. 5 Type: l *(hex address) 6 Type l 200,290
  • 25. 25 What's in x86_64 head_64.S? demo placeholder
  • 26. 26 The kernel's main() function ● start_kernel() {: boot_cpu_init(); setup_arch(&command_line); page_alloc_init(); pr_notice("Kernel command line: ); mm_init(); sched_init(); init_IRQ(); init_timers(); timekeeping_init(); console_init(); rest_init(); ● } “Activate the first processor.” process the device-tree All timestamps before are [0.000000] setup page tables and start virtual memory start userspace All on one core!
  • 27. cpu_idle Boot ROM in CPU bootloader (u-boot, GRUB) head_64.S “Kernel startup entry point” Decompress start of zImage main.c start_kernel() kernel_init rest_init() Finish core kernel bringup spawn 2nd thread
  • 28. kernel/smp.c smp_init() Boot ROM in CPU bootloader (u-boot, GRUB) cpu_idle head_64.S “Kernel startup entry point” Decompress start of zImage arch/arm/kernel/smp.c secondary_start_kernel() main.c start_kernel() kernel_init rest_init() Boot secondary cores Bring up symmetric multiprocessing (SMP) spawn 2nd thread
  • 29. 29 Kernel boot via BCC Stack for CPU0 Stack for 2nd core x86_64_start_kernel: head_64.S demo placeholder
  • 30. kernel/smp.c smp_init() Boot ROM in CPU bootloader (u-boot, GRUB) cpu_idle head_64.S “Kernel startup entry point” Decompress spawn 2nd thread start of zImage arch/arm/kernel/smp.c secondary_start_kernel() main.c start_kernel() kernel_init do_initcalls() rest_init() device drivers probe devices Boot secondary cores Bring up devices, filesystems . . .
  • 31. kernel/smp.c smp_init() Boot ROM in CPU bootloader (u-boot, GRUB) cpu_idle head_64.S “Kernel startup entry point” Decompress init start of zImage arch/arm/kernel/smp.c secondary_start_kernel() main.c start_kernel() kernel_init do_initcalls() rest_init() device drivers probe devices start userspace Boot secondary cores Finally, userspace. spawn 2nd thread
  • 32. kernel/smp.c smp_init() Boot ROM in CPU bootloader (u-boot, GRUB) cpu_idle head_64.S “Kernel startup entry point” Decompress init start of zImage arch/arm/kernel/smp.c secondary_start_kernel() main.c start_kernel() kernel_init do_initcalls() rest_init() device drivers probe devices start userspace Boot secondary cores spawn 2nd thread
  • 33. 33 Summary ● Practicing with u-boot sandbox is comparatively relaxing. ● Viewing the kernel as ELF helps to understand early boot. ● Several processors and SW components participate in boot. ● Until the scheduler and SMP start, the boot process is relatively simple.
  • 34. 34 Acknowledgements ● Big thanks to Joel Fernandes and Akkana Peck for suggestions. ● Shout-out to Linaro for making ARM so much easier than x86.
  • 35. 35 Major References ● Embedded Linux Primer by Chris Hallinan and Essential Linux Device Drivers by Sreekrishnan Venkateswaran (books) ● Booting ARM Linux by Russell King and THE LINUX/x86 BOOT PROTOCOL (Documentation/) ● Program startup process in userspace at linux-insides blog, Michael Kerrisk's TLPI (book) ● Matthew Garrett's comprehensive series on UEFI ● Status of Intel Management Engine on various laptops (Coreboot) and servers (FSF) ● Nov, 2017 Intel Management Engine exploits and vulnerability detection tool ● All about ACPI talk by Darren Hart, ELCE 2013, Arch Wiki on hacking ACPI tables ● 'apt-get install debian-kernel-handbook'; GDB docs chapter 8
  • 36. 36 Cold-boot may become rare Source: Micron ● Non-volatile RAM  suspend even for brief inactivity. ● Minimal diff between 'suspend' and 'hibernate'? ● Linux drivers: Matthew Wilcox, XIP DAX AKA, 'Optane' by Intel Specs: ArsTechnica
  • 39. 39 What is an initrd anyway? ● 'init ramdisk' = filesystem that is loaded into memory by the kernel before the rootfs mounts. ● Why? – To provide a 'rescue shell' in case rootfs doesn't mount. – To provide modules that don't fit in zImage. – To provide a safe environment to run agressive tests. – To facilitate software updates on devices with limited storage.
  • 41. 41 What's in an initrd and why? ● Boot into the rescue shell by providing a broken cmdline in /boot/grub/grub.cfg – Type 'ls' ● Or try 'lsinitramfs /boot/$(uname -r)' ● initrd is a gzipped cpio archive: cp /boot/initrd-$(uname -r) /tmp/initrd.gz gunzip /tmp/initrd.gz cpio -t < /tmp/initrd
  • 42. 42 OMG! My life is over! (rescue shell tips) Inhale on a 4-count, then exhale on a 10-count. ● Oh no! 'help' scrolls pages of unreadable crap! Relax your jaw. Make circles with your neck. ● Read 'man busybox'. ● 'help | grep' works in busybox. ● Look in /bin and /sbin. There's fsck!! ● You have sed and vi (but not emacs ;-( ) ● Type 'reboot -f' or 'exit' when you are bored.
  • 43. 43 How to create your own initrd ● Unpack one that already works with gunzip and 'cpio -i' ● Copy in your binary. ● Use gen_initramfs.h from kernel source tree: – scripts/gen_initramfs_list.sh -o <archive> <path to source> ● Run 'lsinitramfs <archive>' to check the result. ● cp <archive> /boot; edit /boot/grub/grub.cfg CAUTION: your system boots fine, right? You're crazy to mess with the bootloader, you moron. ● Run grub-script-check.
  • 45. 45 The Lenovo laptop on which the slides were created has known IME vulnerabilities described by unpatched CVEs. This has nothing to do with Meltdown and Spectre.
  • 46. 46 Bootloaders according to Intel Read device-tree (ARM)
  • 47. 47 Coming soon to a system near youSource: Anandtech
  • 48. 48 Investigating your laptop's PCH ● Try: lsmod | grep pch ● Try: find /lib/modules/$(uname -r)/ -name “*pch*” ● Then (for example): EG20T = Intel Topcliff PCH
  • 49. 49 Why bootloaders have two parts ● ARM: “SPL”, “XLoader” or “MLO” in addition to u-boot.img. ● Problem: DRAM controller must be initialized. ● Solution: load into SRAM ('OCRAM' in i.MX6, 'l2ram' for TI). – Why this works: SRAM (and pNOR) are mapped memory. ● Problem: SRAM is little! (256K on i.MX6, 2 MB on DRA7x). ● Solution: start with a tiny SPL.
  • 50. 50 Warm vs. power-on reset Clears memory? Restarts clocks? Pros Cons Examples Power-on Reset Yes, then reads boot-mode pins. Won't fail. Slightly slower. Plug-in device Warm Reset DDR set to 'self- refresh', then reset clocks and jump to stored address. Faster; retains 'reset reason' and RAM data. Can fail. 'reboot'; watchdog; JTAG
  • 51. 51 Advanced Configuration and Power Interface Source: Intel
  • 52. do_bootm_states = u-boot state machine bootm.c<lib> “Main Entry point for arm bootm implementation” BootROM (internal EEPROM) resume? Read Reset Controller registers No Yes Jump to stored image bootm_start() bootm_find_os() bootm_load_os() bootm_os_get_boot_func() boot_selected_os do_bootm_linux() bootm_jump_linux() bootm.c<common> Das U-boot ***
  • 53. 53 Where do messages originate? [ 54.590327] Starting kernel ... [ 54.593459] Uncompressing Linux... done, booting the kernel. Linux version 3.0.35-2508-g54750ff (gcc version 4.6.3 #1 SMP PREEMPT CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine: Freescale i.MX 6Quad/DualLite/Solo Sabre-SD Board Memory policy: ECC disabled, Data cache writealloc CPU identified as i.MX6Q, silicon rev 1.1 PERCPU: Embedded 7 pages/cpu @8c008000 s5440 r8192 d15040 u32768 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 227328 Kernel command line: console=ttymxc1,115200 ip=dhcp rootwait root=/dev/nfs nfsroot=172.17.0.1:/tftpboot/alison/mx6q/fsl-mx6,v3,tcp u-boot misc.c in zImage header from kernel proper from CPU from kernel passed from u-boot }
  • 54. 54 Getting more detailed kernel messages at boot ● Remove 'quiet' from the kernel command line. ● How to keep 'quiet' from coming back: – edit /etc/grub.d/10_linux and add: export GRUB_DISABLE_SUBMENU=y export GRUB_CMDLINE_LINUX_DEFAULT="" CAUTION: your system boots fine, right? You're crazy to mess with the bootloader, you moron. ● Always run 'grub-script-check /boot/grub/grub.cfg' afterwards.
  • 55. 55 Learning more with systemd-bootchart ● Make sure kernel is compiled with CONFIG_SCHEDSTATS=y. ● 'apt-get install systemd-bootchart' ● Interrupt grub by typing 'e' ● Append 'init=/lib/systemd/systemd-bootchart' to the line that starts with 'linux' ● After boot, open the SVG image in /run/log/ with a browser.
  • 56. A change in compiling your own kernel
  • 57. 57 Appendix: running QEMU #!/bin/bash ROOTDIR=/home/alison/ISOs HDNAME=debian-testing VERSION=4.9.5 # Load kernel via GRUB; console shows in QEMU window. #qemu-system-x86_64 -machine accel=kvm -name ${HDNAME} -boot c -drive file=$ {ROOTDIR}/${HDNAME}.raw,format=raw -m 4096 -smp cpus=1 -net nic,model=e1000 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -localtime -serial stdio # Load kernel from external file; console shows in xterm; GRUB doesn't run. qemu-system-x86_64 -machine accel=kvm -name ${HDNAME} -initrd /home/alison/embedded/SCALE2017/kernel/initrd.img-${VERSION} -kernel /home/alison/embedded/SCALE2017/kernel/vmlinuz-${VERSION} -boot c -drive file=$ {ROOTDIR}/${HDNAME}.raw,format=raw -m 4096 -smp cpus=1 -net nic,model=e1000 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -localtime -serial stdio -append "console=ttyAMA0 console=ttyS0 root=UUID=8e6a1c7e-b3c4-4a37-8e21-56a137c9dded ro"
  • 59. The ARM bootloader ● Read fundamental configuration from fuses, switches and GPIOs. ● Then, for ARM: 1. Setup and initialise the RAM. 2. Initialise one serial port. 3. Detect the machine type. 4. Setup the kernel tagged list. device-tree 5. Load initramfs. 6. Call the kernel image. Code in the SPL: board_init_f() and jump_to_image_linux()
  • 60. 60 Image, zImage, uImage, vmlinux, vmlinuz? ● Image is the raw executable. ● zImage is compressed version of Image with prepended uncompression instructions in ASM. ● uImage is a zImage with a u-boot header. ● vmlinux is ELF executable containing Image in .text section. ● vmlinuz is a stripped version of vmlinux.