Posted: October 22, 2008
This is a short project to try and turn on virtualization (VMX) features for an Intel Core2 Duo using a bootloader. My ultimate goal was to prove I could turn virtualization on and then add 5 lines of code to the GRUB bootloader so it works every time my computer is powered up even if the BIOS doesn't know the CPU can do virtualization.
So my main desktop and development computer, an Athlon XP 1.8GHz computer I built, finally dies. So instead of doing the right thing and building my own computer again I decide to get a Dell Inspiron 530 from Best Buy. I did some (bad) research and came to the conclusion that the CPU in this box could do the virtualization. When I took it home I didn't find anything about virtualization in the BIOS nor did Linux have the cpuid VMX bit set.
Btw, some other bad things about this computer... well first of all it didn't come with even DVI. The video output was VGA, which is pretty screwie for a computer built in 2008. And sure I could put a new video board in this computer, but how much strain is that going to put on that 300 watt underpowered power supply? Secondly, when I called Dell for support to ask them about the virtualization, they refused to talk to me cause I bought the computer at Best Buy. Instead they referred me to the Geek Squad. When I called the Geek Squad to ask about a new BIOS for turning on virtualization, they said it would cost me $69 to diagnose the problem. Retards.
Moral of the story: Never trust Dell again.
How It Works
So these x86 chips have an MSR (model specific register) for turning on the VMX instructions in the CPU. By default, VMX is disabled on boot. There are two bits in MSR 0x3a. Bit 2 says to turn on the VMX instructions and bit 0 says to lock bit 2 so it can't be changed. So the BIOS basically has 3 options: 1) Turn on VMX and lock it so the OS can't turn it off 2) Leave VMX off and lock it so the OS can't use VMX at all 3) Ignore there could be VMX at all. So assuming that this BIOS in this Dell was old and didn't know about VMX, I figured it must be option 3 here.
To prove the BIOS didn't know anything about VMX, I made this bootloader to first output the bottom 3 bits of MSR 0x3a, try to change it, and then output the bottom 3 bits again to see if it worked. I originally used the PC emulator Bochs to see if the bootloader works at all and then tried it on the Dell.
So the output on Bochs was exactly what I expected. Two 0's in a row indicating the original state of VMX was turned off and not locked and final state was turned off and not locked. Since Bochs doesn't emulate VMX, this seems kosher to me. On the Dell however it would output the first 0 and then hang.
So after trying to figure out why the thing is hanging, I looked on the net again for my CPU and found out it really doesn't support VMX. So I have no idea if this bootloader would benefit anyone, but I'm posting it anyway just incase someone really did buy a computer that could do virtualization, but the manufacturer of the computer doesn't turn it on in the BIOS.
How To Use
So basically you have to make either a boot floppy or a flash boot device or whatever. All that really means is you "dd" the bootloader.bin file into the first 512 bytes on the floppy or flash device. In the Makefile included in the tarball below, you can edit it and change the /dev/sde to whatever your floppy or flash device happens to be and then type: make install_floppy. Oh yeah, if you want to assemble the source code, you need the NASM assembler. Download it, install it, and then in the bootloader directory type: make.
If this works (or doesn't work) for anyone or if anyone has any questions, feel free to email me. I'd really like to hear about how this program worked out.
Copyright 1997-2019 - Michael Kohn