A Binary Compatible Unikernel Pierre Olivier*, Daniel Chiba*, Stefan - - PowerPoint PPT Presentation

a binary compatible unikernel
SMART_READER_LITE
LIVE PREVIEW

A Binary Compatible Unikernel Pierre Olivier*, Daniel Chiba*, Stefan - - PowerPoint PPT Presentation

A Binary Compatible Unikernel Pierre Olivier*, Daniel Chiba*, Stefan Lankes + , Changwoo Min*, Binoy Ravidnran* *Virginia Tech, + RWTH Aachen University VEE19 - 04/14/2019 Unikernels Presentation Full-fledged Virtual Machine Linux


slide-1
SLIDE 1

A Binary Compatible Unikernel

Pierre Olivier*, Daniel Chiba*, Stefan Lankes+, Changwoo Min*, Binoy Ravidnran*

*Virginia Tech, +RWTH Aachen University

VEE’19 - 04/14/2019

slide-2
SLIDE 2

Unikernels

Presentation

Application Libraries OS interface used Linux distribution Linux Kernel Hypervisor Hardware Full-fledged Virtual Machine

2/11

slide-3
SLIDE 3

Unikernels

Presentation

Application Libraries OS interface used Linux distribution Linux Kernel Hypervisor Hardware Full-fledged Virtual Machine Legend : Useful software Software bloat

2/11

slide-4
SLIDE 4

Unikernels

Presentation

Application Libraries OS interface used Linux distribution Linux Kernel Hypervisor Hardware Application Libraries OS Layer Full-fledged Virtual Machine Unikernel Legend : Useful software Software bloat

2/11

slide-5
SLIDE 5

Unikernels

Presentation (2) Unikernel: application + dependencies + thin OS compiled as a static binary running on top of a hypervisor

3/11

slide-6
SLIDE 6

Unikernels

Presentation (2) Unikernel: application + dependencies + thin OS compiled as a static binary running on top of a hypervisor

◮ single-*

◮ Single purpose: run 1 application ◮ Single process ◮ Single binary and single address space for application + kernel ◮ No user/kernel protection needed 3/11

slide-7
SLIDE 7

Unikernels

Presentation (2) Unikernel: application + dependencies + thin OS compiled as a static binary running on top of a hypervisor

◮ single-*

◮ Single purpose: run 1 application ◮ Single process ◮ Single binary and single address space for application + kernel ◮ No user/kernel protection needed

◮ Lightweight virtualization, alternative to containers

◮ Security advantage: small attack surface and high isolation 3/11

slide-8
SLIDE 8

Unikernels

Presentation (2) Unikernel: application + dependencies + thin OS compiled as a static binary running on top of a hypervisor

◮ single-*

◮ Single purpose: run 1 application ◮ Single process ◮ Single binary and single address space for application + kernel ◮ No user/kernel protection needed

◮ Lightweight virtualization, alternative to containers

◮ Security advantage: small attack surface and high isolation

◮ Per-application tailored kernel

◮ LibOS/Exokernel model 3/11

slide-9
SLIDE 9

Unikernels

Presentation (2) Unikernel: application + dependencies + thin OS compiled as a static binary running on top of a hypervisor

◮ single-*

◮ Single purpose: run 1 application ◮ Single process ◮ Single binary and single address space for application + kernel ◮ No user/kernel protection needed

◮ Lightweight virtualization, alternative to containers

◮ Security advantage: small attack surface and high isolation

◮ Per-application tailored kernel

◮ LibOS/Exokernel model

◮ Reduced OS noise, increased performance

◮ Low system call latency ◮ App + kernel in ring 0, system calls are function calls 3/11

slide-10
SLIDE 10

Unikernels

The Issue

◮ Unikernels have plenty of benefits to bring ◮ Unikernels have plenty of application domains ◮ They are very popular in academia . . . ◮ . . . but why (nearly) nobody uses them in the industry?

4/11

slide-11
SLIDE 11

Unikernels

The Issue

