Skip to content

Commit e0cf1f4

Browse files
slpjakecorrenti
authored andcommitted
Revert "cpuid: remove unsafe from cpuid methods"
This reverts commit fb42ebf. Signed-off-by: Sergio Lopez <slp@redhat.com>
1 parent 53920d2 commit e0cf1f4

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/cpuid/src/brand_string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ impl BrandString {
104104
/// of the host CPU.
105105
pub fn from_host_cpuid() -> Result<Self, Error> {
106106
let mut this = Self::new();
107-
let mut cpuid_regs = host_cpuid(0x8000_0000);
107+
let mut cpuid_regs = unsafe { host_cpuid(0x8000_0000) };
108108

109109
if cpuid_regs.eax < 0x8000_0004 {
110110
// Brand string not supported by the host CPU
111111
return Err(Error::NotSupported);
112112
}
113113

114114
for leaf in 0x8000_0002..=0x8000_0004 {
115-
cpuid_regs = host_cpuid(leaf);
115+
cpuid_regs = unsafe { host_cpuid(leaf) };
116116
this.set_reg_for_leaf(leaf, Reg::EAX, cpuid_regs.eax);
117117
this.set_reg_for_leaf(leaf, Reg::EBX, cpuid_regs.ebx);
118118
this.set_reg_for_leaf(leaf, Reg::ECX, cpuid_regs.ecx);

src/cpuid/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pub fn get_cpuid(function: u32, count: u32) -> Result<CpuidResult, Error> {
3535
}
3636

3737
// this is safe because the host supports the `cpuid` instruction
38-
let max_function = __get_cpuid_max(function & leaf_0x80000000::LEAF_NUM).0;
38+
let max_function = unsafe { __get_cpuid_max(function & leaf_0x80000000::LEAF_NUM).0 };
3939
if function > max_function {
4040
return Err(Error::InvalidParameters(format!(
4141
"Function not supported: 0x{function:x}"
4242
)));
4343
}
4444

4545
// this is safe because the host supports the `cpuid` instruction
46-
let entry = __cpuid_count(function, count);
46+
let entry = unsafe { __cpuid_count(function, count) };
4747
if entry.eax == 0 && entry.ebx == 0 && entry.ecx == 0 && entry.edx == 0 {
4848
return Err(Error::InvalidParameters(format!("Invalid count: {count}")));
4949
}

0 commit comments

Comments
 (0)