diff --git a/src/kernel/arch/x86_64/amd_virt.rs b/src/kernel/arch/x86_64/amd_virt.rs index b74d5f4..5c35e34 100644 --- a/src/kernel/arch/x86_64/amd_virt.rs +++ b/src/kernel/arch/x86_64/amd_virt.rs @@ -22,9 +22,10 @@ pub fn amd_v_supported() -> bool { } } +#[allow(dead_code)] pub fn enable_svm() { let mut efer = x86_64::registers::model_specific::Efer::read().bits(); efer.set_bit(12, true); assert!(efer.bit(12)); unsafe { x86_64::registers::model_specific::Efer::write(EferFlags::from_bits_retain(efer)) }; -} \ No newline at end of file +} diff --git a/src/kernel/arch/x86_64/cpuid.rs b/src/kernel/arch/x86_64/cpuid.rs index 3d716a2..49bb183 100644 --- a/src/kernel/arch/x86_64/cpuid.rs +++ b/src/kernel/arch/x86_64/cpuid.rs @@ -1,6 +1,8 @@ // Copyright (c) 2025 shibedrill // SPDX-License-Identifier: MIT +#![allow(dead_code)] + use lazy_static::lazy_static; use raw_cpuid::CpuId; use raw_cpuid::CpuIdReaderNative; @@ -20,6 +22,7 @@ pub enum VirtualizationProvider { } #[derive(PartialEq, Eq)] +#[allow(clippy::upper_case_acronyms)] pub enum ProcessorVendor { AMD, Intel, @@ -52,6 +55,7 @@ impl TryFrom<&str> for ProcessorVendor { fn try_from(from: &str) -> Result { match from { "AuthenticAMD" | "AMDisbetter!" => Ok(Self::AMD), + // "GenuineIotel" is a legit string found in some mildly defective Intel CPUs "GenuineIntel" | "GenuineIotel" => Ok(Self::Intel), "VIA VIA VIA " => Ok(Self::Via), "GenuineTMx86" | "TransmetaCPU" => Ok(Self::Transmeta), @@ -73,6 +77,8 @@ impl TryFrom<&str> for ProcessorVendor { "VBoxVBoxVBox" => Ok(Self::VirtualBox), "XenVMMXenVMM" => Ok(Self::Xen), "Microsoft Hv" => Ok(Self::HyperV), + // " lrpepyh vr " is a legit string found in some implementations of the + // Parallels hypervisor due to an endianness mismatch " prl hyperv " | " lrpepyh vr " => Ok(Self::Parallels), " QNXQVMBSQG " => Ok(Self::QNX), _ => Err(()), @@ -82,13 +88,16 @@ impl TryFrom<&str> for ProcessorVendor { impl ProcessorVendor { pub fn is_hypervisor(&self) -> bool { - matches!(self, Self::QEMU - | Self::KVM - | Self::VMware - | Self::VirtualBox - | Self::HyperV - | Self::Parallels - | Self::QNX) + matches!( + self, + Self::QEMU + | Self::KVM + | Self::VMware + | Self::VirtualBox + | Self::HyperV + | Self::Parallels + | Self::QNX + ) } pub fn try_get_current() -> Result { if let Some(brand_string) = CPUID.get_vendor_info() { diff --git a/src/kernel/arch/x86_64/paging.rs b/src/kernel/arch/x86_64/paging.rs index b937168..b2cc02d 100644 --- a/src/kernel/arch/x86_64/paging.rs +++ b/src/kernel/arch/x86_64/paging.rs @@ -1,3 +1,6 @@ +// Copyright (c) 2025 shibedrill +// SPDX-License-Identifier: MIT + #![allow(dead_code)] use crate::{LOGGER, LogLevel, format, log_info}; diff --git a/src/kernel/main.rs b/src/kernel/main.rs index e5b4838..59dc08d 100644 --- a/src/kernel/main.rs +++ b/src/kernel/main.rs @@ -34,7 +34,7 @@ use lazy_static::lazy_static; use limine::firmware_type::FirmwareType; use spin::mutex::Mutex; -use crate::arch::x86_64::{amd_virt, cpuid::{virt_supported, CPUID}}; +use crate::arch::x86_64::cpuid::{CPUID, virt_supported}; lazy_static! { pub static ref SERIAL_3F8: Mutex = @@ -149,10 +149,8 @@ unsafe extern "C" fn main() -> ! { log_info!("Hypervisor: {:?}", string.identify()); } log_info!("Virtualization provider: {:?}", virt_supported()); - log_info!("AMD-V info: {}", CPUID.get_svm_info().unwrap().revision()); - amd_virt::enable_svm(); - + log_info!("Done boot!"); loop { arch::asm::nop(); }