Verification of Bhyve's instruction emulation
Student: Mahesh Tudu (mahesh86701997@gmail.com)
Mentor: John Baldwin (jhb@freebsd.org)
Project title
Test harness for instruction emulation code using Intel XED(x86 encoder decoder) tool.
Project description & Approach to solving the problem
Bhyve is a type 2 hypervisor which supports guest virtual machines by coordinating calls for CPU, memory, disk, network and other resources through the physical host's operating system. It runs guest operating system inside a virtual machine (parameters like number of virtual CPUs, amount of guest memory and input output connectivity can be specified with command line parameter). Bhyve needs to perform instruction emulation which are not tested yet, some examples being :
- emulate CLFLUSH and CLFLUSHOPT,
- emulate CMP r/m, reg
- MovS instruction memory to MMIO emulation
- Suppport PCI extended config space
- GLA2GPA ioctl
- AND r/m 16/32, imm8
- Mov r/m 16/32, r16/32
- Mov moffset, AX/EAX/RAX
- MovSX r16, r/m8 (mov with sign extension)
- MovZX r16, r/m8 (mov with zero extension)
- MovSB m8, m8 (mov data from string to string)
- SUB r32, r/m32
- STOS m16, m16
- PUSH r/m 16/32
- POP r/m 16/32
and many more instructions. Since XED (x86 Encoder Decoder) provides a list of encoding/decoding options like :
- ./xed
- -d hex string (decode one instruction, must be last)
- -de hex string (decode then encode, must be last)
where hex-string is a string of hex-code for that instruction which we want to decode. After decoding it needs to produce a data structure describing the opcode, operands and flags by passing such arguements in XED. The main purpose of this project is to provide tests for bhyve instructions. The tests are tiny guest operating system that generally execute few lines of code in C language and assembler (x86, IA-32 instructions set and intel 64 instructions set) test code in order to obtain its SUCCESS/FAILURE result. All the tests written for this project needs to be automated, so that anyone can verify it within a short span of time and I will try to maintain the accuracy and efficiency of the algorithm required for testing. I will make sure that at the end of this project my solution would be an optimal one. As we all know that FreeBSD supports multiple operating systems and contains a significant collection of server related software in the base system and the ports collection, and Bhyve which is a very new virtualisation system allows a user to run a number of guest operaring systems (FreeBSD, OpenBSD, Linux, Microsoft Windows) simultaneously.
Deliverables/Test Plan
Automate the testing process My test harness enables automation of tests and ensures execution of tests, by using a test library and generates a report. I will also design a test script to handle different test scenarios and test data. The typical objectives of my test harness would be :
- Execute test suites of test cases
- Generate associated test reports
- Support for debugging
- To record the test results for each one of the tests
- Help the developers to measure code coverage at a code level
- Increase the productivity of the system through automation
- Enhance the quality of software components and application
- To handle the complex condition that testers are finding difficult to simulate
- Repeatability of subsequent test runs.
- Increased probability that regression testing will occur
Milestones
- May 27th : Start of coding
- Basic framework of test harness.
- June 3rd : Week 2
- Modifying the framework of test harness
- Test harness for some instructions and provide simplicity.
- June 24th - June 28th: Evaluation #1
- Basic framework of Test harness which includes test for some instructions and verified them through XED tool.
- June 26th : Continue coding
- Write tests for more no. of Instructions
- Simultaneously modifying Test Harness to support most architectures and get it verified by XED tool.
- July 22nd - July 26th : Evaluation #2
- Trying to provide automated set of some tests
- July 27th : Continue coding for rest of the instruction set.
- Test for all Bhyve instruction emulations.
- Scripts for automation of all the tests
- All algorithms optimized
- August 19th : End of coding (soft)
- Debug and finish code and complete documentation
- August 26th : End of coding (hard)
Test Plan
- All the instructions emulated by bhyve during execution will be verified and checked for correctness by Intel XED (x86 encoder-decoder) tool.
The Code
TBD