ibm linux technology center · 2011. 2. 10. · early boot code zimage compression library...

48
c 2010 IBM Corporation IBM Linux Technology Center Porting Linux to a new architecture, done right Arnd Bergmann

Upload: others

Post on 31-Mar-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

c© 2010 IBM Corporation

IBM Linux Technology Center

Porting Linux to a new architecture, done right

Arnd Bergmann

Page 2: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Overview

1 Status of new architecture ports2 Typical approaches to new architectures3 Lessons Learned

2 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 3: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

About me

s390 architecture 2002-2005PowerPC/Cell architecture 2005-now32/64 bit syscall emulationMaintaining include/asm-genericReviewing new architecturesLearning about ARM

3 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 4: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Recently merged architectures

2.6.13 2.6.19 2.6.22 2.6.28 2.6.30 2.6.32 2.6.36

100000

1000000

10000000

100000000

tile

s*core

microblaze

mn10300

blackfin

avr32

xtensa

arm

4 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 5: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Upcoming architectures

nios IIlm32UniCoreOpenRISCc64xMMIXnameless 48-bit architecturenameless DSP architecture

5 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 6: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

What makes architecture ports so hard?

Typical approaches to new architectures

6 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 7: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #1: English

Homes of the current architecture maintainers

7 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 8: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented freestandingILP32/LP64 GNU

C

99 with static annotationsand enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 9: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented freestandingILP32/LP64

GNU C99

with static annotationsand enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 10: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented freestandingILP32/LP64

GNU C99 with static annotations

and enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 11: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented freestanding

ILP32/LP64 GNU C99 with static annotations

and enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 12: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented

freestandingILP32/LP64 GNU C99 with static annotations

and enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 13: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically

object-oriented freestandingILP32/LP64 GNU C99 with static annotations

and enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 14: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented freestandingILP32/LP64 GNU C99 with static annotations

and enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 15: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Language barrier #2: C

pragmatically object-oriented freestandingILP32/LP64 GNU C99 with static annotationsand enforced coding style

8 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 16: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric Multiprocessing

Noncoherent I/OOut-of-order I/OMemory management unitsMultiple ABIsMultiple ISAsMultiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 17: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/O

Out-of-order I/OMemory management unitsMultiple ABIsMultiple ISAsMultiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 18: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/OOut-of-order I/O

Memory management unitsMultiple ABIsMultiple ISAsMultiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 19: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/OOut-of-order I/OMemory management units

Multiple ABIsMultiple ISAsMultiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 20: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/OOut-of-order I/OMemory management unitsMultiple ABIs

Multiple ISAsMultiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 21: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/OOut-of-order I/OMemory management unitsMultiple ABIsMultiple ISAs

Multiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 22: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/OOut-of-order I/OMemory management unitsMultiple ABIsMultiple ISAsMultiple platforms

Timekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 23: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Architectural challenges

Symmetric MultiprocessingNoncoherent I/OOut-of-order I/OMemory management unitsMultiple ABIsMultiple ISAsMultiple platformsTimekeeping

9 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 24: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Where to start

Copy from x86

Copy from ARMCopy from TileDo not copy at all!

10 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 25: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Where to start

Copy from x86

Copy from ARM

Copy from TileDo not copy at all!

10 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 26: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Where to start

Copy from x86Copy from ARM

Copy from Tile

Do not copy at all!

10 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 27: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Where to start

Copy from x86Copy from ARMCopy from Tile

Do not copy at all!

10 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 28: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Generic header files

42 versions of struct stat?

One minimal syscall list!Cover all the simple implementations

11 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 29: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Generic header files

42 versions of struct stat?One minimal syscall list!

Cover all the simple implementations

11 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 30: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Generic header files

42 versions of struct stat?One minimal syscall list!Cover all the simple implementations

11 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 31: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Generic Architecture template

Early Boot codezImage compressionLibrary functionsdevice treeTrap handlingSignal handlingptracepci

12 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 32: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

User space: runtime

glibc/eglibcuClibcklibc

13 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 33: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

User space: distro

Full distributionDebian, Fedora, OpenSUSE, Ubuntu, Gentoo, ...

Embedded distributionbuildrootyoctoemdebian

Busybox initramfs

14 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 34: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

User space: distro

Full distributionDebian, Fedora, OpenSUSE, Ubuntu, Gentoo, ...

Embedded distributionbuildrootyoctoemdebian

Busybox initramfs

14 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 35: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

User space: distro

Full distributionDebian, Fedora, OpenSUSE, Ubuntu, Gentoo, ...

Embedded distributionbuildrootyoctoemdebian

Busybox initramfs

14 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 36: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lessons Learned

15 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 37: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #1

Start small

16 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 38: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #2

Generalize existing code for your special case

17 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 39: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #3

Understand the development process

18 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 40: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #4

Follow the upstream kernel

19 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 41: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #5

Debug your system with qemu with gdb

20 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 42: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #6

Simplify drivers using virtio and hvc

21 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 43: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #7

Describe SoC in a flattened device tree

22 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 44: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #8

Clean up after sparse and checkpatch

23 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 45: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #9

Run lockdep enabled kernels

24 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 46: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Lesson #10

Become a git master

25 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 47: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Legal Statement

This work represents the view of the author and does not necessarilyrepresent the view of IBM.IBM, IBM (logo), e-business (logo), pSeries, e (logo) server, andxSeries are trademarks or registered trademarks of InternationalBusiness Machines Corporation in the United States and/or othercountries.Linux is a registered trademark of Linus Torvalds.Other company, product, and service names may be trademarks orservice marks of others.

26 / 27 Arnd Bergmann c© 2010 IBM Corporation

Page 48: IBM Linux Technology Center · 2011. 2. 10. · Early Boot code zImage compression Library functions device tree Trap handling Signal handling ... Lesson #1 Start small 16 / 27 Arnd

Porting Linux to a new architecture, done right

Questions?

27 / 27 Arnd Bergmann c© 2010 IBM Corporation