Skip to content

Commit bf4f59e

Browse files
committed
fix
1 parent c4c58bf commit bf4f59e

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kernel/src/platform/native.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ use core::arch::asm;
3838
use core::mem;
3939
use core::mem::MaybeUninit;
4040
use cpufeature::backend::CpuidBackend;
41-
use cpufeature::leaves::leaf_07::CET_SS;
41+
use cpufeature::leaves::CpuidFeature;
42+
use cpufeature::leaves::CET_SS;
4243
use syscall::GlobalFeatureFlags;
4344

4445
#[cfg(debug_assertions)]
@@ -61,7 +62,17 @@ impl NativePlatform {
6162
}
6263
}
6364

64-
impl CpuidBackend for NativePlatform {}
65+
impl CpuidBackend for NativePlatform {
66+
fn cpuid(feature: &CpuidFeature) -> Option<cpufeature::backend::CpuidResult> {
67+
let regs = CpuidResult::get(feature.leaf, feature.subleaf);
68+
Some(cpufeature::backend::CpuidResult {
69+
eax: regs.eax,
70+
ebx: regs.ebx,
71+
ecx: regs.ecx,
72+
edx: regs.edx,
73+
})
74+
}
75+
}
6576

6677
impl SvsmPlatform for NativePlatform {
6778
#[cfg(test)]
@@ -113,7 +124,7 @@ impl SvsmPlatform for NativePlatform {
113124
}
114125

115126
fn determine_cet_support(&self) -> bool {
116-
Self::cpuid_value(&CET_SS) != 0
127+
Self::cpuid_value(&CET_SS).is_some_and(|v| v != 0)
117128
}
118129

119130
fn capabilities(&self) -> Caps {

kernel/src/platform/snp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use core::ptr;
5959
use core::sync::atomic::{AtomicU32, Ordering};
6060
use cpufeature::backend::CpuidBackend;
6161
use cpufeature::leaves::CpuidFeature;
62-
use cpufeature::leaves::leaf_07::CET_SS;
62+
use cpufeature::leaves::CET_SS;
6363

6464
static GHCB_IO_DRIVER: GHCBIOPort = GHCBIOPort::new();
6565

@@ -287,7 +287,7 @@ impl SvsmPlatform for SnpPlatform {
287287
}
288288

289289
fn determine_cet_support(&self) -> bool {
290-
Self::cpuid_value(&CET_SS) != 0
290+
Self::cpuid_value(&CET_SS).is_some_and(|v| v != 0)
291291
}
292292

293293
fn capabilities(&self) -> Caps {

0 commit comments

Comments
 (0)