Replies: 2 comments 5 replies
-
A question:
Should we clone |
Beta Was this translation helpful? Give feedback.
4 replies
-
To me it's a very good design doc. 👍 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
About the overall architecture of arceos-hypervisor,
a unified modular hypervisor based on ArceOS.
Design Goal
This project originated from the discussion/13 of rCore-OS community.
In general, this project hopes to add virtualization support crates/modules based on ArceOS unikernel,
and build a modular hypervisor that supports multiple architectures based on the basic OS functions provided by ArceOS unikernel.
We hope to make the hypervisor as modular as possible and minimize modifications to the arceos kernel code.
Components
ArceOS-hypervisor is mainly composed of the following independent components:
vmm-app: a user app of ArceOS, acts like a VMM (Virtual Machine Monitor)
axvm: a module of ArceOS, responsible for resource management within each VM
axvcpu: a module of ArceOS, providing CPU virtualization support
axdevice (unimplement): a module of ArceOS, providing device emulation support
VCpu Scheduling
axvcpu is just and only reponsible virtualization function support, e.g. enter/exit guest VM through vmlaunch/vmexit.
Since ArceOS already provides axtask for runtime control flow mangement under single privilege level,
we can reuse its scheduler and evolve with it.
VCpu scheduling upon ArceOS may looks like this:
In order to support such vcpu scheduling,
For axtask, it needs to
For axvcpu, it needs to
vcpu.run()
function, so that aloop
block can handle all access from guest VM.Exception (VM-Exit)
Exception Handling
The vcpu scheduling design mentioned above requires a reasonable exception (VM-Exit) handling framework.
This is the problem:
Due to the different ways in which different architectures support virtualization,
their virtualization privilege level exception handling entries are also different.
We need to design a set of VM-Exit processing frameworks that are as unified as possible for different architectures.
x86_64
The handling of VM-Exit under x86_64 has been completed by @aarkegz, see crates/axvm/src/arch/x86_64/vmx
/vmcs.rs
For x86_64's virtual machine extensions, the host-state area of the VMCS region can flexibly determine the rip value after a VM-Exit occurs, which is set as the function address of
vmx_exit
insideVmxVcpu
structure.Therefore, we can save the context properly in the host sp during
vmlaunch/resume
, store the host sp pointer, and pop the context from the host sp in thevmx_exit
function when a VM-Exit occurs. All of these operations are performed in vmx mod, which elegantly limits the interaction with the guest VM to thevcpu.run()
function.aarch64
For aarch64 architecture,
VBAR_EL2
register holds the vector base address for any exception that is taken to EL2.So, to run arceos in EL2 to support virtualization, we need to make intrusive modifications to arceos's [axhal module] (https://github.com/arceos-org/arceos/tree/main/modules/axhal).
For VM-Entry
arch_vcpu.run()
&vcpu.vm_context_frame
&vcpu.vm_context_frame
, includingFor VM-Exit
¤t_vcpu.vm_context_frame
, includingarch_vcpu.run()
Exception Type (VM-Exit Reason)
Memory Management
This is very similar to the address space management of the arceos-monolithic.
@equation314 suggested that we can use axmm.
However, its
PageTable
of aspace cannot be changed.It uses the
PageTable
type provided by arceos axhal/paging, and the page table entry structure cannot be modified.We can take advantage of its memory_set crate and register the PageTable as our AxNestPageTable.
Still, we hope to find a way to unify address space management for both monolithic and hypervisor variants of ArceOS.
@hky1999 is working on that, dev branch : https://github.com/arceos-hypervisor/arceos-umhv/tree/vm_cfg
Emulated Device
Emulated Device support for arceos-hypervisor is supported by the implementation of Exception Handling and Memory Management (most of device are accessed by MMIO).
We plan to design an
axdevice
module for device management of each VM, it provides struct likeAxEmulatedDevices
, which will be owned and managed byAxVM
.When a VM-Exit caused by MMIO (or PIO) access occurs,
axvcpu
will record the current access information, including address, bit width, read/write, etc. Theemulated_device_handler
function of axdevice needs to find the corresponding emulated device according to the access address, call the corresponding device's processing function and pass in the access information.Providing emulated device support for guest VMs requires considerable work.
Currently we focus on emulated interrupt controller for different architectures and virtio-devices (mainly Virtio-Blk).
Beta Was this translation helpful? Give feedback.
All reactions