general-purpose computing with virtualbox on genode/nova

78
General-purpose computing with VirtualBox on Genode/NOVA Norman Feske <[email protected]>

Upload: khangminh22

Post on 24-Mar-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

General-purpose computing withVirtualBox on Genode/NOVA

Norman Feske<[email protected]>

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 2

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 3

Architecture overview

SVC

config,status

IPCD

VMprocess

VMprocess

VBoxManage VirtualBoxApplication

/dev/vboxdrv /dev/vboxdrv

xpcom xpcomxp

com

xpcom

General-purpose computing with VirtualBox on Genode/NOVA 4

Starting up a VM process

VMprocess

/dev/vboxdrv

open

kernel

vboxdrv.ko

General-purpose computing with VirtualBox on Genode/NOVA 5

VM process running

root mode non-root mode

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

VMMR0 / Hypervisor

load VMMR0

General-purpose computing with VirtualBox on Genode/NOVA 6

Entering the Guest OS

root mode non-root mode

Guest OS

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

ioctrl VM RUN

world switch

General-purpose computing with VirtualBox on Genode/NOVA 7

Flow of a virtualization event

root mode non-root mode

Guest OS

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

world switch

VMMR0 ?yes

no

VM RUNreturns

General-purpose computing with VirtualBox on Genode/NOVA 8

Risks for desktop virtualization

root mode non-root mode

Guest OS

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

VMMR0 / Hypervisor

highly complex

General-purpose computing with VirtualBox on Genode/NOVA 9

Risks for desktop virtualization

root mode non-root mode

Guest OS

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

VMMR0 / Hypervisor

highly complex

General-purpose computing with VirtualBox on Genode/NOVA 9

Risks for desktop virtualization

root mode non-root mode

Guest OS

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

VMMR0 / Hypervisor

highly complex

access control?

General-purpose computing with VirtualBox on Genode/NOVA 10

Risks for desktop virtualization

root mode non-root mode

Guest OS

VMprocess

/dev/vboxdrvkernel

vboxdrv.ko

VMMR0 / Hypervisor

highly complex

access control?

authorized tochange the kernel

highly complex

General-purpose computing with VirtualBox on Genode/NOVA 11

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 12

NOVA architecture

non-root mode

root mode

kernel

NOVA Microhypervisor

9,000 SLOC

Resource managementApps Drivers

VMMVMM VMM

Guest OS Guest OS Guest OS

General-purpose computing with VirtualBox on Genode/NOVA 13

Flow of a virtualization event

User-level VMM Guest OS

NOVA

UTCB

UTCB

VMCS

world switch

copy

General-purpose computing with VirtualBox on Genode/NOVA 14

Genode OS architecture

→ Application-specific TCB

General-purpose computing with VirtualBox on Genode/NOVA 15

Genode OS framework

General-purpose computing with VirtualBox on Genode/NOVA 16

Genode combined with virtualization

General-purpose computing with VirtualBox on Genode/NOVA 17

Seoul VMM on top of Genode/NOVA

User Mode

Privileged ModeNOVA Hypervisor

Core

Init

Resource Multiplexer

UnmodifiedGuest OS

virtual CPU

virtual device

virtual RAM

VMMDevice Driver

Kernel

General-purpose computing with VirtualBox on Genode/NOVA 18

Idea

Device models and features of VirtualBox

+

Security of the Genode/NOVA architecture

General-purpose computing with VirtualBox on Genode/NOVA 19

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 20

Identify the interesting parts

Entire VirtualBox code base> 4 million lines of code (sloccount)

Narrowed to the interesting parts> 2 million lines of code

src/VBox/VMM src/recompilersrc/VBox/Main src/libs/liblzf-3.4src/VBox/Runtime src/libs/liblzf-3.4/cssrc/VBox/Devices src/libs/libxml2-2.6.31src/VBox/Storage src/libs/zlib-1.2.6src/VBox/GuestHost include/VBoxsrc/VBox/Disassembler include/iprtsrc/VBox/HostServices

General-purpose computing with VirtualBox on Genode/NOVA 21

Porting the VirtualBox Runtime to Genode

Facilitate Genode’s existing infrastructureI 3rd-party software management toolsI FreeBSD libcI Standard C++ libraryI POSIX threads

→ Most parts of the POSIX runtime could be reused

General-purpose computing with VirtualBox on Genode/NOVA 22

Porting the VirtualBox Runtime to Genode

Facilitate Genode’s existing infrastructureI 3rd-party software management toolsI FreeBSD libcI Standard C++ libraryI POSIX threads

→ Most parts of the POSIX runtime could be reused

