Cider

Native Execution of iOS Apps on Android

Jeremy Andrus ([email protected]) Alexander Van't Hof, Naser AlDuaij, Christoffer Dall, Nicolas Viennot, Jason Nieh Columbia University In the City of New York

March 4, 2014 ASPLOS 2014, Salt Lake City, UT !1 Presentation © 2014, Jeremy . Andrus Motivation The Goal

Presentation © 2014, Jeremy C. Andrus !3 Motivation Virtualization

Presentation © 2014, Jeremy C. Andrus !4 Motivation Binary Compatibility

Wine

API Reimplementation

✤ immense implementation! ✤ 20 years later: still incomplete

Presentation © 2014, Jeremy C. Andrus !5 Motivation Overview Binary Compatibility

Kernel ABI Compatibility

BSD Linux Compatibility

✤ missing kernel subsystem! ✤ opaque driver interfaces

Presentation © 2014, Jeremy C. Andrus !6 Motivation Overview Cider : OS Compatibility

✤ Direct execution of unmodified iOS apps" ✤ Reuse existing libraries" ✤ Reuse existing open source kernel code" ✤ iOS apps can use Android libraries

Presentation © 2014, Jeremy C. Andrus !7 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Cider : OS Compatibility

✤ Personas" ➡ distinguish iOS and Linux threads" ✤ Duct Tape" ➡ XNU code in the " ✤ Diplomats" ➡ iOS apps use Android libraries

Presentation © 2014, Jeremy C. Andrus !8 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Cider : OS Compatibility

XNU syscall Linux syscall Interface Interface Cider Linux Kernel

Mach-O Loader

Presentation © 2014, Jeremy C. Andrus !9 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Per-Thread Personas

XNU syscall Linux syscall Interface Interface Cider Linux Kernel

Persona -O Management Loader

Presentation © 2014, Jeremy C. Andrus !10 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Cider : OS Compatibility

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Management Loader

Presentation © 2014, Jeremy C. Andrus !11 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Duct tape

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Duct Tape Management Loader

Presentation © 2014, Jeremy C. Andrus !12 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Duct tape

XNU Source

Foreign Zone Mach IPC

Duct Tape Duct Tape Zone

Domestic Zone

Presentation © 2014, Jeremy C. Andrus !13 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Duct tape lck_mtx_lock() ➡ mutex_lock() lck_mtx_t ➡ struct mutex XNU Source Linux kernel" Mach IPC memory, synch," list management, etc.

Synchronization, List Mgmt Duct Tape Mach Semantics kmalloc, Mach IPC syscall stubs spinlock, list…

Presentation © 2014, Jeremy C. Andrus !14 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Duct tape

XNU Source Cider" Linux"

Mach IPC Kernel

Synchronization, List Mgmt Mach Semantics kmalloc, spinlock, list…

Mach IPC syscall stubs

Presentation © 2014, Jeremy C. Andrus !15 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Cider : OS Compatibility

iOS OpenGL

Apple GPU?!

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Duct Tape Management Loader

Presentation © 2014, Jeremy C. Andrus !16 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Cider : OS Compatibility

ELF?? Android OpenGL

??

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Duct Tape Management Loader

Presentation © 2014, Jeremy C. Andrus !17 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Cider : OS Compatibility

Android ?? OpenGL

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Duct Tape Management Loader

Presentation © 2014, Jeremy C. Andrus !18 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Diplomats

Android Libraries

diplomats

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Duct Tape Management Loader

Presentation © 2014, Jeremy C. Andrus !19 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android Diplomats iOS App links against diplomats - not iOS symbols!

Android diplomats Libraries

aFunc()

XNU syscall Persona Linux syscall Interface Management Interface Cider Linux Kernel

Presentation © 2014, Jeremy C. Andrus !20 Motivation Overview Personas Duct Tape Diplomats Evaluation iOS Android

Cider : Architecture iOS Mach" IPC Services configd Android … Libraries

diplomats

XNU Source XNU syscall Linux syscall Interface Interface Mach IPC Cider Linux Kernel

Persona Mach-O Duct Tape Management Loader

Presentation © 2014, Jeremy C. Andrus !21 Motivation Overview Personas Duct Tape Diplomats Evaluation Cider: Prototype iOS Apps!

✤ Nexus 7 (Tegra)" ➡ Integrated iOS app launch

Android Apps!

Presentation © 2014, Jeremy C. Andrus !22 Motivation Overview Personas Duct Tape Diplomats Evaluation Cider: Prototype

✤ Nexus 7 (Tegra)" ➡ Full multi-touch support" ➡ OpenGL for 2D/3D graphics

Presentation © 2014, Jeremy C. Andrus !23 Motivation Overview Personas Duct Tape Diplomats Evaluation Cider: Experimental Results

✤ PassMark benchmark application" ✤ Android App" ➡ Stock Nexus 7" ➡ Cider" ✤ iOS App" ➡ Cider" ➡ iPad mini

Presentation © 2014, Jeremy C. Andrus !24 Motivation Overview Personas Duct Tape Diplomats Evaluation Cider: Experimental Results PassMark Benchmark 20! Cider Android! Cider iOS! iOS! 15!

10!

5! Normalized Performance

Normalized Performance Normalized 0! 4!

3!

2!

1!

0! ! ! ! ! ! ! ! ! ! !

Integer

Find Primes Storage Read Floating Point Storage Write Memory WriteMemory Read Data Encryption Data Compression Presentation © 2014, Jeremy C. AndrusRandom String Sort !25 Motivation Overview Personas Duct Tape Diplomats Evaluation Cider: Experimental Results PassMark Benchmark 2.020!! CiderCider AndroidAndroid!! CiderCider iOS iOS! ! iOSiOS! ! 15!

1.510!!

5!

1.00!! 4!

3!

0.5! 2!

1!

0.0! 0! ! ! ! ! ! ! ! ! ! ! !! ! ! ! ! !

Integer

Find Primes Solid Vectors Image FiltersStorage Read Floating Point Storage Write Memory WriteMemory Read Data Encryption Simple 3D Test Complex VectorsImageData CompressionRendering Complex 3D Test Presentation © 2014, JeremyTransparent C. AndrusRandom Vectors String Sort 54 Motivation Overview Personas Duct Tape Diplomats Evaluation Cider: Experimental Results PassMark Benchmark 2.0! Cider Android! Cider iOS! iOS!

1.5!

1.0!

0.5!

0.0! ! ! ! ! ! ! !

Solid Vectors Image Filters Simple 3D Test Complex VectorsImage Rendering Complex 3D Test Presentation © 2014, JeremyTransparent C. Andrus Vectors !27 Motivation Overview Personas Duct Tape Diplomats Evaluation Conclusion

✤ Direct execution of unmodified iOS apps" ➡ Per-thread Personas" ➡ Duct Tape" ➡ Diplomats

Presentation © 2014, Jeremy C. Andrus !28 Motivation Overview Personas Duct Tape Diplomats Evaluation

Thank You

Cider

http://systems.cs.columbia.edu/projects/cider

Logo design by: Steve Lovelace (http://steve-lovelace.com/) Presentation © 2014, Jeremy C. Andrus !29