Linting fixes
All checks were successful
Continuous Integration / Check (push) Successful in 1m13s
Continuous Integration / Clippy (push) Successful in 1m10s

This commit is contained in:
August 2025-10-31 15:44:49 -04:00
parent 2fb3ea7aaa
commit c2f9343bbf
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
4 changed files with 23 additions and 12 deletions

View File

@ -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)) };
}
}

View File

@ -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<Self, Self::Error> {
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<Self, ()> {
if let Some(brand_string) = CPUID.get_vendor_info() {

View File

@ -1,3 +1,6 @@
// Copyright (c) 2025 shibedrill
// SPDX-License-Identifier: MIT
#![allow(dead_code)]
use crate::{LOGGER, LogLevel, format, log_info};

View File

@ -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<SerialPort> =
@ -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();
}