diff --git a/nel_os_bootloader/run-qemu.sh b/nel_os_bootloader/run-qemu.sh index b35bbfc..fd47f34 100755 --- a/nel_os_bootloader/run-qemu.sh +++ b/nel_os_bootloader/run-qemu.sh @@ -8,6 +8,7 @@ EFI_BINARY="$1" qemu-system-x86_64 -enable-kvm \ -m 4G \ -serial mon:stdio \ + -nographic \ -no-reboot \ -drive if=pflash,format=raw,readonly=on,file=OVMF_CODE.fd \ -drive if=pflash,format=raw,readonly=on,file=OVMF_VARS.fd \ diff --git a/nel_os_kernel/src/vmm/x86_64/intel/mod.rs b/nel_os_kernel/src/vmm/x86_64/intel/mod.rs index a208195..bac57b5 100644 --- a/nel_os_kernel/src/vmm/x86_64/intel/mod.rs +++ b/nel_os_kernel/src/vmm/x86_64/intel/mod.rs @@ -1,9 +1,26 @@ -use crate::{info, vmm::VCpu}; +use raw_cpuid::cpuid; + +use crate::{ + info, + vmm::{x86_64::common, VCpu}, +}; pub struct IntelVCpu; impl IntelVCpu { pub fn new() -> Self { + let mut msr = common::read_msr(0x3a); + if msr & (1 << 2) == 0 { + msr |= 1 << 2; + msr |= 1; + common::write_msr(0x3a, msr); + } + + let msr = common::read_msr(0x3a); + if msr & (1 << 2) == 0 { + panic!("VMX is not enabled in the BIOS"); + } + IntelVCpu } } @@ -17,6 +34,16 @@ impl VCpu for IntelVCpu { where Self: Sized, { + if cpuid!(0x1).ecx & (1 << 5) == 0 { + info!("Intel CPU does not support VMX"); + return false; + } + + let msr = common::read_msr(0x3a); + if msr & (1 << 2) == 0 && msr & 1 != 0 { + info!("VMX is not enabled in the BIOS"); + return false; + } true } }