-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wojciech Ozga <woz@zurich.ibm.com>
- Loading branch information
1 parent
8cb5e3e
commit 92b01b5
Showing
16 changed files
with
85 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
security-monitor/src/confidential_flow/handlers/sbi/debug_request.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
// SPDX-FileCopyrightText: 2023 IBM Corporation | ||
// SPDX-FileContributor: Wojciech Ozga <woz@zurich.ibm.com>, IBM Research - Zurich | ||
// SPDX-License-Identifier: Apache-2.0 | ||
use crate::confidential_flow::handlers::sbi::{SbiRequest, SbiResponse}; | ||
use crate::confidential_flow::handlers::sbi::SbiRequest; | ||
use crate::confidential_flow::{ApplyToConfidentialHart, ConfidentialFlow}; | ||
use crate::core::architecture::riscv::specification::CAUSE_VIRTUAL_SUPERVISOR_ECALL; | ||
use crate::core::architecture::sbi::CovgExtension; | ||
use crate::core::architecture::GeneralPurposeRegister; | ||
use crate::core::control_data::{ConfidentialHart, HypervisorHart, ResumableOperation}; | ||
use crate::core::control_data::{ConfidentialHart, ResumableOperation}; | ||
use crate::non_confidential_flow::DeclassifyToHypervisor; | ||
|
||
pub struct DebugRequest { | ||
a0: usize, | ||
a1: usize, | ||
a2: usize, | ||
a3: usize, | ||
} | ||
|
||
impl DebugRequest { | ||
pub fn from_confidential_hart(confidential_hart: &ConfidentialHart) -> Self { | ||
let a0 = confidential_hart.gprs().read(GeneralPurposeRegister::a0); | ||
let a1 = confidential_hart.gprs().read(GeneralPurposeRegister::a1); | ||
let a2 = confidential_hart.gprs().read(GeneralPurposeRegister::a2); | ||
let a3 = confidential_hart.gprs().read(GeneralPurposeRegister::a3); | ||
Self { a0, a1, a2, a3 } | ||
Self { | ||
a0: confidential_hart.gprs().read(GeneralPurposeRegister::a0), | ||
a1: confidential_hart.gprs().read(GeneralPurposeRegister::a1), | ||
} | ||
} | ||
|
||
pub fn handle(self, confidential_flow: ConfidentialFlow) -> ! { | ||
let r = SbiRequest::new(CovgExtension::EXTID, CovgExtension::SBI_EXT_COVG_DEBUG, self.a0, self.a1); | ||
|
||
confidential_flow | ||
.set_resumable_operation(ResumableOperation::SbiRequest()) | ||
.into_non_confidential_flow() | ||
.declassify_and_exit_to_hypervisor(DeclassifyToHypervisor::SbiRequest(r)); | ||
.declassify_and_exit_to_hypervisor(DeclassifyToHypervisor::SbiRequest(SbiRequest::new( | ||
CovgExtension::EXTID, | ||
CovgExtension::SBI_EXT_COVG_DEBUG, | ||
self.a0, | ||
self.a1, | ||
))); | ||
} | ||
} |
29 changes: 4 additions & 25 deletions
29
security-monitor/src/confidential_flow/handlers/time/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2023 IBM Corporation | ||
// SPDX-FileContributor: Wojciech Ozga <woz@zurich.ibm.com>, IBM Research - Zurich | ||
// SPDX-License-Identifier: Apache-2.0 | ||
use crate::confidential_flow::handlers::sbi::SbiResponse; | ||
use crate::confidential_flow::{ApplyToConfidentialHart, ConfidentialFlow}; | ||
use crate::core::architecture::riscv::specification::WFI_INSTRUCTION; | ||
use crate::core::architecture::GeneralPurposeRegister; | ||
use crate::core::control_data::ConfidentialHart; | ||
use crate::core::timer_controller::TimerController; | ||
use crate::non_confidential_flow::DeclassifyToHypervisor; | ||
pub use read_time::ReadTime; | ||
pub use set_timer::SetTimer; | ||
|
||
/// Handles virtual instruction trap that occured during execution of the confidential hart. | ||
pub struct SetTimer { | ||
ncycle: usize, | ||
} | ||
|
||
impl SetTimer { | ||
pub fn from_confidential_hart(confidential_hart: &ConfidentialHart) -> Self { | ||
Self { ncycle: confidential_hart.gprs().read(GeneralPurposeRegister::a0) } | ||
} | ||
|
||
pub fn handle(self, mut confidential_flow: ConfidentialFlow) -> ! { | ||
TimerController::new(&mut confidential_flow).set_next_event_for_vs_mode(self.ncycle); | ||
confidential_flow.apply_and_exit_to_confidential_hart(ApplyToConfidentialHart::SbiResponse(SbiResponse::success())) | ||
} | ||
} | ||
mod read_time; | ||
mod set_timer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
security-monitor/src/confidential_flow/handlers/time/set_timer.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2023 IBM Corporation | ||
// SPDX-FileContributor: Wojciech Ozga <woz@zurich.ibm.com>, IBM Research - Zurich | ||
// SPDX-License-Identifier: Apache-2.0 | ||
use crate::confidential_flow::handlers::sbi::SbiResponse; | ||
use crate::confidential_flow::{ApplyToConfidentialHart, ConfidentialFlow}; | ||
use crate::core::architecture::GeneralPurposeRegister; | ||
use crate::core::control_data::ConfidentialHart; | ||
use crate::core::timer_controller::TimerController; | ||
|
||
/// Handles virtual instruction trap that occured during execution of the confidential hart. | ||
pub struct SetTimer { | ||
ncycle: usize, | ||
} | ||
|
||
impl SetTimer { | ||
pub fn from_confidential_hart(confidential_hart: &ConfidentialHart) -> Self { | ||
Self { ncycle: confidential_hart.gprs().read(GeneralPurposeRegister::a0) } | ||
} | ||
|
||
pub fn handle(self, mut confidential_flow: ConfidentialFlow) -> ! { | ||
TimerController::new(&mut confidential_flow).set_next_event_for_vs_mode(self.ncycle); | ||
confidential_flow.apply_and_exit_to_confidential_hart(ApplyToConfidentialHart::SbiResponse(SbiResponse::success())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.