Vmbear Main Page
Total Page:16
File Type:pdf, Size:1020Kb
VMB: A General Purpose x86 Virtual Machine Monitor Matthew Schulkind Department of Computer Science Columbia University [email protected] 1 Introduction 2.2 Parallels Workstation Parallels[5] Workstation is a product very similar in na- VMB is an open-source x86 virtualizer. The goal is to ture to VMWare Workstation. The website claims that support fast virtualization of all x86 operating systems it is the first virtualization product which runs on top of without requiring any modifications to the guest operat- the Intelversion of OS X. It also runs on top of Windows ing system. Currently there are no open-source appli- and Linux. cations which fully virtualize an unmodified operating system; VMB will fill this niche. This will provide a 2.3 QEMU framework to expand upon for anyone who wishes to do QEMU[6] is a very functional open-source CPU emula- research on specific aspects of x86 virtualization such as tor which can emulate a number of different processors optimizing network performance. The only host operat- including the x86 on top of a variety of host systems. ing system supported currently is the Linux 2.4 kernel. This is fundamentally different than the goal of VMB VMB does not require much functionality at all from the which is to virtualize and not emulate. host operating system other than allocating memory, so it should not be very hard to port to other host operating 2.4 QVM86 systems. QVM86[8] is an open-source add-on module for QEMU Currently work is being done to support the Linux 2.4 which enables some guest code to run natively on the series as a guest OS, but no hacks specific to this guest host CPU when an x86 guestis beingrun on an x86 host. operating systems are being implemented. All virtual- Almost all of the problems encountered by virtualization ization support is general-purpose; the reason work is programs such as VMWare and VMB are avoided by being focused on the Linux 2.4 series is that it allows running all kernel-mode code through the QEMU em- a certain subset of x86 features to be implemented at ulation software. This simplifies the design a lot since first. Once the Linux 2.4 series is supported, it should be QEMU is already very functional, but it also means that trivial to support the 2.6 series, and relatively little de- theoretically it will never be as fast as a full virtualiza- velopment time should be required to support any flavor tion solution. The current status of this project is that it of BSD or Microsoft Windows[4] compared to the de- will boot Windows 98, but it is still unstable, and Linux velopment time needed to support the Linux 2.4 kernel boots up as well but may still have some minor bugs. initially. 2.5 The QEMU Accelerator Module The QEMU Accelerator Module[7], also known as 2 Related Work kqemu, is very similar to QVM86 in that it is a add- on to QEMU which adds virtualization support. Un- 2.1 VMWare Workstation like QVM86, the QEMU Accelerator Modules is closed- source. The most recent version adds support to virtual- VMWare[10] is a company which makes various dif- ize some guest kernel code in addition to the guest user ferent commercial applications, all which provide full code which QVM86 is able to virtualize. Even though x86 virtualization. VMWare Workstation[12] is the most some kernel code is virtualized, full virtualization is not similar to VMB in that it provides x86 virtualization provided due to some assumptions being made about with a hosted architecture, described in Section 3.5. The the workings of the guest OS. These assumptions should latest version is very functional, but it is a closed-source only lead to unsupported functions in the guest OS and project with a fairly large price tag. There are currently not a compromise of the host OS. The website claims no open-source projects which provide the same features that the assumptions should be safe for Windows and that VMWare Workstation does, primarily the ability to Linux guests, but other operating systems may not func- fully virtualize an unmodified operating system. tion correctly. 2.6 Xen This also allows applications of the guest OS to still run Xen[13] is an open-source virtualization project run by as ring 3 so that they do not have enough privileges to the University of Cambridge. It has similar goals to modify the guest OS kernel directly. VMB, but Xen requires that the guest OS be modified 3 Architecture to run under it. The modifications are also non-trivial in nature and require a fairly significant amount of ef- 3.1 Overview fort to port an OS to run under Xen. Also, currently Figure 1 shows an overview of the VMB architecture. there are no plans to support Windows due to licensing There are two distinct address spaces which can be issues with modifying Windows source code. VMB will switched to: that of the host kernel and that of the guest. be able to eventually run Windows since no modifica- The magic page, described in Section 4.1, is used to tions will be necessary. On the up side, because Xen switch between these two address spaces. To allow the requires the OS to be modified, there is almost no speed VMM to be able to catch faults which occur inside the hit in many situations between running an OS under Xen guest, the Linux ptrace interface is used. The VMM and directly on the x86 hardware. Xen significantly out- and GUI run inside the host world so that they have ac- performs the latest version of VMWare which allows cess to the functionality provided by the host kernel. for benchmarks to be published and unofficially outper- The guest runs inside the guest world so that it can be forms to some degree the latest version of VMWare in- given control over its address space. The guest is al- cluding their ESX Server[11]. Work is in progress on ways run in an unprivileged execution mode so that it a beta version of Xen which utilizes the new VT and can’t directly access any privileged state. All attempts Pacifica by Intel and AMD respectively which provide to access privileged state trap into the VMM through the support for hardware-assisted virtualization. This new ptrace interface and are handled appropriately. Typ- version will eventually allow fast virtualization of un- ical IRET/interrupt pairs are used for control transfer modified operating systems, but currently the beta runs between privileged and unprivileged code. The VMB unacceptably slow and requires hardware which is not kernel module and VMM communicate using a charac- available publicly. ter device. Xen does not attempt to directly virtualize any part of the x86 architecture which can not be done efficiently. # cd vmb/ Instead of directly virtualizing these parts of the x86 ar- # insmod vmb.o chitecture, Xen provides a similar interface to the OS. # mkdir ramfs The OS must be modified to use this Xen provided in- # mount -t ramfs none ramfs terface instead of those provided by the x86 architecture # dd if=/dev/zero of=ramfs/ram \ itself. This allows Xen to filter and emulate various dif- > bs=1M count=64 ferent privileged functions such as writing to a page ta- 64+0 records in ble. 64+0 records out To handle the provided interfaces and virtualization # dd if=/dev/zero of=ramfs/shadow \ of the rest of the x86 architecture, Xen uses a hyper- > bs=1M count=64 visor layer. This is a very lightweight operating sys- 64+0 records in tem which is started before the guest OS and is always 64+0 records out mapped into the current process space. The hypervisor # ./vmb is mapped into all process spaces so that there does not need to be a full context switch and corresponding TLB flush to handle the virtualization of privileged instruc- tions. One difficulty of keeping the hypervisor mapped Figure 2: Running VMB into all processes is ensuring that the part of the address space allocated to the hypervisoris not also in use by the Figure 2 shows the steps needed to start VMB after guest OS. Xen accomplishes this by reserving the upper it has already been built. Both a floppy image and a 64MB of the address space purely for Xen. This task hard drive image can be supplied. Currently the paths will not be quite as trivial for VMB since there will be to the two images are hard-coded, but the two image lo- no guaranteed area of the address space free. cations could easily be read at run-time. Once the steps To make sure that the guestOS can neverrun any priv- in Figure 2 are followed, one must type “run” in the ileged instructions without Xen’s consent, the guest OS command box at the bottom of the window and hit enter. is run at ring 1 and the hypervisor runs at ring 0. This Due to a GUI bug, one must click in the debug log box means that whenever the guest OS attempts to execute at the top of the window before typing text meant for the a privileged instruction, it will trap into the hypervisor. guest. Guest world Host world Magic page Host kernel VMB kernel module IRET IRET Char device InterruptPage table Interrupt load using the magic Guest page VMM and GUI ptrace() Figure 1: VMB Block Diagram 3.2 Code Structure the virtualization can be done with the help of hardware The source code is organized into three main parts, a virtualization mechanisms, but some must also be done GUI, a virtualization component, and a kernel module to through software trickery.