hypervisor: reevaluate #[allow] attributes

Remove stale #[allow]s whose lints no longer fire, convert the
unconditionally-firing ones to #[expect], and keep the conditional
ones as #[allow] (e.g. large_enum_variant only fires when both kvm
and mshv are enabled; a nonminimal_bool only on x86). The many
unreachable_patterns allows are feature-gated and left as #[allow].

Part of #8326.

Signed-off-by: Tushar Khatri <hello@tusharkhatri.in>
This commit is contained in:
Tushar Khatri
2026-06-12 16:11:41 +00:00
committed by Rob Bradford
parent d6e59a0be7
commit 859bce5cae
9 changed files with 10 additions and 12 deletions

View File

@@ -165,7 +165,7 @@ pub enum ExceptionClass {
BRK = 0b111100, BRK = 0b111100,
} }
#[allow(non_upper_case_globals)] #[expect(non_upper_case_globals)]
// PSR (Processor State Register) bits. // PSR (Processor State Register) bits.
// Taken from arch/arm64/include/uapi/asm/ptrace.h. // Taken from arch/arm64/include/uapi/asm/ptrace.h.
const PSR_MODE_EL1h: u64 = 0x0000_0005; const PSR_MODE_EL1h: u64 = 0x0000_0005;

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#![allow(non_camel_case_types)] #![expect(non_camel_case_types)]
// //
// MOV-Move // MOV-Move

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#![allow(non_camel_case_types)] #![expect(non_camel_case_types)]
// //
// MOVS - Move Data from String to String // MOVS - Move Data from String to String

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#![allow(non_camel_case_types)] #![expect(non_camel_case_types)]
// //
// OR - Logical inclusive OR // OR - Logical inclusive OR

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#![allow(non_camel_case_types)] #![expect(non_camel_case_types)]
// //
// STOS - Store String // STOS - Store String

View File

@@ -20,9 +20,7 @@ use crate::CpuVendor;
#[cfg(all(feature = "mshv_emulator", target_arch = "x86_64"))] #[cfg(all(feature = "mshv_emulator", target_arch = "x86_64"))]
pub mod emulator; pub mod emulator;
pub mod gdt; pub mod gdt;
#[allow(non_camel_case_types)] #[expect(non_upper_case_globals)]
#[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
pub mod msr_index; pub mod msr_index;
// MTRR constants // MTRR constants

View File

@@ -1512,7 +1512,7 @@ pub type KvmResult<T> = result::Result<T, KvmError>;
impl KvmHypervisor { impl KvmHypervisor {
/// Create a hypervisor based on Kvm /// Create a hypervisor based on Kvm
#[allow(clippy::new_ret_no_self)] #[expect(clippy::new_ret_no_self)]
pub fn new() -> hypervisor::Result<Arc<dyn hypervisor::Hypervisor>> { pub fn new() -> hypervisor::Result<Arc<dyn hypervisor::Hypervisor>> {
let kvm_obj = Kvm::new().map_err(|e| hypervisor::HypervisorError::VmCreate(e.into()))?; let kvm_obj = Kvm::new().map_err(|e| hypervisor::HypervisorError::VmCreate(e.into()))?;
let api_version = kvm_obj.get_api_version(); let api_version = kvm_obj.get_api_version();

View File

@@ -233,7 +233,7 @@ pub struct MshvHypervisor {
impl MshvHypervisor { impl MshvHypervisor {
/// Create a hypervisor based on Mshv /// Create a hypervisor based on Mshv
#[allow(clippy::new_ret_no_self)] #[expect(clippy::new_ret_no_self)]
pub fn new() -> hypervisor::Result<Arc<dyn hypervisor::Hypervisor>> { pub fn new() -> hypervisor::Result<Arc<dyn hypervisor::Hypervisor>> {
let mshv_obj = let mshv_obj =
Mshv::new().map_err(|e| hypervisor::HypervisorError::HypervisorCreate(e.into()))?; Mshv::new().map_err(|e| hypervisor::HypervisorError::HypervisorCreate(e.into()))?;
@@ -586,7 +586,7 @@ impl cpu::Vcpu for MshvVcpu {
Ok(()) Ok(())
} }
#[allow(non_upper_case_globals)] #[expect(non_upper_case_globals)]
fn run(&mut self) -> std::result::Result<cpu::VmExit, cpu::HypervisorCpuError> { fn run(&mut self) -> std::result::Result<cpu::VmExit, cpu::HypervisorCpuError> {
match self.fd.run() { match self.fd.run() {
Ok(x) => match x.header.message_type { Ok(x) => match x.header.message_type {

View File

@@ -23,7 +23,7 @@ pub struct MshvEmulatorContext<'a> {
impl MshvEmulatorContext<'_> { impl MshvEmulatorContext<'_> {
// Do the actual gva -> gpa translation // Do the actual gva -> gpa translation
#[allow(non_upper_case_globals)] #[expect(non_upper_case_globals)]
fn translate(&self, gva: u64, flags: u32) -> Result<u64, PlatformError> { fn translate(&self, gva: u64, flags: u32) -> Result<u64, PlatformError> {
if let Some((cached_gva, cached_gpa)) = self.mapping if let Some((cached_gva, cached_gpa)) = self.mapping
&& cached_gva == gva && cached_gva == gva