mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 10:06:31 +00:00
DragonOS虚拟化 (#389)
* try some ioctl flow & kvm device * add sys ioctl * 删掉一些debug信息 * 修改run-qemu.sh脚本,在QEMU中enable vmx * 修改cr0,cr4,msr寄存器enable VMX operations * enable vmx operation * allocate memory for vmcs with bug * allocate memory for vmcs * cpu virt-50% * single vcpu virt * add vmcs fields * CPU virt overall flow with bug * run vmlaunch success * run CPU virt with bug * 成功运行non-root模式的guest * 成功运行vmexit,进入vmx_return函数 * 成功运行vmlaunch, vmexit, vmresume * vmexit handler with bug * 完成vmexit cpuid handler * fix vmresume guest状态恢复的bug * 增加vm ioctl * refactor kvm 50% * refactor kvm 80% * FIXME: kvm vmlaunch failed * vmlaunch success * FIXME: output error * update guest_rsp * cpu virt refactor * add mmu related struct * add usermemory region workflow * add mem-virt workflow * add mem-virt * refactor code * add vcpu ioctl set_regs * rename hypervisor to vm & solve some deadlock bugs * workout mem pipeline * fix vmcs control setting bugs * refactor segment regs initialization * resovle conficts * resovle conficts * format code
This commit is contained in:
@ -34,6 +34,9 @@ use core::mem::{self};
|
||||
|
||||
use core::sync::atomic::{compiler_fence, AtomicBool, Ordering};
|
||||
|
||||
use super::kvm::vmx::vmcs::VmcsFields;
|
||||
use super::kvm::vmx::vmx_asm_wrapper::vmx_vmread;
|
||||
|
||||
pub type PageMapper =
|
||||
crate::mm::page::PageMapper<crate::arch::x86_64::mm::X86_64MMArch, LockedFrameAllocator>;
|
||||
|
||||
@ -169,12 +172,21 @@ impl MemoryManagementArch for X86_64MMArch {
|
||||
}
|
||||
|
||||
/// @brief 获取顶级页表的物理地址
|
||||
unsafe fn table(_table_kind: PageTableKind) -> PhysAddr {
|
||||
let paddr: usize;
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
asm!("mov {}, cr3", out(reg) paddr, options(nomem, nostack, preserves_flags));
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
return PhysAddr::new(paddr);
|
||||
unsafe fn table(table_kind: PageTableKind) -> PhysAddr {
|
||||
match table_kind {
|
||||
PageTableKind::Kernel | PageTableKind::User => {
|
||||
let paddr: usize;
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
asm!("mov {}, cr3", out(reg) paddr, options(nomem, nostack, preserves_flags));
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
return PhysAddr::new(paddr);
|
||||
}
|
||||
PageTableKind::EPT => {
|
||||
let eptp =
|
||||
vmx_vmread(VmcsFields::CTRL_EPTP_PTR as u32).expect("Failed to read eptp");
|
||||
return PhysAddr::new(eptp as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief 设置顶级页表的物理地址到处理器中
|
||||
|
Reference in New Issue
Block a user