mirror of
https://github.com/mii443/nel_os.git
synced 2025-08-22 16:15:38 +00:00
WIP
This commit is contained in:
@ -27,7 +27,9 @@ run-args = [
|
||||
"none",
|
||||
"-cpu",
|
||||
"host",
|
||||
"-enable-kvm"
|
||||
"-enable-kvm",
|
||||
"-monitor",
|
||||
"telnet:127.0.0.1:5555,server,nowait"
|
||||
]
|
||||
test-args = [
|
||||
"-device",
|
||||
|
@ -59,12 +59,13 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
let mut vcpu = VCpu::new(phys_mem_offset.as_u64(), &mut frame_allocator);
|
||||
vcpu.activate();
|
||||
|
||||
info!("vmlaunch...");
|
||||
info!("Starting the Virtual Machine...");
|
||||
|
||||
unsafe {
|
||||
asm!("cli");
|
||||
let vmlaunch = vmx::vmlaunch();
|
||||
|
||||
info!("VMLaunch: {:?}", vmlaunch);
|
||||
|
||||
if vmlaunch.is_err() {
|
||||
let error = InstructionError::read();
|
||||
let error = error.as_str();
|
||||
|
@ -81,7 +81,7 @@ impl VCpu {
|
||||
|
||||
primary_exec_ctrl.0 |= (reserved_bits & 0xFFFFFFFF) as u32;
|
||||
primary_exec_ctrl.0 &= (reserved_bits >> 32) as u32;
|
||||
primary_exec_ctrl.set_hlt(false);
|
||||
primary_exec_ctrl.set_hlt(true);
|
||||
primary_exec_ctrl.set_activate_secondary_controls(false);
|
||||
|
||||
primary_exec_ctrl.write();
|
||||
@ -284,6 +284,7 @@ impl VCpu {
|
||||
};
|
||||
vmwrite(vmcs::guest::LDTR_ACCESS_RIGHTS, ldtr_rights.0 as u64)?;
|
||||
|
||||
info!("RIP: {:#x}", Self::guest as u64);
|
||||
vmwrite(vmcs::guest::RIP, Self::guest as u64)?;
|
||||
vmwrite(vmcs::guest::IA32_EFER_FULL, rdmsr(IA32_EFER))?;
|
||||
vmwrite(vmcs::guest::RFLAGS, 0x2)?;
|
||||
@ -298,9 +299,18 @@ impl VCpu {
|
||||
self.vmcs.reset()
|
||||
}
|
||||
|
||||
fn guest_fn() -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
halt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[naked]
|
||||
unsafe extern "C" fn guest() -> ! {
|
||||
naked_asm!("hlt");
|
||||
//naked_asm!("call {guest_fn}", guest_fn = sym Self::guest_fn);
|
||||
}
|
||||
|
||||
fn vmexit_handler(&mut self) -> ! {
|
||||
|
Reference in New Issue
Block a user