intel
This commit is contained in:
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user