Code Compaction of an Operating System Kernel Haifeng He, John Trimble, Somu Perianayagam, Saumya Debray, Gregory Andrews Computer Science Department.

Slides:



Advertisements
Similar presentations
Systems Software.
Advertisements

Extensibility, Safety and Performance in the SPIN Operating System Presented by Allen Kerr.
Program Representations. Representing programs Goals.
Chapter 6 Limited Direct Execution
1 S. Tallam, R. Gupta, and X. Zhang PACT 2005 Extended Whole Program Paths Sriraman Tallam Rajiv Gupta Xiangyu Zhang University of Arizona.
Binary Obfuscation Using Signals Igor V. Popov ( University of Arizona)‏ Saumya K. Debray (University of Arizona)‏ Gregory R. Andrews (University of Arizona)
Chapter 13 Embedded Systems
Zheming CSCE715.  A wireless sensor network (WSN) ◦ Spatially distributed sensors to monitor physical or environmental conditions, and to cooperatively.
Eliminating Stack Overflow by Abstract Interpretation John Regehr Alastair Reid Kirk Webb University of Utah.
Static Analysis of Embedded C Code John Regehr University of Utah Joint work with Nathan Cooprider.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Vertically Integrated Analysis and Transformation for Embedded Software John Regehr University of Utah.
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
From last time: live variables Set D = 2 Vars Lattice: (D, v, ?, >, t, u ) = (2 Vars, µ, ;,Vars, [, Å ) x := y op z in out F x := y op z (out) = out –
CS 104 Introduction to Computer Science and Graphics Problems
Active Messages: a Mechanism for Integrated Communication and Computation von Eicken et. al. Brian Kazian CS258 Spring 2008.
Chapter 13 Embedded Systems
OS Spring’03 Introduction Operating Systems Spring 2003.
Automatic Compaction of OS Kernel Code via On-Demand Code Loading Haifeng He, Saumya Debray, Gregory Andrews The University of Arizona.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Partial Automation of an Integration Reverse Engineering Environment of Binary Code Author : Cristina Cifuentes Reverse Engineering, 1996., Proceedings.
Recap from last time: live variables x := 5 y := x + 2 x := x + 1 y := x y...
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
Precision Going back to constant prop, in what cases would we lose precision?
CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.
Secure Virtual Architecture John Criswell, Arushi Aggarwal, Andrew Lenharth, Dinakar Dhurjati, and Vikram Adve University of Illinois at Urbana-Champaign.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
University of Maryland Compiler-Assisted Binary Parsing Tugrul Ince PD Week – 27 March 2012.
Protection and the Kernel: Mode, Space, and Context.
11 If you were plowing a field, which would you rather use? Two oxen, or 1024 chickens? (Attributed to S. Cray) Abdullah Gharaibeh, Lauro Costa, Elizeu.
Operating Systems CS3502 Fall 2014 Dr. Jose M. Garrido
Eric Keller, Evan Green Princeton University PRESTO /22/08 Virtualizing the Data Plane Through Source Code Merging.
Putting Pointer Analysis to Work Rakesh Ghiya and Laurie J. Hendren Presented by Shey Liggett & Jason Bartkowiak.
Compiler BE Panel IDC HPC User Forum April 2009 Don Kretsch Director, Sun Developer Tools Sun Microsystems.
Uncovering the Multicore Processor Bottlenecks Server Design Summit Shay Gal-On Director of Technology, EEMBC.
Exploring Suitability of Linux for Embedded Vision Applications Ankit Mathur Mayank Agarwal Mini Project.
1 Advance Computer Architecture CSE 8383 Ranya Alawadhi.
ACMSE’04, ALDepartment of Electrical and Computer Engineering - UAH Execution Characteristics of SPEC CPU2000 Benchmarks: Intel C++ vs. Microsoft VC++
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
HPC User Forum Back End Compiler Panel SiCortex Perspective Kevin Harris Compiler Manager April 2009.
Instrumentation in Software Dynamic Translators for Self-Managed Systems Bruce R. Childers Naveen Kumar, Jonathan Misurda and Mary.
Embedded Lab. Park Yeongseong.  Introduction  State of the art  Core values  Design  Experiment  Discussion  Conclusion  Q&A.
CISC Machine Learning for Solving Systems Problems John Cavazos Dept of Computer & Information Sciences University of Delaware
Pointer Analysis Survey. Rupesh Nasre. Aug 24, 2007.
OPTIMIZING DSP SCHEDULING VIA ADDRESS ASSIGNMENT WITH ARRAY AND LOOP TRANSFORMATION Chun Xue, Zili Shao, Ying Chen, Edwin H.-M. Sha Department of Computer.
Full and Para Virtualization
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
An Automated Development Framework for a RISC Processor with Reconfigurable Instruction Set Extensions Nikolaos Vassiliadis, George Theodoridis and Spiridon.
Chapter 1 Basic Concepts of Operating Systems Introduction Software A program is a sequence of instructions that enables the computer to carry.
D A C U C P Speculative Alias Analysis for Executable Code Manel Fernández and Roger Espasa Computer Architecture Department Universitat Politècnica de.
Compacting ARM binaries with the Diablo framework – Dominique Chanet & Ludo Van Put Compacting ARM binaries with the Diablo framework Dominique Chanet.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
CS 3214 Computer Systems Lecture 9 Godmar Back.
Muen Policy & Toolchain
Presented by Mike Marty
Ph.D. in Computer Science
Effective Data-Race Detection for the Kernel
Many-core Software Development Platforms
Presented by: Sameer Kulkarni
Department of Computer Science University of California, Santa Barbara
Performance Optimization for Embedded Software
Virtualization Techniques
The Procedure Abstraction Part I: Basics
Department of Computer Science University of California, Santa Barbara
Presentation transcript:

Code Compaction of an Operating System Kernel Haifeng He, John Trimble, Somu Perianayagam, Saumya Debray, Gregory Andrews Computer Science Department

The Problem  Reduce the memory footprint of Linux kernel on embedded platform  Why is this important? Use general-purpose OS in embedded systems Limited amount of memory in embedded systems  Goal: Automatically reduce the size of Linux kernel

The Opportunities General- Purpose OS Embedded Systems HardwareMany devicesSmall, fixed set of devices SoftwareMany applications Small, fixed set of applications System calls Large numberSmall subset How to utilize these opportunities?

The Options  Hardware configuration Carefully configure the kernel Still not the smallest kernel  Program analysis for code compaction Find unreachable code Find duplications (functions, instructions)  Orthogonal to hardware assisted compression (e.g., ARM/Thumb)

The Challenges of Kernel Code Compaction  Does not follow conventions of compiler- generated code ? How to handle kernel code  Large amount indirect control flow ? How to find targets of indirect calls  Multiple entry points in the kernel  Implicit control flow paths Interrupts

Our Approach  Use binary rewriting A uniform way to handle C and assembly code Whole program optimizations  Handling kernel binary is not trivial  Less information available (types, pointer aliasing)  Combine source-level analysis A hybrid technique

A Big Picture Source Code of Kernel Binary Code Of Kernel Pointer Analysis Program Call Graph Control Flow Graph Disassemble Kernel Compaction Compact Kernel Executable Source-Level Analysis Binary Rewriting Compile Syscalls required by User Apps

Source-Level Analysis  A significant amount of hand-written assembly code in the kernel Can ’ t ignore it Interacts with C code  Requires pointer analysis for both C code and assembly code “ Lift ” the assembly code to source level

Approximate Decompilation  Idea Reverse engineer hand-written assembly code back to C  The benefit Reuse source-level analysis for C  The translation can be approximate Can disregard aspects of assembly code that are irrelevant to the analysis

Approximate Decompilation *.c Pointer analysis X Program Call Graph *.S Source Code of Kernel *.c X Appr. decomp. for analysis X *.c  If pointer analysis is flow-insensitive, then instructions like cmp, condition jmp can be ignored

Pointer Analysis  Tradeoff: precision vs. efficiency  Our choice: FA analysis by Zhang et al. Flow-insensitive and context-insensitive Field sensitive  Why? Efficiency: almost linear Quite precise for identifying the targets of indirect function calls

Identify Reachable Code  Compute program call graph of Linux kernel based on FA analysis  Identify entry points of Linux kernel startup_32 System calls invoked during kernel boot process System calls required by user applications Interrupt handlers  Traverse the program call graph to identify all reachable functions

Improve the Analysis  Observation: During kernel initialization, execution is deterministic Only one active thread Only depends on hardware configuration and command line options  Initialization code of kernel is “ static ” If configuration is same, we can safely remove unexecuted initialization code Use.text.init section to identify initialization code Use profiling to identify unexecuted code

Kernel Compaction  Unreachable code elimination Based on reachable code analysis  Whole function abstraction Find identical functions and leave only one instance  Duplicate code elimination Find identical instruction sequences

Experimental Setup  Start with a minimally configured kernel  Compile the kernel with optimization for code size ( gcc –Os )  Compile kernel with and without networking Linux and  Benchmarks: MiBench suite Busybox toolkit (used by Chanet et al.)  Implemented using PLTO

Results: Code Size Reduction Linux Apps. SetAll Sys. CallsBusyboxMiBench With Networking 12.2%18.0%19.3% Without14.5%22.1%23.8%

Effects of Different Optimizations Reduction

Effects of Different Call Targets Analysis Reduction Kernels

Related Work  “ System-wide compaction and specialization of the Linux Kernel ” (LCTES ’ 05) by Chanet et al.  “ Kernel optimizations and prefetch with the Spike executable optimizer ” (FDDO-4) by Flower et al.  “ Survey of code-size reduction methods ” by Beszédes et al.

Conclusions  Embedded systems typically run a small fixed set of applications  General-purpose OSs contain features that are not needed in every application  An automated technique to safely discard unnecessary code Source-level analysis + binary rewriting Approximate decompilation

Questions? Project website:

Binary Rewriting of Linux Kernel  PLTO: a binary rewriting system for Intel x86 architecture  Disassemble kernel code Data embedded within executable section Implicit addressing constraints Unusual instruction sequences Applied a type-based recursive disassemble algorithm Able to disassemble 94% code