<<

IBM Technology Center

Porting Linux to a new architecture, done right

Arnd Bergmann

2010 IBM Corporation Porting Linux to a new architecture, done right Overview

1 Status of new architecture ports 2 Typical approaches to new architectures 3 Lessons Learned

2 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right About me

s390 architecture 2002-2005 PowerPC/Cell architecture 2005-now 32/64 bit syscall emulation Maintaining include/asm-generic Reviewing new architectures Learning about ARM

3 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Recently merged architectures

100000000

10000000

1000000

100000 arm xtensa mn10300 microblaze s*core tile 2.6.13 2.6.19 2.6.22 2.6.28 2.6.30 2.6.32 2.6.36

4 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Upcoming architectures

nios II lm32 UniCore OpenRISC c64x MMIX nameless 48-bit architecture nameless DSP architecture

5 / 27 Arnd Bergmann c 2010 IBM Corporation 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 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 pragmatically object-oriented freestanding ILP32/LP64 GNU 99 with static annotations and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

C

8 / 27 Arnd Bergmann c 2010 IBM Corporation pragmatically object-oriented freestanding ILP32/LP64 with static annotations and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

GNU

8 / 27 Arnd Bergmann c 2010 IBM Corporation pragmatically object-oriented freestanding ILP32/LP64 and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

GNU C99 with static annotations

8 / 27 Arnd Bergmann c 2010 IBM Corporation pragmatically object-oriented freestanding and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

ILP32/LP64 GNU C99 with static annotations

8 / 27 Arnd Bergmann c 2010 IBM Corporation pragmatically object-oriented and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

freestanding ILP32/LP64 GNU C99 with static annotations

8 / 27 Arnd Bergmann c 2010 IBM Corporation pragmatically and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

object-oriented freestanding ILP32/LP64 GNU C99 with static annotations

8 / 27 Arnd Bergmann c 2010 IBM Corporation and enforced coding style

Porting Linux to a new architecture, done right Language barrier #2: C

pragmatically object-oriented freestanding ILP32/LP64 GNU C99 with static annotations

8 / 27 Arnd Bergmann c 2010 IBM Corporation 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 Noncoherent I/O Out-of-order I/O Memory management units Multiple ABIs Multiple ISAs Multiple platforms Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing

9 / 27 Arnd Bergmann c 2010 IBM Corporation Out-of-order I/O Memory management units Multiple ABIs Multiple ISAs Multiple platforms Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O

9 / 27 Arnd Bergmann c 2010 IBM Corporation Memory management units Multiple ABIs Multiple ISAs Multiple platforms Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O Out-of-order I/O

9 / 27 Arnd Bergmann c 2010 IBM Corporation Multiple ABIs Multiple ISAs Multiple platforms Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O Out-of-order I/O Memory management units

9 / 27 Arnd Bergmann c 2010 IBM Corporation Multiple ISAs Multiple platforms Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O Out-of-order I/O Memory management units Multiple ABIs

9 / 27 Arnd Bergmann c 2010 IBM Corporation Multiple platforms Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O Out-of-order I/O Memory management units Multiple ABIs Multiple ISAs

9 / 27 Arnd Bergmann c 2010 IBM Corporation Timekeeping

Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O Out-of-order I/O Memory management units Multiple ABIs Multiple ISAs Multiple platforms

9 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Architectural challenges

Symmetric Multiprocessing Noncoherent I/O Out-of-order I/O Memory management units Multiple ABIs Multiple ISAs Multiple platforms Timekeeping

9 / 27 Arnd Bergmann c 2010 IBM Corporation Copy from ARM Copy from Tile Do not copy at all!

Porting Linux to a new architecture, done right Where to start

Copy from x86

10 / 27 Arnd Bergmann c 2010 IBM Corporation Copy from x86

Copy from Tile Do not copy at all!

Porting Linux to a new architecture, done right Where to start

Copy from ARM

10 / 27 Arnd Bergmann c 2010 IBM Corporation Copy from x86 Copy from ARM

Do not copy at all!

Porting Linux to a new architecture, done right Where to start

Copy from Tile

10 / 27 Arnd Bergmann c 2010 IBM Corporation Copy from x86 Copy from ARM Copy from Tile

Porting Linux to a new architecture, done right Where to start

Do not copy at all!

10 / 27 Arnd Bergmann c 2010 IBM Corporation One minimal syscall list! Cover all the simple implementations

Porting Linux to a new architecture, done right Generic header files

42 versions of struct stat?

11 / 27 Arnd Bergmann c 2010 IBM Corporation Cover all the simple implementations

Porting Linux to a new architecture, done right Generic header files

42 versions of struct stat? One minimal syscall list!

11 / 27 Arnd Bergmann c 2010 IBM Corporation 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 Porting Linux to a new architecture, done right Generic Architecture template

Early Boot code zImage compression functions device tree Trap handling Signal handling ptrace pci

12 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right : runtime

glibc/eglibc uClibc

13 / 27 Arnd Bergmann c 2010 IBM Corporation Embedded distribution yocto emdebian Busybox initramfs

Porting Linux to a new architecture, done right User space: distro

Full distribution , Fedora, OpenSUSE, , Gentoo, ...

14 / 27 Arnd Bergmann c 2010 IBM Corporation Busybox initramfs

Porting Linux to a new architecture, done right User space: distro

Full distribution Debian, Fedora, OpenSUSE, Ubuntu, Gentoo, ... Embedded distribution buildroot yocto emdebian

14 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right User space: distro

Full distribution Debian, Fedora, OpenSUSE, Ubuntu, Gentoo, ... Embedded distribution buildroot yocto emdebian Busybox initramfs

14 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right

Lessons Learned

15 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Lesson #1

Start small

16 / 27 Arnd Bergmann c 2010 IBM Corporation 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 Porting Linux to a new architecture, done right Lesson #3

Understand the development process

18 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Lesson #4

Follow the upstream kernel

19 / 27 Arnd Bergmann c 2010 IBM Corporation 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 Porting Linux to a new architecture, done right Lesson #6

Simplify drivers using virtio and hvc

21 / 27 Arnd Bergmann c 2010 IBM Corporation 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 Porting Linux to a new architecture, done right Lesson #8

Clean up after sparse and checkpatch

23 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Lesson #9

Run lockdep enabled kernels

24 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Lesson #10

Become a git master

25 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right Legal Statement

This work represents the view of the author and does not necessarily represent the view of IBM. IBM, IBM (logo), e-business (logo), pSeries, e (logo) server, and xSeries are trademarks or registered trademarks of International Business Machines Corporation in the United States and/or other countries. Linux is a registered trademark of . Other company, product, and service names may be trademarks or service marks of others.

26 / 27 Arnd Bergmann c 2010 IBM Corporation Porting Linux to a new architecture, done right

Questions?

27 / 27 Arnd Bergmann c 2010 IBM Corporation