General-purpose computing with VirtualBox on Genode/NOVA 22

VM process initialization

Enable subsystems one by one

Guest memory (accessed by recompiler and device models)RAM, MMIOI/O-port handlingPGM, HWACCM, TMDevice models, PDM, BIOSHost drivers

I Using the “Basic front end”I Reimplement SDLConsole interface

General-purpose computing with VirtualBox on Genode/NOVA 23

VM process initialization

Enable subsystems one by one

Guest memory (accessed by recompiler and device models)RAM, MMIO

I/O-port handlingPGM, HWACCM, TMDevice models, PDM, BIOSHost drivers

I Using the “Basic front end”I Reimplement SDLConsole interface

General-purpose computing with VirtualBox on Genode/NOVA 23

VM process initialization

Enable subsystems one by one

Guest memory (accessed by recompiler and device models)RAM, MMIOI/O-port handling

PGM, HWACCM, TMDevice models, PDM, BIOSHost drivers

I Using the “Basic front end”I Reimplement SDLConsole interface

General-purpose computing with VirtualBox on Genode/NOVA 23

VM process initialization

Enable subsystems one by one

Guest memory (accessed by recompiler and device models)RAM, MMIOI/O-port handlingPGM, HWACCM, TM

Device models, PDM, BIOSHost drivers

I Using the “Basic front end”I Reimplement SDLConsole interface

General-purpose computing with VirtualBox on Genode/NOVA 23

VM process initialization

Enable subsystems one by one

Guest memory (accessed by recompiler and device models)RAM, MMIOI/O-port handlingPGM, HWACCM, TMDevice models, PDM, BIOS

Host driversI Using the “Basic front end”I Reimplement SDLConsole interface

General-purpose computing with VirtualBox on Genode/NOVA 23

VM process initialization

Enable subsystems one by one

Guest memory (accessed by recompiler and device models)RAM, MMIOI/O-port handlingPGM, HWACCM, TMDevice models, PDM, BIOSHost drivers

I Using the “Basic front end”I Reimplement SDLConsole interface

General-purpose computing with VirtualBox on Genode/NOVA 23

A look inside a VM process

ExecutionManager

Recompiler

InstructionEmulator

HardwareAcceleration

VMEnter

VMExit

General-purpose computing with VirtualBox on Genode/NOVA 24

Start with executing the recompiler only

ExecutionManager

Recompiler

InstructionEmulator

HardwareAcceleration

General-purpose computing with VirtualBox on Genode/NOVA 25

Simple test scenario

Linux

CoreROM

Init

FB SDLFramebuffer Input

VirtualBox

ISOimage

kernel

General-purpose computing with VirtualBox on Genode/NOVA 26

Increasing guest complexity

1. Custom-made Genode OS scenarios

2. Small Linux-based images (Tinycore, GRML)

3. Windows XP

General-purpose computing with VirtualBox on Genode/NOVA 27

Increasing guest complexity

1. Custom-made Genode OS scenarios

2. Small Linux-based images (Tinycore, GRML)

3. Windows XP

General-purpose computing with VirtualBox on Genode/NOVA 27

Increasing guest complexity

1. Custom-made Genode OS scenarios

2. Small Linux-based images (Tinycore, GRML)

3. Windows XP

General-purpose computing with VirtualBox on Genode/NOVA 27

Windows XP as a guest

Linux

CoreCore

Init

FB SDLFramebuffer Input

VirtualBoxLX Proxy FS

File system

VDIimage

kernel

General-purpose computing with VirtualBox on Genode/NOVA 28

Move scenario to NOVA

NOVA

Core

Init

VirtualBoxVESA driver

Framebuffer

PS/2 driverInput

Rump FSFile system

AHCI driverBlock

VDIimage

kernel

General-purpose computing with VirtualBox on Genode/NOVA 29

Move scenario to NOVA

NOVA

Core

Init

VirtualBoxVESA driver

Framebuffer

PS/2 driverInput

Rump FSFile system

AHCI driverBlock

VDIimage

kernel

General-purpose computing with VirtualBox on Genode/NOVA 29

Entering non-root mode

ExecutionManager

Recompiler

InstructionEmulator

HardwareAcceleration

VMEnter

VMExit

IRQs

General-purpose computing with VirtualBox on Genode/NOVA 30

Entering non-root mode

VBox VM state ↔ NOVA UTCB state

Virtualization of guest memory(EPT faults)

Enter VT-x conservatively(if protected mode and paging enabled)

Inject IRQs into recompiler

Later: IRQ injection via NOVA into VT-X

