a binary compatible unikernel
play

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


  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

  2. Unikernels Presentation Full-fledged Virtual Machine Linux distribution Application Libraries Linux OS interface used Kernel Hypervisor Hardware 2/11

  3. Unikernels Presentation Full-fledged Virtual Machine Legend : Linux Useful software distribution Software bloat Application Libraries Linux OS interface used Kernel Hypervisor Hardware 2/11

  4. Unikernels Presentation Full-fledged Virtual Machine Legend : Linux Useful software distribution Software bloat Application Unikernel Libraries Application Libraries Linux OS interface used Kernel OS Layer Hypervisor Hardware 2/11

  5. Unikernels Presentation (2) Unikernel: application + dependencies + thin OS compiled as a static binary running on top of a hypervisor 3/11

  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

  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

  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

  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

  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

  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

  12. Unikernels The Issue: Porting to Unikernels Application Execution src Build Unikernel (compile, binary Unikernel & link, etc.) libraries src 5/11

  13. Unikernels The Issue: Porting to Unikernels Application Execution src Build Unikernel (compile, binary Unikernel & link, etc.) libraries src ◮ Proprietary software → source code not available 5/11

  14. Unikernels The Issue: Porting to Unikernels Application Execution src Build Unikernel (compile, binary Unikernel & link, etc.) libraries src ◮ Proprietary software → source code not available ◮ Incompatible language 5/11

  15. Unikernels The Issue: Porting to Unikernels Application Execution src Build Unikernel (compile, binary Unikernel & link, etc.) libraries src ◮ Proprietary software → source code not available ◮ Incompatible language ◮ Unsupported features 5/11

  16. Unikernels The Issue: Porting to Unikernels Application Execution src Build Unikernel (compile, binary Unikernel & link, etc.) libraries src ◮ Proprietary software → source code not available ◮ Incompatible language ◮ Unsupported features ◮ Porting is hard, needs knowledge about both application and unikernel 5/11

  17. Unikernels The Issue: Porting to Unikernels Application Execution src Unikernel Build binary Unikernel & (compile, libraries src link, etc.) ◮ 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

  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

  19. Unikernels Overview ◮ Linux ABI convention: 6/11

  20. Unikernels Overview ◮ Linux ABI convention: ◮ ELF loader convention ◮ Load-time Stack layout 6/11

  21. Unikernels Overview ◮ Linux ABI convention: ◮ ELF loader convention ◮ Load-time Stack layout ◮ Syscalls 6/11

  22. Unikernels Overview ◮ Linux ABI convention: ◮ ELF loader convention ◮ Load-time Stack layout ◮ Syscalls ◮ Kernel adapted Hypervisor: uHyve from HermitCore Host: Linux kernel KVM 6/11

  23. Unikernels Overview ◮ Linux ABI convention: ◮ ELF loader convention ◮ Load-time Stack Single-address space VM layout Guest ◮ Syscalls ◮ Kernel adapted Host Hypervisor: uHyve from HermitCore Host: Linux kernel KVM 6/11

  24. Unikernels Overview ◮ Linux ABI convention: ◮ ELF loader convention ◮ Load-time Stack Native layout Linux Guest ◮ Syscalls App. ◮ Kernel adapted Load Host Hypervisor: uHyve from HermitCore Host: Linux kernel KVM 6/11

  25. Unikernels Overview ◮ Linux ABI convention: ◮ ELF loader convention ◮ Load-time Stack Native layout Linux Guest Hermitux ◮ Syscalls App. kernel ◮ Kernel adapted Load Host Hypervisor: uHyve from HermitCore Host: Linux kernel KVM 6/11

  26. Unikernels Overview ◮ Linux ABI convention: Init. stack and jump to entry point ◮ ELF loader convention ◮ Load-time Stack Native layout Linux Guest Hermitux ◮ Syscalls App. kernel ◮ Kernel adapted Load Host Hypervisor: uHyve from HermitCore Host: Linux kernel KVM 6/11

  27. Unikernels Overview ◮ Linux ABI convention: Init. stack and jump to entry point ◮ ELF loader convention ◮ Load-time Stack handler Native Syscall layout Linux Guest Hermitux ◮ Syscalls App. kernel ◮ Kernel adapted Load Host Hypervisor: uHyve from HermitCore ◮ Complete/partial Host: Linux kernel KVM support for 80+ syscalls 6/11

  28. Unikernels Overview ◮ Linux ABI convention: Init. stack and jump to entry point ◮ ELF loader convention ◮ Load-time Stack handler Native Syscall layout Linux Guest Hermitux ◮ Syscalls App. kernel ◮ Kernel adapted Load Host Hypervisor: uHyve from HermitCore ◮ Complete/partial Host: Linux kernel KVM Debug, profile support for 80+ syscalls 6/11

  29. Unikernels Overview ◮ Linux ABI convention: Init. stack and jump to entry point ◮ ELF loader convention ◮ Load-time Stack handler Native Syscall layout Linux Guest Hermitux ◮ Syscalls App. kernel ◮ Kernel adapted Load Host Hypervisor: uHyve from HermitCore ◮ Complete/partial Host: Linux kernel KVM Debug, profile support for 80+ syscalls ◮ How to maintain unikernel benefits without access to the application sources? ◮ Fast system calls and modularity 6/11

  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

  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 “unikernelized” Semantic patch Patch LibC Coccinelle Musl LibC (80 LoC) (4400 LoC) 7/11

  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 Syscall binary rewriting … (5 bytes) (5 bytes) j m p 0 x 2 0 0 0 4 2 j m p 0 x 2 0 0 0 4 2 … (1 byte) (1 byte) n o p n o p mov $0, %rax (read) (1 byte) (1 byte) n n o o p p (2 bytes) s y s c a l l mov $3, %rdi i (5 bytes) m o v $ 2 , % e s … mov $3, %rdi Rewritten code Snippet … mov %r10, %rcx Original code callq 0x200457 (read) mov $2, %esi jmp 0x400aac 8/11

Recommend


More recommend