Skip to content

Commit

Permalink
Introduce TEE extension in hardware context
Browse files Browse the repository at this point in the history
The sail model doesn't have the TEE extension. This commit introduces a
feature to enable disable this extension depending on the configuration
context.
  • Loading branch information
francois141 authored and CharlyCst committed Jan 27, 2025
1 parent 9fc24f2 commit 1bd506c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions model_checking/src/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ pub fn sail_to_miralis(sail_ctx: SailVirtCtx) -> VirtContext {
has_s_extension: false,
has_v_extension: true,
has_zihpm_extension: true,
has_tee_extension: false,
},
);

Expand Down
1 change: 1 addition & 0 deletions model_checking/src/symbolic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub fn new_ctx() -> VirtContext {
has_s_extension: false,
has_v_extension: true,
has_zihpm_extension: true,
has_tee_extension: false,
},
);

Expand Down
1 change: 1 addition & 0 deletions src/arch/metal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ impl Architecture for MetalArch {
has_crypto_extension: false,
has_zicntr: false,
has_zihpm_extension: true,
has_tee_extension: true,
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ pub struct ExtensionsCapability {
pub is_sstc_enabled: bool,
/// Has Zihpm extension
pub has_zihpm_extension: bool,
/// Has Trusted Execution Environment Task Group
pub has_tee_extension: bool,
}

// ———————————————————————————— Privilege Modes ————————————————————————————— //
Expand Down
2 changes: 2 additions & 0 deletions src/arch/userspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub static HOST_CTX: Mutex<VirtContext> = Mutex::new(VirtContext::new(
has_crypto_extension: false,
has_zicntr: true,
has_zihpm_extension: true,
has_tee_extension: false,
},
));

Expand Down Expand Up @@ -88,6 +89,7 @@ impl Architecture for HostArch {
has_sstc_extension: false,
is_sstc_enabled: false,
has_zihpm_extension: false,
has_tee_extension: false,
},
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,13 @@ impl MiralisContext {
}
0x306 => Csr::Mcounteren,
0x30a => Csr::Menvcfg,
0x747 => Csr::Mseccfg,
0x747 => {
if !self.hw.extensions.has_tee_extension {
Csr::Unknown
} else {
Csr::Mseccfg
}
}
0xF15 => Csr::Mconfigptr,
0x302 => {
if !self.hw.extensions.has_s_extension {
Expand Down

0 comments on commit 1bd506c

Please sign in to comment.