diff --git a/src/cpuid/src/brand_string.rs b/src/cpuid/src/brand_string.rs index 369f46d83..825a11fd4 100644 --- a/src/cpuid/src/brand_string.rs +++ b/src/cpuid/src/brand_string.rs @@ -102,9 +102,10 @@ impl BrandString { /// Creates a brand string, initialized from the CPUID leaves 0x80000002 through 0x80000004 /// of the host CPU. + #[allow(unused_unsafe)] pub fn from_host_cpuid() -> Result { let mut this = Self::new(); - let mut cpuid_regs = host_cpuid(0x8000_0000); + let mut cpuid_regs = unsafe { host_cpuid(0x8000_0000) }; if cpuid_regs.eax < 0x8000_0004 { // Brand string not supported by the host CPU @@ -112,7 +113,7 @@ impl BrandString { } for leaf in 0x8000_0002..=0x8000_0004 { - cpuid_regs = host_cpuid(leaf); + cpuid_regs = unsafe { host_cpuid(leaf) }; this.set_reg_for_leaf(leaf, Reg::EAX, cpuid_regs.eax); this.set_reg_for_leaf(leaf, Reg::EBX, cpuid_regs.ebx); this.set_reg_for_leaf(leaf, Reg::ECX, cpuid_regs.ecx); diff --git a/src/cpuid/src/common.rs b/src/cpuid/src/common.rs index 8c2ffb1cc..d7474b89c 100644 --- a/src/cpuid/src/common.rs +++ b/src/cpuid/src/common.rs @@ -18,6 +18,7 @@ pub enum Error { } #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[allow(unused_unsafe)] pub fn get_cpuid(function: u32, count: u32) -> Result { // TODO: replace with validation based on `has_cpuid()` when it becomes stable: // https://doc.rust-lang.org/core/arch/x86/fn.has_cpuid.html @@ -35,7 +36,7 @@ pub fn get_cpuid(function: u32, count: u32) -> Result { } // this is safe because the host supports the `cpuid` instruction - let max_function = __get_cpuid_max(function & leaf_0x80000000::LEAF_NUM).0; + let max_function = unsafe { __get_cpuid_max(function & leaf_0x80000000::LEAF_NUM).0 }; if function > max_function { return Err(Error::InvalidParameters(format!( "Function not supported: 0x{function:x}" @@ -43,7 +44,7 @@ pub fn get_cpuid(function: u32, count: u32) -> Result { } // this is safe because the host supports the `cpuid` instruction - let entry = __cpuid_count(function, count); + let entry = unsafe { __cpuid_count(function, count) }; if entry.eax == 0 && entry.ebx == 0 && entry.ecx == 0 && entry.edx == 0 { return Err(Error::InvalidParameters(format!("Invalid count: {count}"))); }