Expand description
Hypercalls for project 2.
Hypercall is a software trap from the guest operating system to hypervisor, similar to the syscall from the application to kernel. You can simply think hypercall as a “syscall” of the hypervisor and guest OS.
In x86_64, guest OS can requests hypercall through the special instruction “vmcall”. When guest OS executes “vmcall” instruction, it first vmexits to the hypervisor. After that, hypercall reads the registers and resolve the requested hypercall according to the its own abi for hypercall. And the hypervisor serves the requests and pass the control back to the guest OS through the “vmresume” instruction.
Both the project now and the project afterwards, you will use the following abis for hypercall. %rax holds the hypercall number. %rdi, %rsi, %rdx, %r10, %r9, %r8 are the first and second arguments, and so on.
Hypercall interface
The core interface of hypercall is HypercallAbi
and Hypercall
traits.
When the vcpu executes the vmcall, it traps into the vmexit handler of the host operating system.
Then the vmexit control infrastructure of the kev forwards the given request to the Controller
for the hypercall.
When the Controller
found that the given request is a hypercall, it probes the CPU state and resolve the
information of the request through the Hypercall::resolve
. After that the Controller
passes the decoded
hypercall request to the HypercallAbi::handle
. The HypercallAbi::handle
then finally handles the given requests.
Tasks
For this part, you are required to implement two hypercalls: the first halts the current vCPU, while the second prints a string to the console.
The detailed Application Binary Interface (ABI) for each hypercall can be founded in the Hypercall
code section.
When you write to the console, you MUST proxy the console output through the PrinterProxy
.
Otherwise, grading script may be failed.