General-purpose computing with VirtualBox on Genode/NOVA 31

Entering non-root mode

VBox VM state ↔ NOVA UTCB state

Virtualization of guest memory(EPT faults)

Enter VT-x conservatively(if protected mode and paging enabled)

Inject IRQs into recompiler

Later: IRQ injection via NOVA into VT-X

General-purpose computing with VirtualBox on Genode/NOVA 31

Entering non-root mode

VBox VM state ↔ NOVA UTCB state

Virtualization of guest memory(EPT faults)

Enter VT-x conservatively(if protected mode and paging enabled)

Inject IRQs into recompiler

Later: IRQ injection via NOVA into VT-X

General-purpose computing with VirtualBox on Genode/NOVA 31

Entering non-root mode

VBox VM state ↔ NOVA UTCB state

Virtualization of guest memory(EPT faults)

Enter VT-x conservatively(if protected mode and paging enabled)

Inject IRQs into recompiler

Later: IRQ injection via NOVA into VT-X

General-purpose computing with VirtualBox on Genode/NOVA 31

Entering non-root mode

VBox VM state ↔ NOVA UTCB state

Virtualization of guest memory(EPT faults)

Enter VT-x conservatively(if protected mode and paging enabled)

Inject IRQs into recompiler

Later: IRQ injection via NOVA into VT-X

General-purpose computing with VirtualBox on Genode/NOVA 31

Adding features

Additional driversNetworking

Guest toolsShared foldersHost clockMouse-pointer synchronization

General-purpose computing with VirtualBox on Genode/NOVA 32

Update to VirtualBox 4.3

Basic front end no longer supported

Use of main front end code to NOVA portI Custom console implementationI Shortcut XPCOM middleware

→ Support for using .vbox files

General-purpose computing with VirtualBox on Genode/NOVA 33

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 34

Demo

Windows 7 running in VirtualBox directly on top of NOVA

General-purpose computing with VirtualBox on Genode/NOVA 35

Adaptation of VirtualBox to Genode/NOVA

Ported code

400,000 lines of code (sloccount)

New code

6,200 lines (sloccount)hm, iommio, ioport, mm, pdm, pgm, sup

Modifications of the original code

510 lines added120 lines removed

General-purpose computing with VirtualBox on Genode/NOVA 36

Current state and outlook

Usable performance, optimization ongoing

Focused on VT-X, SVM not regularly tested

Reduces TCB complexity to two orders of magnitude

Useful for building appliances in high-security computing

Stepping stone for using Genode as a general-purpose OS

General-purpose computing with VirtualBox on Genode/NOVA 37

Current state and outlook

Usable performance, optimization ongoing

Focused on VT-X, SVM not regularly tested

Reduces TCB complexity to two orders of magnitude

Useful for building appliances in high-security computing

Stepping stone for using Genode as a general-purpose OS

General-purpose computing with VirtualBox on Genode/NOVA 37

Current state and outlook

Usable performance, optimization ongoing

Focused on VT-X, SVM not regularly tested

Reduces TCB complexity to two orders of magnitude

Useful for building appliances in high-security computing

Stepping stone for using Genode as a general-purpose OS

General-purpose computing with VirtualBox on Genode/NOVA 37

Current state and outlook

Usable performance, optimization ongoing

Focused on VT-X, SVM not regularly tested

Reduces TCB complexity to two orders of magnitude

Useful for building appliances in high-security computing

Stepping stone for using Genode as a general-purpose OS

General-purpose computing with VirtualBox on Genode/NOVA 37

Current state and outlook

Usable performance, optimization ongoing

Focused on VT-X, SVM not regularly tested

Reduces TCB complexity to two orders of magnitude

Useful for building appliances in high-security computing

Stepping stone for using Genode as a general-purpose OS

General-purpose computing with VirtualBox on Genode/NOVA 37

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 38

War stories

Invalid guest state

TLB consistency

Interrupt handling

Large files in shared folders

General-purpose computing with VirtualBox on Genode/NOVA 39

War stories

Invalid guest state

TLB consistency

Interrupt handling

Large files in shared folders

General-purpose computing with VirtualBox on Genode/NOVA 39

War stories

Invalid guest state

TLB consistency

Interrupt handling

Large files in shared folders

General-purpose computing with VirtualBox on Genode/NOVA 39

War stories

Invalid guest state

TLB consistency

Interrupt handling

Large files in shared folders

General-purpose computing with VirtualBox on Genode/NOVA 39

War stories

Invalid guest state

TLB consistency

Interrupt handling

Large files in shared folders

General-purpose computing with VirtualBox on Genode/NOVA 39

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 40

