Skip to content

Commit

Permalink
Added KSS detection
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulstrackx committed Sep 29, 2020
1 parent 3a4b272 commit bcf726c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions sgx-isa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ bitflags! {
const MODE64BIT = 0b0000_0100;
const PROVISIONKEY = 0b0001_0000;
const EINITTOKENKEY = 0b0010_0000;
const CET = 0b0100_0000;
const KSS = 0b1000_0000;
}
}

Expand Down
15 changes: 11 additions & 4 deletions sgxs-tools/src/sgx_detect/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ impl Print for SgxCpuConfiguration {
#[derive(Clone, Update)]
struct EnclaveAttributes {
standard_attributes: bool,
kss: bool,
cpuid_12h_1: Result<Cpuid12h1, Rc<Error>>
}

Expand All @@ -170,10 +171,12 @@ impl Dependency<SgxCpuSupport> for EnclaveAttributes {
| AttributesFlags::PROVISIONKEY
| AttributesFlags::EINITTOKENKEY,
) && (c.attributes_xfrm_valid & 0x3) == 0x3,
kss: c.attributes_flags_valid.contains(AttributesFlags::KSS),
cpuid_12h_1: Ok(*c),
}),
(Some(_), c) => Some(EnclaveAttributesInner {
standard_attributes: false,
kss: false,
cpuid_12h_1: c.clone(),
}),
(None, _) => None,
Expand Down Expand Up @@ -264,6 +267,7 @@ struct SgxFeaturesCat;
#[derive(Default, DebugSupport, Update)]
struct SgxFeatures {
cpu_cfg: Option<SgxCpuConfigurationInner>,
encl_attr: Option<EnclaveAttributesInner>,
}

#[dependency]
Expand All @@ -277,8 +281,8 @@ impl Dependency<SgxCpuConfiguration> for SgxFeatures {

#[dependency]
impl Dependency<EnclaveAttributes> for SgxFeatures {
fn update_dependency(&mut self, _dependency: &EnclaveAttributes, _support: &SgxSupport) {
// TODO: KSS support from attributes
fn update_dependency(&mut self, dependency: &EnclaveAttributes, _support: &SgxSupport) {
self.encl_attr = dependency.inner.clone()
}
}

Expand All @@ -300,11 +304,14 @@ impl Print for SgxFeatures {
self.cpu_cfg.as_ref().map(|c| c.exinfo).as_opt().paint()
);
print!("{}ENCLV ", self.cpu_cfg.as_ref().map(|c| c.enclv).as_opt().paint());
println!(
print!(
"{}OVERSUB ",
self.cpu_cfg.as_ref().map(|c| c.oversub).as_opt().paint()
);
//println!("{}KSS", ...);
println!(
"{}KSS ",
self.encl_attr.as_ref().map(|a| a.kss).as_opt().paint()
);
}
}

Expand Down

0 comments on commit bcf726c

Please sign in to comment.