Skip to content

Commit

Permalink
rec: move contexts belonging to a Rec to rec
Browse files Browse the repository at this point in the history
Sinc the current implementations of Timer, Gic, and Simd
serve as parts of Rec's context, move them under rec.

Signed-off-by: Bokdeuk Jeong <[email protected]>
  • Loading branch information
bokdeuk-jeong committed Dec 18, 2024
1 parent d57e6d5 commit ec8b28d
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion rmm/src/exception/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::lower::synchronous;
use crate::cpu;
use crate::event::realmexit::{ExitSyncType, RecExitReason};
use crate::rec::Rec;
use crate::simd;
use crate::rec::simd;

use aarch64_cpu::registers::*;
use armv9a::regs::CPTR_EL2;
Expand Down
2 changes: 0 additions & 2 deletions rmm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub mod config;
pub mod cpu;
pub(crate) mod event;
pub mod exception;
pub mod gic;
#[macro_use]
pub mod granule;
#[macro_use]
Expand All @@ -27,7 +26,6 @@ pub mod realm;
pub mod rec;
pub mod rmi;
pub mod rsi;
pub mod simd;
#[cfg(feature = "stat")]
pub mod stat;
#[cfg(any(test, miri))]
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/monitor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::event::{Context, Mainloop, RmiHandle, RsiHandle};
use crate::mm::translation::PageTable;
use crate::realm::context::set_reg;
use crate::rec::context::set_reg;
use crate::rec::Rec;
use crate::rmi;
use crate::rmi::rec::run::Run;
Expand Down
2 changes: 0 additions & 2 deletions rmm/src/realm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pub mod config;
pub mod context;
pub mod mm;
pub mod rd;
pub mod registry;
pub mod timer;
2 changes: 1 addition & 1 deletion rmm/src/realm/rd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use vmsa::guard::Content;

use crate::measurement::{Measurement, MEASUREMENTS_SLOT_NR};
use crate::realm::mm::IPATranslation;
use crate::simd::SimdConfig;
use crate::rec::simd::SimdConfig;
use alloc::boxed::Box;
use alloc::collections::btree_map::BTreeMap;
use alloc::sync::Arc;
Expand Down
8 changes: 4 additions & 4 deletions rmm/src/realm/context.rs → rmm/src/rec/context.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::Rec;
use super::gic;
use super::timer;
use crate::gic;
use crate::rec::Rec;
use super::simd;
use super::simd::SimdRegister;
use crate::rmi::error::Error;
use crate::simd;
use crate::simd::SimdRegister;

use aarch64_cpu::registers::*;

Expand Down
2 changes: 1 addition & 1 deletion rmm/src/gic.rs → rmm/src/rec/gic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::rec::Rec;
use super::Rec;
use crate::rmi::error::Error;
use crate::rmi::rec::run::Run;

Expand Down
11 changes: 6 additions & 5 deletions rmm/src/rec.rs → rmm/src/rec/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::gic;
use crate::realm::context::Context;
pub mod context;
pub mod gic;
pub mod simd;
pub mod timer;

use crate::realm::rd::Rd;
use crate::realm::timer;
use crate::rec::context::Context;
use crate::rmi::error::Error;
use crate::rmi::rec::params::NR_AUX;
use crate::rmm_exit;
use crate::rsi::attestation::MAX_CHALLENGE_SIZE;
use crate::simd;

use aarch64_cpu::registers::*;

use core::cell::OnceCell;
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/simd.rs → rmm/src/rec/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use core::array::from_fn;
use lazy_static::lazy_static;
use spin::mutex::Mutex;

use super::Rec;
use crate::config::NUM_OF_CPU;
use crate::cpu::get_cpu_id;
use crate::realm::rd::Rd;
use crate::rec::Rec;
use crate::rmi::error::Error;

// Vector length (VL) = size of a Z-register in bytes
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/realm/timer.rs → rmm/src/rec/timer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::rec::Rec;
use super::Rec;
use crate::rmi::error::Error;
use crate::rmi::rec::run::Run;

Expand Down
2 changes: 1 addition & 1 deletion rmm/src/rmi/realm/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::const_assert_eq;
use crate::granule::{GRANULE_SHIFT, GRANULE_SIZE};
use crate::measurement::Hashable;
use crate::realm::mm::rtt::{RTT_PAGE_LEVEL, RTT_STRIDE};
use crate::rec::simd;
use crate::rmi::error::Error;
use crate::rmi::features;
use crate::rmi::{HASH_ALGO_SHA256, HASH_ALGO_SHA512};
use crate::simd;