Project Turmvilla

Use of Genode as our day-to-day OS

VirtualBox as migration path

Reference platform: Lenovo Thinkpad x201

General-purpose computing with VirtualBox on Genode/NOVA 41

Project Turmvilla

Use of Genode as our day-to-day OS

VirtualBox as migration path

Reference platform: Lenovo Thinkpad x201

General-purpose computing with VirtualBox on Genode/NOVA 41

Project Turmvilla

Use of Genode as our day-to-day OS

VirtualBox as migration path

Reference platform: Lenovo Thinkpad x201

General-purpose computing with VirtualBox on Genode/NOVA 41

Turmvilla functional requirements

Wireless networking

Storage (SATA drivers + file system)

Graphics (driver + GUI stack)

User input (PS/2 and USB HID)

Integration of guest OS and Genode

A fallback!

General-purpose computing with VirtualBox on Genode/NOVA 42

Turmvilla functional requirements

Wireless networking

Storage (SATA drivers + file system)

Graphics (driver + GUI stack)

User input (PS/2 and USB HID)

Integration of guest OS and Genode

A fallback!

General-purpose computing with VirtualBox on Genode/NOVA 42

Turmvilla functional requirements

Wireless networking

Storage (SATA drivers + file system)

Graphics (driver + GUI stack)

User input (PS/2 and USB HID)

Integration of guest OS and Genode

A fallback!

General-purpose computing with VirtualBox on Genode/NOVA 42

Turmvilla functional requirements

Wireless networking

Storage (SATA drivers + file system)

Graphics (driver + GUI stack)

User input (PS/2 and USB HID)

Integration of guest OS and Genode

A fallback!

General-purpose computing with VirtualBox on Genode/NOVA 42

Turmvilla functional requirements

Wireless networking

Storage (SATA drivers + file system)

Graphics (driver + GUI stack)

User input (PS/2 and USB HID)

Integration of guest OS and Genode

A fallback!

General-purpose computing with VirtualBox on Genode/NOVA 42

Turmvilla functional requirements

Wireless networking

Storage (SATA drivers + file system)

Graphics (driver + GUI stack)

User input (PS/2 and USB HID)

Integration of guest OS and Genode

A fallback!

General-purpose computing with VirtualBox on Genode/NOVA 42

Turmvilla dual-boot setup

genode

ext2

home(LUKS encrypted)

ext4

boot / rescue

ext4 4GiB

/boot

/genode

linux.vdi

- GRUB- GNU/Linux- X11- VirtualBox- mount home- mount genode

Rich GNU/Linuxext3

home(LUKS encrypted)

ext4

Partitions of physical disk

Virtual-machine disks

General-purpose computing with VirtualBox on Genode/NOVA 43

Turmvilla Genode scenario

Init

NitpickerGUI

WindowManager CLI monitor

timeracpi drvacpi report romplatform drvahci drvpart blklog file terminallogrump fswifi drvps2 drvusb drvfb drvrtc drvtrace subject reporterinput mergerreport romnitpickerwm report romwmlayouterdecoratorvbox pointershared fsconfig fsconfig romromcli nit fbcli terminal

VirtualBox Noux

General-purpose computing with VirtualBox on Genode/NOVA 44

Turmvilla state and current focus

Current state:

My primary OS since the beginning of JuneTeam at Genode Labs starts migration

Work in progress:

Tiled and tabbed window managerIntel graphics driverNOVA kernel-resource managementCapability-based desktop environment

General-purpose computing with VirtualBox on Genode/NOVA 45

Turmvilla state and current focus

Current state:

My primary OS since the beginning of JuneTeam at Genode Labs starts migration

Work in progress:

Tiled and tabbed window managerIntel graphics driverNOVA kernel-resource managementCapability-based desktop environment

General-purpose computing with VirtualBox on Genode/NOVA 45

Outline

1. VirtualBox

2. NOVA microhypervisor and Genode

3. Transplantation of VirtualBox to NOVA

4. Demo

5. War stories

6. Project Turmvilla

7. The Book “Genode Foundations”

General-purpose computing with VirtualBox on Genode/NOVA 46

The Book “Genode Foundations”

GENODEOperating System Framework

FoundationsNorman Feske

http://genode.org/documentation/genode-foundations-15-05.pdf

General-purpose computing with VirtualBox on Genode/NOVA 47

Thank you

Genode OS Frameworkhttp://genode.org

Genode Labs GmbHhttp://www.genode-labs.com

Source code at GitHubhttp://github.com/genodelabs/genode

General-purpose computing with VirtualBox on Genode/NOVA 48