This RFC is a discussion of Bareflank-LibVMI hypercall ABI
A request is made to hypervisor with a hypercall ID which will be stored in rax
register and the bareflank dispatches the task to the appropriate vmcall_handler based on hypercall ID.
Some hypercalls, take some data as input while other return data output. To facilitate the this, libvmi_extensions
create common shared memory region between hypervisor and LibVMI with read-write-execute permissions. When libvmi_extensions are loaded, the details of the shared memory(starting memory address with size) will be printed to output so the hypercall with data as input can use this region. This shared memory with a fixed size will be created with Bareflank memory_manager.h
.
The JSON format will be used for input-output data. We can use any json parser create
the data on one side and retrive the data on the otherside.
When data is given as input to Hypervisor:
the input data is first formated in the JSON format and then copied into the shared region.
and get the size of the total data.
The ABI for the hypercal looks like
mov rax 0x5 ; hypercall ID
mov rbx 0x2347789688 ;starting region of memory
mov rcx 0x16 ;size of the input data
vmcall
When data is given as output by the hypervisor:
the output data is first formated in the JSON format and then copied into the shared region and get the size of the total data.
The ABI for the hypercall looks like
mov rax 0x6 ; hypercall ID
vmcall ; Give hypercall
; collect the size of the data returned in rcx register.
This region can be used by memory mapping hypercall to map a process's memory into this region so that LibVMI can read from the region.
Now the next immediate task is to create a shared memory region. I am thinking to create
a simple version of Xen's Grant table. So that this region can be shared with multiple VMs.
@rianquinn @connojd @tklengyel please comment your thoughts