Porting Android to Microkernel: an Experimental Approach
Total Page:16
File Type:pdf, Size:1020Kb
PORTING ANDROID TO MICROKERNEL: AN EXPERIMENTAL APPROACH by JUNZHE ZHANG A THESIS submitted in partial fulfillment of the requirements for the degree BACHELOR OF SCIENCE Department of Computer Science College of Literature, Science and the Arts UNIVERSITY OF MICHIGAN Ann Arbor, Michigan 2014 Approved by: Major Professor Peter M.Chen Abstract As smartphones become more popular, the requirement of dependability is also higher. This thesis tries to achieve this goal by providing an architectural solution. As the most widely used modern mobile system, Android is studied as a special case. This thesis proposes a design of porting Android to Minix3, a microkernel system. A preliminary porting work is also presented. Table of Contents List of Figures ................................................................................................................................ iv List of Tables .................................................................................................................................. v Chapter 1 - Introduction .................................................................................................................. 1 1.1 Demand on Dependability and Security ............................................................................... 1 1.1.1 A Modular OS Design ................................................................................................... 2 1.1.2 Pros and Cons ................................................................................................................ 2 1.2 Special Case: Android .......................................................................................................... 3 1.2.1 Popularity and Variations .............................................................................................. 3 1.2.2 Threats ............................................................................................................................ 4 1.3 The Focus of This Thesis ...................................................................................................... 4 Chapter 2 - Previous Work ............................................................................................................. 6 2.1 L4 .......................................................................................................................................... 6 2.1.1 L4Linux .......................................................................................................................... 6 L4Linux is a port of Linux kernel to the L4 kernel API. It ported Linux by a hypervisor approach. L4Linux runs in user-mode on top of the L4 kernel, side-by-side with other L4 kernel application [Härtig, H., Hohmuth, M., & Wolter.J, 1998]. It is binary compatible with the normal Linux/X86 kernel and can be used with any Linux distribution. ................. 6 2.1.2 L4Android ...................................................................................................................... 6 2.1.3 P4/Linux ......................................................................................................................... 7 2.2 Mach ..................................................................................................................................... 7 2.2.1 Mach and BSD ............................................................................................................... 7 2.3 Exokernel .............................................................................................................................. 7 Chapter 3 - Minix3 Design ............................................................................................................. 9 3.1 Minix3 Overview .................................................................................................................. 9 3.2 Processes ............................................................................................................................. 10 3.3 Input / Output .................................................................................................................. 12 3.4 Memory Management ..................................................................................................... 13 3.5 File System ...................................................................................................................... 13 3.6 Reincarnation Server ....................................................................................................... 15 i Chapter 4 - Android Design .......................................................................................................... 16 4.1 Android Framework Overview ........................................................................................... 16 4.1.2 Software Stacks ............................................................................................................ 16 4.1.2 Program Work Flows ................................................................................................... 17 4.2 Proprietary Drivers ............................................................................................................. 17 4.2.1 Logger .......................................................................................................................... 18 4.2.2 Ashmem ....................................................................................................................... 18 4.2.3 Binder ........................................................................................................................... 20 4.3 Application Components .................................................................................................... 22 4.3.1 Activity ........................................................................................................................ 22 4.3.2 Service .......................................................................................................................... 23 4.3.3 Broadcast ...................................................................................................................... 23 4.3.4 Content Provider .......................................................................................................... 24 4.3.5 Zygote and Process ...................................................................................................... 24 4.3.6 Messages and Looper ................................................................................................... 25 4.4 Compatibility with Minix ................................................................................................... 25 4.4.1 Similarities ................................................................................................................... 25 4.4.2 Differences ................................................................................................................... 26 Chapter 5 - Experiment ................................................................................................................. 27 5.1 Porting Proprietary Drivers ................................................................................................. 27 5.1.1 Logger .......................................................................................................................... 27 5.1.2 Ashmem ....................................................................................................................... 28 5.1.3 Binder ........................................................................................................................... 29 5.2 Zygote and Process Initialization ........................................................................................ 31 5.3 Kernel Modification ............................................................................................................ 31 5.4 Performance Measure ......................................................................................................... 32 Chapter 6 - Future Work ............................................................................................................... 34 6.1 Dalvik Virtual Machine ...................................................................................................... 34 6.2 Hardware Abstraction Layer ............................................................................................... 34 Chapter 7 - Summary .................................................................................................................... 36 7.1 Statement of the Problem and Summary ............................................................................ 36 ii 7.2 Lessons Learned ................................................................................................................. 37 References ..................................................................................................................................... 38 iii List of Figures Fig 1. Structure of a multi-server microkernel system ................................................................... 2 Fig 2. Minix3 system structure ..................................................................................................... 10 Fig 3. I/O process comparison between microkernel and monolithic kernel. .............................. 12 Fig 4. Illustration of Binder driver structure and working process ............................................... 21 Fig 5. Performance measurement with read-write through binder ..............................................