Fog Creek Software
Discussion Board

How did VMWare do it?

If the X86 isn't a self-virtualizing processor, how did VMWare do it?

In Awe
Wednesday, June 9, 2004

Well, the x86 IS in fact a virtrialinzg processor, and that feature was first used when windows 3 came out. (it was used to run dos programs that when they miss-behaved. They would supposedly not crash the whole computer when “one” session when down). In fact, this ability is what really made windows really useful, since MOST software at that time was dos based!

However, to create a VM, it is actually VERY easy, and you don’t even need a processor that supports this idea.

The VM concept has been in wide use in the mainframe era almost from day one. IBM, and likey everyother mainframe vendor offered VM for their big iron boxes by the mid 1960’s

You see, all you do is write a small monitor program that sites below every thing else.

So, you get:

[your cool processor    ]

        [your cool monitor/task switcher]

[os 1]                      [os2]            [os3]

So, what happens is the very small monitor sits BELOW all of the os that are running. It simply time slices between each of the 3 (or how many) systems you want. It gives some time to os 1, and then stop it, and then switches everything over to os2, and then over to os3 (this is really just like time slicing anyway..but you do it below the os level). So, this small monitor, or mini kernel sites below everything else.

So, this small task switcher only have to save the current machine status, and then switch to the next job (most processor have some type of time slice, and interrupt to do this quite easily). Note that you write this system BELOW the OS level, and thus very little code is needed. (the most work comes in switching, or making sure the i/o stuff does not step on each other). Once you switch, then the OS above does not even KNOW of the existence of this small program that runs below (hum, great idea for a super virus).

Of course, I use virtual PC, and it does use the processor ability to virtualized a copy.

There is a “server” edition of virtual pc, and actually designed to let you take 3, or 4 servers, and place them all on one box. It is quite different then the pc version of virtual pc..and I suspect that it runs below the os for much better performance. Virtual pc is great, but it also virtualizes the network connections, sound cards, and most importantly, the disk drives. As a result, you don’t take much of a hit on the processor with virtial pc, but the disk i/o takes a real nasty hit.  I suspect the “server edition” allows direct use of the disk drives (or, as mentioned sits below the os…not on top like virtual pc).

Albert D. Kallal
Edmonton, Alberta Canada

Albert D. Kallal
Wednesday, June 9, 2004

Nah, it is a vitriolising processor, as anyone who has ever sworn at their PC will tell you.

Wednesday, June 9, 2004

"In this presentation I will describe the main challenges of implementing a virtual machine monitor for the commodity x86 PC as well as some of the solutions to these problems as implemented in VMware's Virtual Platform. "

Just me (Sir to you)
Wednesday, June 9, 2004

"Future of Virtual Machines
The virtual-machine concept goes back to 1960s mainframes. It has since been applied to executing legacy environments and to Java. Ed Bugnion, VMWare, shows how VMs can solve common software problems through compatibility, isolation, encapsulation and mobility and how the return to VMs may affect hardware and operating system trends. Source: USENIX Annual Technical Conference"

Matthew Lock
Wednesday, June 9, 2004

Albert: The 80386 feature used in Windows 3.x was called "Virtual 86". This feature enables 32-bit Intel processors to seemlessly (more or less) run 16-bit applications. This has almost nothing to do with products like VMware or VirtualPC.

FWIW: There are a few "features" of the 32-bit Intel processors that make it *impossible* to fully virtualize. For example, ring-3 code can use the "SGDT, SLDT, and SIDT" instructions to directly query the values from these system registers. Of course, ring-3 code can neither change these registers, nor can it manipulate the in-memory tables (assuming other protection measures are properly in place).

See for the gory details.

Keith Moore
Wednesday, June 9, 2004

Presumably it will analyze code that is about to be run, to check for unsafe instructions. And further it will presumably maintain a 'run' version of each page that contains unsafe code, containing the code that is actually executed by the cpu. (Most of the time there won't be any need for a 'run' version of a page, because most code will be safe.)

Then you'll need a write trap for pages known to contain code, so that if they are changed you can scan them again, in case they changed from safe to unsafe (etc.).

All this will be why vmware isn't as fast as your real PC.

Wednesday, June 9, 2004

"All this will be why vmware isn't as fast as your real PC."

But, damn, it's nearly as fast. Have you ever seen applications run inside of VMWare? To the naked eye, many applications run just as fast as their native counterparts. Fankly, I'm impressed.

Benji Smith
Wednesday, June 9, 2004

You have to ask yourself - what is the bottleneck. I would have to guess:

1) User Input
2) Network Access
3) Disk Access
4) Memory Access
5) Processor

The processor is the only thing affected by VM. Disk Access will be the same so if your program is not processor bound it will be close to the same speed as running nativly

Thursday, June 10, 2004

Since the virtual devices in your VMWare virtual PC are pretty generic, they are not going to use any of the advanced speed features of your underlying hardware I guess?

Just me (Sir to you)
Friday, June 11, 2004

*  Recent Topics

*  Fog Creek Home