◮ Unikernels have plenty of benefits to bring ◮ Unikernels have plenty of application domains ◮ They are very popular in academia . . . ◮ . . . but why (nearly) nobody uses them in the industry?

Because it is hard to port existing applications!

4/11

slide-12
SLIDE 12

Unikernels

The Issue: Porting to Unikernels

Application src Unikernel & libraries src Build (compile, link, etc.) Unikernel binary Execution 5/11

slide-13
SLIDE 13

Unikernels

The Issue: Porting to Unikernels

Application src Unikernel & libraries src Build (compile, link, etc.) Unikernel binary Execution

◮ Proprietary software → source code not available

5/11

slide-14
SLIDE 14

Unikernels

The Issue: Porting to Unikernels

Application src Unikernel & libraries src Build (compile, link, etc.) Unikernel binary Execution

◮ Proprietary software → source code not available ◮ Incompatible language

5/11

slide-15
SLIDE 15

Unikernels

The Issue: Porting to Unikernels

Application src Unikernel & libraries src Build (compile, link, etc.) Unikernel binary Execution

◮ Proprietary software → source code not available ◮ Incompatible language ◮ Unsupported features

5/11

slide-16
SLIDE 16

Unikernels

The Issue: Porting to Unikernels

Application src Unikernel & libraries src Build (compile, link, etc.) Unikernel binary Execution

◮ Proprietary software → source code not available ◮ Incompatible language ◮ Unsupported features ◮ Porting is hard, needs knowledge about both application and

unikernel

5/11

slide-17
SLIDE 17

Unikernels

The Issue: Porting to Unikernels

Application src Unikernel & libraries src Build (compile, link, etc.) Unikernel binary Execution

◮ Proprietary software → source code not available ◮ Incompatible language ◮ Unsupported features ◮ Porting is hard, needs knowledge about both application and

unikernel

◮ Complex build toolchains

5/11

slide-18
SLIDE 18

Unikernels

The Issue: Porting to Unikernels

◮ Proprietary software → source code not available ◮ Incompatible language ◮ Unsupported features ◮ Porting is hard, needs knowledge about both application and

unikernel

◮ Complex build toolchains

HermiTux Solution

◮ A unikernel binary-compatible with Linux

◮ For x86-64 for now 5/11

slide-19
SLIDE 19

Unikernels

Overview

◮ Linux ABI

convention:

6/11

slide-20
SLIDE 20

Unikernels

Overview

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

6/11

slide-21
SLIDE 21

Unikernels

Overview

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls 6/11

slide-22
SLIDE 22

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve KVM

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

6/11

slide-23
SLIDE 23

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Guest Host KVM

Single-address space VM

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

6/11

slide-24
SLIDE 24

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Native Linux App. Load Guest Host KVM

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

6/11

slide-25
SLIDE 25

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Native Linux App. Load Guest Host KVM Hermitux kernel

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

6/11

slide-26
SLIDE 26

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Native Linux App. Load

  • Init. stack and jump to entry point

Guest Host KVM Hermitux kernel

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

6/11

slide-27
SLIDE 27

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Native Linux App. Load

  • Init. stack and jump to entry point

Syscall Guest Host KVM Hermitux kernel handler

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

◮ Complete/partial

support for 80+ syscalls

6/11

slide-28
SLIDE 28

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Native Linux App. Load

  • Init. stack and jump to entry point

Guest Host KVM Debug, profile Syscall Hermitux kernel handler

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

◮ Complete/partial

support for 80+ syscalls

6/11

slide-29
SLIDE 29

Unikernels

Overview

Host: Linux kernel Hypervisor: uHyve Native Linux App. Load

  • Init. stack and jump to entry point

Guest Host KVM Debug, profile Syscall Hermitux kernel handler

◮ Linux ABI

convention:

◮ ELF loader

convention

◮ Load-time Stack

layout

◮ Syscalls

◮ Kernel adapted

from HermitCore

◮ Complete/partial

support for 80+ syscalls

◮ How to maintain unikernel benefits without access to

the application sources?

