ization (often called para-virtualization) (Microsoft,
2022c,a).
In the following, we discuss the Hyper-V hyper-
call interface for enlightened partitions. Part of the
information is stated in the Hyper-V Top-Level Func-
tional Specification (TLFS) (Microsoft, 2022c), the
rest is reverse-engineered from the Hyper-V binary.
When invoking hypercalls, the caller passes a Hy-
percall Input Value (HIV) to the HV and receives a
Hypercall Result Value (HRV) after the hypercall ex-
ecution. The exchange of these values happens via
General-Purpose Registers (GPRs). For call-specific
inputs and outputs, there is choice between a register-
and memory-based calling convention. Hypercalls
in Hyper-V fall into four groups: simple hypercall,
rep hypercall, extended hypercall, and Virtual Trust
Level (VTL) call and return (Microsoft, 2022c).
Basic Workflow. First, the caller inside the partition
specifies the hypercall input, consisting of an HIV,
which defines the hypercall to invoke and other hy-
percall properties, and optionally further call-specific
input. The caller triggers a VM exit to the HV. He ex-
ecutes a designated instruction, VMCALL on Virtual-
ization Technology for x86 (VT-x) and VMMCALL
on AMD-Virtualization (AMD-V). The HV abstracts
the different VM exit instructions by providing the
correct one to the caller on a memory page in the
Guest Physical Address (GPA) space, called the hy-
percall page. The VP running the hypercall must be in
kernel mode at the time of the VM exit since Hyper-V
only allows programs in kernel mode to invoke hyper-
calls (Microsoft, 2022c).
After the VM exit, the HV takes over the execu-
tion and starts general pre-processing. It evaluates the
reason for the VM exit in the VM Exit handler to call
the appropriate handler. In our case, the reason for
the exit was the VMCALL, so execution passes to the
VMCALL handler, who performs tests (e.g., valid-
ity of HIV, calling from kernel mode) and prepares
the call for the hypercall handler. Towards the end,
the execution splits into extended hypercall, VTL call
and return, register-based, and memory-based call-
ing. The register-based and memory-based callings
split further into simple and rep hypercall. Finally,
the VMCALL handler calls the hypercall handler via
the Hypercall Handler Table (HHT)—an HV-internal
data structure that stores constant hypercall-specific
data. It contains an entry for each hypercall with a
pointer to the handler. The handlers implement the
hypercall-specific functionality. When finished, each
handler returns a value to report its execution status.
It is either 0 if the execution was successful, or corre-
sponds to a defined error code (Microsoft, 2022c).
After the hypercall handler, the VMCALL handler
takes over again and starts post-processing. It pre-
pares the potential output of handlers for transfer to
the caller and creates the HRV, which provides the
caller with feedback about the hypercall execution in
the HV. Finally, the VM Exit handler passes control
back to the caller.
Hypercall Input Value. The HIV is a 64-bit value
parameterizing the hypercall properties. Relevant
for the logger are the 16-bit call code identifying
the call, a bit flag indicating the calling conven-
tion (register/memory), one byte specifying variable
header size, and rep count a start index for rep hy-
percalls. The RCX register transfers the value (Mi-
crosoft, 2022c).
Hypercall Result Value. The HRV is a 64-bit value
giving the status of the hypercall execution. Similar to
the return value of the hypercall handler, it indicates
the overall call execution status. A value of reps com-
pleted exists for rep hypercalls. The HV returns the
HRV in RAX (Microsoft, 2022c).
Register- vs. Memory-Based Calling Convention.
Hypercalls with input and output values besides the
HIV and HRV allow the caller to choose between a
register-based or memory-based calling convention.
The register-based concept is faster but only works for
calls with a limited input or output size. In basic form,
hypercalls with no call-specific output and two or
fewer input are supported, with inputs stored in RDX
and R8. The XMM Fast Hypercall extension allows
using the 128-bit registers XMM0 to XMM5. Thus,
the possible input size is 112 bytes. Additionally, it
allows the return of output values in the XMM regis-
ters that don’t carry input values (Microsoft, 2022c).
With the memory-based calling convention, the
transfer occurs via two memory pages; one for the
input, one for the output. The caller-provided mem-
ory pages are 4 KiB in size, sufficient for the in-
put and output of every hypercall. The caller stores
their addresses in the registers RDX and R8, respec-
tively (Microsoft, 2022c).
Simple vs. Rep Hypercalls. Simple hypercalls be-
have as described so far; they get called, perform their
task, and return. Rep hypercalls, in contrast, facilitate
multiple executions of the same operation with a sin-
gle call, comparable to a series of simple hypercalls.
The input next to the HIV consists of a list of input
list elements and possibly an input parameter header.
The input list elements are the inputs for the individ-
ual operation runs, processed in list order. The header
contains data that is the same for all list elements. The
output comprises an HRV and a list of output list el-
ements if the operation generates one. The transmis-
sion of input and output remains the same (Microsoft,
2022c).
Logging Hypercalls to Learn About the Behavior of Hyper-V
413