use armv9a::{define_bitfield, define_bits, define_mask};
use autopadding::*;
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/rmi/rec/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::get_granule;
use crate::get_granule_if;
use crate::granule::GranuleState;
use crate::granule::GRANULE_MASK;
use crate::realm::context::get_reg;
use crate::realm::mm::rtt::RTT_PAGE_LEVEL;
use crate::realm::mm::stage2_tte::S2TTE;
use crate::realm::rd::Rd;
use crate::rec::context::get_reg;
use crate::rec::{
Rec, RmmRecEmulatableAbort::EmulatableAbort, RmmRecEmulatableAbort::NotEmulatableAbort,
};
Expand Down
10 changes: 5 additions & 5 deletions rmm/src/rmi/rec/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::granule::{set_granule, GranuleState};
use crate::host;
use crate::listen;
use crate::measurement::HashContext;
use crate::realm::context::{set_reg, RegOffset};
use crate::realm::rd::{Rd, State};
use crate::rec::context::{set_reg, RegOffset};
use crate::rec::State as RecState;
use crate::rec::{Rec, RmmRecEmulatableAbort::NotEmulatableAbort};
use crate::rmi;
Expand Down Expand Up @@ -212,7 +212,7 @@ pub fn set_event_handler(rmi: &mut RmiHandle) {
}

#[cfg(not(any(miri, test)))]
if !crate::gic::validate_state(&run) {
if !crate::rec::gic::validate_state(&run) {
return Err(Error::RmiErrorRec);
}

Expand All @@ -222,7 +222,7 @@ pub fn set_event_handler(rmi: &mut RmiHandle) {
}

#[cfg(not(any(miri, test)))]
crate::gic::receive_state_from_host(&mut rec, &run)?;
crate::rec::gic::receive_state_from_host(&mut rec, &run)?;
crate::mmio::emulate_mmio(&mut rec, &run)?;

crate::rsi::ripas::complete_ripas(&mut rec, &run)?;
Expand Down Expand Up @@ -279,8 +279,8 @@ pub fn set_event_handler(rmi: &mut RmiHandle) {
}

#[cfg(not(any(miri, test)))]
crate::gic::send_state_to_host(&rec, &mut run)?;
crate::realm::timer::send_state_to_host(&rec, &mut run)?;
crate::rec::gic::send_state_to_host(&rec, &mut run)?;
crate::rec::timer::send_state_to_host(&rec, &mut run)?;

// NOTICE: do not modify `run` after copy_to_ptr(). it won't have any effect.
rmm.page_table.map(run_pa, false);
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/rsi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use crate::granule::{GranuleState, GRANULE_SIZE};
use crate::listen;
use crate::measurement::{HashContext, Measurement, MEASUREMENTS_SLOT_NR, MEASUREMENTS_SLOT_RIM};
use crate::realm::config::realm_config;
use crate::realm::context::{get_reg, set_reg};
use crate::realm::mm::address::GuestPhysAddr;
use crate::realm::mm::rtt::RTT_PAGE_LEVEL;
use crate::realm::rd::Rd;
use crate::rec::context::{get_reg, set_reg};
use crate::rec::{Rec, RmmRecAttestState};
use crate::rmi;
use crate::rmi::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/rsi/psci.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::event::RsiHandle;
use crate::granule::GranuleState;
use crate::listen;
use crate::realm::context::{get_reg, set_reg, RegOffset};
use crate::realm::rd::{Rd, State};
use crate::rec::context::{get_reg, set_reg, RegOffset};
use crate::rec::Rec;
use crate::rmi;
use crate::rmi::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/rsi/ripas.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::granule::is_granule_aligned;
use crate::granule::GranuleState;
use crate::realm::context::{get_reg, set_reg};
use crate::realm::mm::rtt::RTT_PAGE_LEVEL;
use crate::realm::mm::stage2_tte::invalid_ripas;
use crate::realm::rd::Rd;
use crate::rec::context::{get_reg, set_reg};
use crate::rec::Rec;
use crate::rmi;
use crate::rmi::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion rmm/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ pub mod mock {
pub mod realm {
use super::super::*;
use crate::event::realmexit::RecExitReason;
use crate::realm::context::set_reg;
use crate::rec::context::set_reg;
use crate::rec::Rec;
use crate::rmi::rec::run::Run;
use crate::rsi::PSCI_CPU_ON;
Expand Down

0 comments on commit ec8b28d

Please sign in to comment.