◮ Fast system calls and modularity 6/11

slide-30
SLIDE 30

Unikernels

Fast Syscalls with Libc Substitution

◮ HermiTux’s syscall handler is invoked by the syscall

instruction

◮ Reintroduce high latency for system calls due to the world

switch

7/11

slide-31
SLIDE 31

Unikernels

Fast Syscalls with Libc Substitution

◮ HermiTux’s syscall handler is invoked by the syscall

instruction

◮ Reintroduce high latency for system calls due to the world

switch

◮ For dynamically compiled programs:

◮ At runtime load a unikernel-aware Libc ◮ Making for system calls (fast) function calls directly into the

kernel

◮ Automatically transformed version of Musl Libc with Coccinelle Musl LibC Coccinelle Semantic patch (80 LoC) Patch (4400 LoC) “unikernelized” LibC 7/11

slide-32
SLIDE 32

Unikernels

Fast Syscalls with Binary Rewriting

◮ What about static binaries? ◮ (Statically) binary-rewrite syscall instructions to direct

jumps to the syscall implementation

◮ Problem: syscall is 2 bytes long and any call/jmp

instruction will be larger

mov %r10, %rcx callq 0x200457 (read) mov $2, %esi jmp 0x400aac Original code Rewritten code Snippet … mov $0, %rax (read) mov $3, %rdi … … j m p x 2 4 2 n

  • p

n

  • p

mov $3, %rdi … (5 bytes) (1 byte) (1 byte) Syscall binary rewriting j m p x 2 4 2 n

  • p

n

  • p

(5 bytes) (1 byte) (1 byte) s y s c a l l m

  • v

$ 2 , % e s i (5 bytes) (2 bytes)

8/11

slide-33
SLIDE 33

Unikernels

Fast Syscalls with Binary Rewriting

◮ What about static binaries? ◮ (Statically) binary-rewrite syscall instructions to direct

jumps to the syscall implementation

◮ Problem: syscall is 2 bytes long and any call/jmp

instruction will be larger

0.000 0.005 0.010 0.015 0.020 0.025 0.030 null (getppid) read write Exection time (s) Linux (native) Hermitux Handler Hermitux Rewrite Hermitux Lib. Substitution

Lmbench3

8/11

slide-34
SLIDE 34

Unikernels

System-call-based Modularity

◮ System-call based modularity

◮ Compile a kernel with support for only the necessary system

calls

◮ How to identify syscall needed without access to the sources? ◮ Use binary analysis to find out what is the value in %rax for

each syscall invocation

Program Number of system calls Kernel .text size reduction Minimal 5 21.87 % Hello world 10 19.84 % PARSEC Blackscholes 15 17.05 % Postmark 26 14.36 % Sqlite 31 11.34 % Full syscalls support 64 00.00 %

9/11

slide-35
SLIDE 35

Unikernels

Evaluation

1 10 100 1000 Binary size (MB) 0.01 0.1 1 10 100 Boot + destruction time (s) 1 10 100 Memory Usage (MB)

Legend: Low isolation (software or none) Strong isolation (EPT) Binary compatible with Linux Not Binary compatible with Linux

Binary Size Boot + Destruction time RAM usage

◮ Image 650x smaller, boot time 780x faster, RAM usage 9x

lower than a Linux VM!

BT (Fortran) EP (C) IS (C) Stream cluster (C++) Swap tions (C++) NBody (Python) 1 2

  • Exec. time nor-

malized to Linux HermiTux Docker OSv Rump

hermiTux Linux Osv Rump 10000 20000 30000 40000 50000 SET GET Requests/sec

Redis

10/11

slide-36
SLIDE 36

Conclusion

◮ Porting to unikernels is hard

◮ Hinders their adoption in the industry

◮ HermiTux provides binary-compatibility with Linux

applications

◮ HermiTux maintains unikernel benefits:

◮ Fast boot times, small footprints ◮ Various techniques to get fast system calls and modularity

It’s open source, try it out! https://ssrg-vt.github.io/hermitux/

11/11