Barevisor as a UEFI driver for Intel and AMD processors.
Barevisor can be compiled into both the UEFI driver and Windows kernel driver. Those interested in virtualizing UEFI, boot loaders, and early OS initialization phases should study UEFI driver-based hypervisors. It is also suitable for having a better picture of how Intel VT-x and AMD SVM work, as well as OS-agnostic designs.
-
Navigate to the
barevisor\src\uefi
directory.> cd C:\Users\tanda\Desktop\RnD\GitHub\barevisor\src\uefi
-
Build Barevisor with the
xtask
command.> cargo xtask build
If successful,
target\x86_64-unknown-uefi\debug\uefi_hv.efi
should exist.Along with that,
check_hv_vendor.efi
is built. This is useful for confirming that Barevisor is loaded into the system (more in the below section).
Barevisor can be partially tested with Bochs, a cross-platform open-source x86_64 PC emulator. Bochs is extremely helpful in the early phase of hypervisor development as it can be used to debug the types of errors that are difficult to diagnose on VMware. Failure of the VMX instructions is the primal example.
Set up a Bochs VM with the following instructions:
-
On Ubuntu and Windows (WSL)
$ sudo apt install build-essential p7zip-full mtools genisoimage $ git clone -b barevisor /~https://github.com/tandasat/Bochs.git $ cd Bochs/bochs $ sh .conf.linux $ make $ sudo make install
-
On macOS
$ brew install p7zip $ brew install mtools $ brew install cdrtools $ git clone -b barevisor /~https://github.com/tandasat/Bochs.git $ cd Bochs/bochs $ sh .conf.macosx $ make $ sudo make install
In the uefi
directory, run either cargo xtask bochs-amd
or cargo xtask bochs-intel
to test on AMD and Intel processors respectively.
You may test code on the UEFI shell but not booting an OS. The author was unable to install an OS on Bochs when UEFI is used instead of traditional BIOS. Please let me know if you made it work.
You can use VMware Workstation Pro or Fusion Pro to test the hypervisor with a VM comes with this repo.
-
Install the necessary dependencies:
-
On Ubuntu and Windows (WSL)
$ sudo apt install build-essential p7zip-full mtools genisoimage
-
On macOS
$ brew install p7zip $ brew install mtools $ brew install cdrtools
-
-
In the
uefi
directory, runcargo xtask vmware
. It will automatically boot a VM, enter the UEFI shell and loaduefi_hv.efi
as below:startup.nsh> echo -off Loading uefi_hv.efi Image base: 0xe5ce000..0xe627000 Loaded uefi_hv.efi load: Image fs1:\uefi_hv.efi loaded at E5CE000 - Success Executing CPUID(0x40000000) on all logical processors CPU 0: Barevisor! fs1:\>
✅ If successful, serial output should appear. Additionally, you may confirm that Barevisor is active by executing
check_hv_vendor.efi
.fs1:\> check_hv_vendor.efi Executing CPUID(0x40000000) on all logical processors CPU 0: Barevisor!
You will want to boot an OS after installing Barevisor. Install your choice of a Windows version in the provided VM image for further testing.