-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1021cef
Showing
5 changed files
with
750 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.efi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Takahiro Shinagawa (The University of Tokyo) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
CC = x86_64-w64-mingw32-gcc | ||
CFLAGS = -std=gnu11 -ffreestanding -shared -nostdlib -Wall -Werror \ | ||
-fno-stack-check -fno-stack-protector \ | ||
-mno-stack-arg-probe -mno-red-zone -mno-sse -mno-ms-bitfields \ | ||
-Wl,--subsystem,10 \ | ||
-e EfiMain \ | ||
-O6 | ||
|
||
QEMU = qemu-system-x86_64 | ||
QEMU_DISK = 'json:{ "fat-type": 0, "dir": "image", "driver": "vvfat", "floppy": false, "rw": true }' | ||
QEMU_OPTS =-nodefaults -machine accel=kvm -cpu host -m 128 -bios OVMF.fd -hda $(QEMU_DISK) -nographic -serial mon:stdio -no-reboot | ||
|
||
NESTED=$(shell cat /sys/module/kvm_intel/parameters/nested) | ||
ifeq ($(NESTED),N) | ||
ENABLE_NESTED=enable_nested | ||
else | ||
ENABLE_NESTED= | ||
endif | ||
|
||
%.efi: %.c | ||
$(CC) $(CFLAGS) $< -o $@ | ||
|
||
.PHONY: all enable_nested disable_nested qemu clean | ||
|
||
|
||
all: main.efi | ||
|
||
qemu: OVMF.fd image/EFI/BOOT/BOOTX64.EFI $(ENABLE_NESTED) | ||
$(QEMU) $(QEMU_OPTS) | ||
|
||
OVMF.fd: | ||
wget http://downloads.sourceforge.net/project/edk2/OVMF/OVMF-X64-r15214.zip | ||
unzip OVMF-X64-r15214.zip OVMF.fd | ||
rm OVMF-X64-r15214.zip | ||
|
||
image/EFI/BOOT/BOOTX64.EFI: main.efi | ||
mkdir -p image/EFI/BOOT | ||
ln -sf ../../../main.efi image/EFI/BOOT/BOOTX64.EFI | ||
|
||
enable_nested: | ||
@echo Enabling nested virtualization in KVM ... | ||
sudo modprobe -r kvm_intel; | ||
sudo modprobe kvm_intel nested=1; | ||
|
||
disable_nested: | ||
@echo Disabling nested virtualization in KVM ... | ||
sudo modprobe -r kvm_intel; | ||
sudo modprobe kvm_intel nested=0; | ||
|
||
clean: | ||
rm -f main.efi OVMF.fd | ||
rm -rf image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# The VMX benchmark (VMXbench) | ||
|
||
VMXbench is a benchmark program written as a UEFI application that measures the number of cycles involved in a VM entry/exit. It currently supports Intel VT-x processors that have the Virtual Machine Extensions (VMX) capability. | ||
|
||
## Description | ||
|
||
VMXbench measures the number of cycles in a VM exit and entry ten times after warming up, and print the min/max/avg cycles to the console. It is useful for measuring the bare-metal hardware performance of the virtualization technology in different generation processors. It also helps learn the basic usage of Intel VT-x and how to make a UEFI application. | ||
|
||
## Sample Output | ||
|
||
``` | ||
Starting VMXbench ... | ||
VMX is supported | ||
Enable VMX | ||
Enable VMX operation | ||
Enter VMX operation | ||
Initialize VMCS | ||
Launch a VM | ||
VM exit[0]: 330, VM entry[0]: 300 | ||
VM exit[1]: 330, VM entry[1]: 294 | ||
VM exit[2]: 332, VM entry[2]: 292 | ||
VM exit[3]: 330, VM entry[3]: 293 | ||
VM exit[4]: 330, VM entry[4]: 296 | ||
VM exit[5]: 330, VM entry[5]: 298 | ||
VM exit[6]: 326, VM entry[6]: 296 | ||
VM exit[7]: 330, VM entry[7]: 293 | ||
VM exit[8]: 332, VM entry[8]: 290 | ||
VM exit[9]: 332, VM entry[9]: 292 | ||
VM exit : min = 326, max = 332, avg = 330 | ||
VM entry: min = 290, max = 330, avg = 294 | ||
Press any key to go back to the UEFI menu | ||
``` | ||
|
||
## Build | ||
|
||
You first need to install the mingw cross compiler. | ||
|
||
Ubuntu: `sudo apt-get install gcc-mingw-w64` | ||
|
||
Fedora: `sudo dnf install mingw64-gcc` | ||
|
||
CentOS: `sudo yum install mingw64-gcc` | ||
|
||
If you use a distribution other than the above, find a 64bit mingw cross compiler, and set its name to "CC" in the Makefile. | ||
|
||
Then, type the following command. | ||
|
||
`make` | ||
|
||
## Test-Run | ||
|
||
Typing the following command will run VMXbench on QEMU. | ||
|
||
`make qemu` | ||
|
||
This will download a UEFI firmware (OVMF-X64-r15214.zip). If you can't download it, find the latest version from http://tianocore.sourceforge.net/wiki/OVMF or in your distribution. | ||
|
||
## Run | ||
|
||
Copy main.efi into a USB frash drive as \EFI\BOOT\BOOTX64.EFI and boot from the drive. You may need to change the boot order at the boot menu. | ||
|
||
## Licence | ||
|
||
[The MIT License](http://opensource.org/licenses/MIT) |
Oops, something went wrong.