build(boot): gate hosted-only runtime code and check the freestanding build

This commit is contained in:
Tyler Smith committed 2026-10-16 07:13:30 +00:00
1 parent 446b399100
commit 807965e044
30 files changed
+205 -76

No files matched your search

@@ -27,6 +27,8 @@ pub(super) struct MemoryFault {
}
/// Raw same-call diagnostics. These fields are never an entry or retirement grant.
#[derive(Debug, Clone, Copy)]
// Only hosted diagnostics read these raw fields back.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(super) struct RawMemoryObservation {
pub status_code: u32,
pub address: u64,
@@ -35,6 +37,8 @@ pub(super) struct RawMemoryObservation {
}
#[derive(Debug)]
// Only hosted diagnostics read these raw fields back.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(super) enum CheckedReturn {
CpuDeclined(Failure),
EntryDeclined(MemoryStatus),
@@ -47,6 +47,7 @@ fn accept_retained_loan<B>(loan: SystemExecutionLoan<'_, B>) -> RetainedResource
pub(crate) mod checked;
pub(crate) use checked::{M0PairReadSourceInput, M0SourceInput, M0WriteSourceInput};
#[cfg(feature = "std")]
mod process;
mod software_async;
#[cfg(feature = "std")]
@@ -1,16 +1,22 @@
//! Source-validated Darwin service settlement on the actual retained thread.
//! No PC owner, dispatcher, memory alias or host callback is available here.
use crate::{
darwin::{self, BsdPrototype, BsdReturnType, PendingBsdCall, platform},
mach, thread,
};
use crate::{darwin, mach, thread};
#[cfg(not(feature = "std"))]
use alloc::{string::String, string::ToString, vec::Vec};
use anyhow::{Context, Result};
use alloc::{string::String, vec::Vec};
use serde::Serialize;
use stela_compiler::{GuestAddress, GuestState, block::SynchronousTrap};
use stela_compiler::block::SynchronousTrap;
// Settlement is reached only by the hosted Darwin process owner.
#[cfg(feature = "std")]
use crate::darwin::{BsdPrototype, BsdReturnType, PendingBsdCall, platform};
#[cfg(feature = "std")]
use anyhow::{Context, Result};
#[cfg(feature = "std")]
use stela_compiler::{GuestAddress, GuestState};
#[derive(Debug, Default)]
// Only the hosted Darwin process path reports these events.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(crate) struct TrapServiceEvents {
pub mach: Vec<mach::Event>,
pub mach_effects: Vec<MachEffects>,
@@ -32,17 +38,20 @@ pub(crate) struct ServiceRefusal {
pub(crate) enum Outcome {
/// No service effect. The original trap stays pending under this same owner.
NoEffect,
#[cfg(feature = "std")]
Complete(GuestAddress),
/// A host or ABI operation failed; canonical consumer preserves all effects.
Indeterminate(anyhow::Error),
}
#[cfg(feature = "std")]
enum Prepared {
Mach(mach::PendingCall),
ThreadIdentity(PendingBsdCall),
ProcessIdentity(PendingBsdCall),
Platform(platform::PendingCall),
}
#[cfg(feature = "std")]
impl Prepared {
fn from_registers(
trap: &SynchronousTrap,
@@ -188,6 +197,7 @@ impl Prepared {
}
}
#[cfg(feature = "std")]
fn complete_mach(
pending: mach::PendingCall,
trap: &SynchronousTrap,
@@ -234,6 +244,7 @@ fn complete_mach(
}
}
#[cfg(feature = "std")]
pub(super) fn complete(
trap: &SynchronousTrap,
registers: &mut GuestState,
@@ -15,11 +15,13 @@ impl fmt::Debug for OwnedStop {
.field("instruction_pc", instruction_pc)
.finish(),
Self::HelperRefused(value) => f.debug_tuple("HelperRefused").field(value).finish(),
#[cfg(feature = "std")]
Self::PointerAuthenticationFault { instruction, code } => f
.debug_struct("PointerAuthenticationFault")
.field("instruction", instruction)
.field("code", code)
.finish(),
#[cfg(feature = "std")]
Self::PointerAuthenticationPoisonedTransfer {
instruction,
target,
@@ -1,16 +1,18 @@
//! Actual fresh-software debug controls and distinct retained execution scopes.
//! LR execution does not manufacture an LR-absent exception-entry token.
use crate::{
pauth::features::LinkRegisterPauthCapability,
system::{
debug::DebugControls,
identification_snapshot::Snapshot,
profile::{BaseSpeAbsence, EntryProfile},
state::{PacmStateFeature, SystemState},
},
#[cfg(feature = "std")]
use crate::pauth::features::LinkRegisterPauthCapability;
use crate::system::{
debug::DebugControls,
identification_snapshot::Snapshot,
profile::{BaseSpeAbsence, EntryProfile},
state::{PacmStateFeature, SystemState},
};
#[cfg(feature = "std")]
use alloc::sync::Arc;
use anyhow::{Context, Result, ensure};
#[cfg(feature = "std")]
use anyhow::Context;
use anyhow::{Result, ensure};
const MDSCR_SOFTWARE_STEP: u64 = 1;
const MDSCR_KERNEL_DEBUG_ENABLE: u64 = 1 << 13;
const MDSCR_MONITOR_DEBUG_ENABLE: u64 = 1 << 15;
@@ -18,6 +20,7 @@ const MDSCR_ACTIVE_DEBUG: u64 =
MDSCR_SOFTWARE_STEP | MDSCR_KERNEL_DEBUG_ENABLE | MDSCR_MONITOR_DEBUG_ENABLE;
enum FeatureScope {
Base(EntryProfile),
#[cfg(feature = "std")]
LinkRegister(Arc<Snapshot>),
}
pub(crate) struct ProcessEntryControls {
@@ -49,6 +52,7 @@ impl ProcessEntryControls {
/// The Arc is the SAME immutable Snapshot allocation as the actual fixed
/// control bank of this fresh PE; no hardware/diagnostic adoption occurs.
/// Other owner/producer obligations are identical to fresh_software.
#[cfg(feature = "std")]
pub(crate) unsafe fn fresh_software_link_register_pauth(
snapshot: &Arc<Snapshot>,
spe: BaseSpeAbsence,
@@ -67,6 +71,7 @@ impl ProcessEntryControls {
owner.check()?;
Ok(owner)
}
#[cfg(feature = "std")]
pub(super) fn link_register(&self) -> bool {
matches!(self.features, FeatureScope::LinkRegister(_))
}
@@ -119,6 +124,7 @@ impl ProcessEntryControls {
"base entry scope has unqualified PACM storage"
);
}
#[cfg(feature = "std")]
FeatureScope::LinkRegister(snapshot) => {
let ids = identification.context("actual LR identification owner unavailable")?;
ensure!(
@@ -10,9 +10,12 @@ mod el1_registers;
pub(crate) mod el1_system;
mod entry_controls;
mod halted;
#[cfg(feature = "std")]
mod low128_call;
mod m0;
#[cfg(feature = "std")]
mod pauth_lr;
#[cfg(feature = "std")]
mod pauth_policy;
mod privileged;
mod privileged_debug;
@@ -31,6 +34,7 @@ use crate::{
};
pub(crate) use entry_controls::ProcessEntryControls;
pub(crate) use m0::{M0PairReadSourceInput, M0SourceInput, M0WriteSourceInput};
#[cfg(feature = "std")]
pub(crate) use provider::CheckedProcessOwner;
use source::{BoundSource, ReturnedTerminal};
use stela_compiler::{
@@ -63,10 +67,12 @@ pub(crate) enum OwnedStop {
Halted {
instruction_pc: GuestAddress,
},
#[cfg(feature = "std")]
PointerAuthenticationFault {
instruction: stela_compiler::block::PointerAuthentication,
code: u8,
},
#[cfg(feature = "std")]
PointerAuthenticationPoisonedTransfer {
instruction: stela_compiler::block::PointerAuthentication,
target: GuestAddress,
@@ -80,6 +86,8 @@ pub(crate) enum OwnedStop {
}
#[derive(Debug)]
// Hosted process reports read every retained observation.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(crate) struct OwnedRunOutcome {
pub stop: OwnedStop,
pub accounting: RunOutcome,
@@ -98,6 +106,8 @@ pub(crate) struct OwnedRunOutcome {
/// Diagnostic metadata only; cannot mint entry/retirement/source authority.
#[derive(Debug)]
// Hosted process reports read every retained observation.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(crate) struct SettledPrefix {
pub entry: GuestAddress,
pub generation: u64,
@@ -137,6 +147,8 @@ impl From<super::super::checked_memory::MemoryFault> for OwnedMemoryFault {
}
#[derive(Clone)]
// Only the hosted EL0 process owner produces entry declines and faults today.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(crate) enum NativeObservation {
Returned {
next_pc: u64,
@@ -462,6 +474,7 @@ impl BlockRuntime {
},
OwnedStop::StopAddress => StopReason::StopAddress,
OwnedStop::BudgetExhausted => StopReason::BudgetExhausted,
#[cfg(feature = "std")]
OwnedStop::PointerAuthenticationPoisonedTransfer {
instruction,
target,
@@ -668,6 +681,7 @@ impl<B: provider::Owner> Active<'_, '_, B> {
Ok(Some(OwnedStop::HelperRefused(error.to_string())))
}
HelperOutcome::Indeterminate(error) => Err(error),
#[cfg(feature = "std")]
HelperOutcome::PreparedPauth {
instruction,
effect,
@@ -703,6 +717,7 @@ impl<B: provider::Owner> Active<'_, '_, B> {
self.finish_retirement(false)?;
Ok(None)
}
#[cfg(feature = "std")]
HelperOutcome::AuthenticationFault { instruction, code } => {
// Precise no-commit fault. No exception owner or destination/link write is fabricated.
anyhow::ensure!(
@@ -731,6 +746,7 @@ impl<B: provider::Owner> Active<'_, '_, B> {
}))
}
#[cfg(feature = "std")]
HelperOutcome::Complete {
continuation,
event,
@@ -879,6 +895,7 @@ impl<B: provider::Owner> Active<'_, '_, B> {
&mut self.pe.thread.registers,
service_events,
) {
#[cfg(feature = "std")]
darwin_services::Outcome::Complete(pc) => Some(pc),
darwin_services::Outcome::NoEffect => None,
darwin_services::Outcome::Indeterminate(error) => return Err(error),
@@ -984,12 +1001,14 @@ fn empty_accounting() -> RunOutcome {
}
}
// Add alongside checked's existing provider/source declarations and reexports.
#[cfg(feature = "std")]
mod observation;
#[cfg(feature = "std")]
pub(crate) use observation::OwnedProcessObservation;
// ConsumerKey is constructed only by the canonical retirement consumer.
// This check is immutable and grants no execution or service completion.
#[cfg(feature = "std")]
pub(crate) fn qualify_observation(
authority: &crate::system::execution::authority::PeExecutionAuthority,
) -> anyhow::Result<()> {
@@ -1,7 +1,5 @@
//! Concrete fresh-software EL0 checked-memory/PAC/clock/TSD owner. No blanket
//! provider, stored Dispatcher, caller callback, second CPU or copied System.
#[cfg(not(feature = "std"))]
use alloc::string::ToString;
mod m0_owner;
mod resources;
pub(crate) use m0_owner::M0Owner;
@@ -10,35 +8,42 @@ pub(crate) use resources::{
El1ContextResources, El1ExecutionResources, El1SystemEffectResources, M0ExecutionResources,
};
use super::super::super::{checked_memory, complete_clock, complete_pauth_with_memory};
use super::super::software_async::NoAsyncSources;
use super::NativeObservation;
use super::entry_controls::ProcessEntryControls;
use super::source::{BoundSource, Helper};
use crate::{
memory::domain::MemoryExecutionLoan,
system::{execution::Boundary, state::SystemState},
};
use stela_compiler::{GuestAddress, GuestState};
// The hosted EL0 process owner; the freestanding mount has no Darwin process.
#[cfg(feature = "std")]
use super::super::super::{checked_memory, complete_clock, complete_pauth_with_memory};
#[cfg(feature = "std")]
use super::super::software_async::NoAsyncSources;
#[cfg(feature = "std")]
use super::{low128_call, pauth_lr};
#[cfg(feature = "std")]
use crate::{
blocks::{ClockEvent, PointerAuthenticationEvent, RunOutcome, ThreadRegisterEvent},
clock,
memory::{
domain::{MemoryExecutionLoan, MemoryThread},
policy::MemoryControls,
},
memory::{domain::MemoryThread, policy::MemoryControls},
pauth,
system::{
events::EventEndpoint,
execution::{Boundary, Dispatcher, EntryBoundary, Failure},
execution::{Dispatcher, EntryBoundary, Failure},
process_memory::{FixedProcessMemoryControls, PreparedProcessMemory},
scalable_controls::fp::FpControlOwner,
state::SystemState,
},
thread,
};
#[cfg(feature = "std")]
use stela_compiler::{
GuestAddress, GuestState,
block::PointerAuthenticationOperation,
context::{ExecutionContext, memory::MemoryRequirements},
};
use super::entry_controls::ProcessEntryControls;
#[cfg(feature = "std")]
pub(crate) struct CheckedProcessOwner<'pe> {
address_space: u64,
controls: &'pe mut FixedProcessMemoryControls,
@@ -52,6 +57,7 @@ pub(crate) struct CheckedProcessOwner<'pe> {
thread: &'pe mut thread::Context,
fp: Option<&'pe FpControlOwner<'pe>>,
}
#[cfg(feature = "std")]
impl<'pe> CheckedProcessOwner<'pe> {
/// # Safety
/// Called once by the actual fresh software machine constructor before it
@@ -210,6 +216,7 @@ impl<'pe> CheckedProcessOwner<'pe> {
pub(super) mod sealed {
pub(crate) trait Concrete {}
}
#[cfg(feature = "std")]
impl sealed::Concrete for CheckedProcessOwner<'_> {}
/// Only this source module can implement the canonical consumer's backend.
@@ -313,6 +320,7 @@ pub(crate) trait Owner: sealed::Concrete {
) -> anyhow::Result<()>;
}
#[cfg(feature = "std")]
impl Owner for CheckedProcessOwner<'_> {
fn execution_loan(&mut self) -> anyhow::Result<MemoryExecutionLoan> {
self.memory
@@ -589,6 +597,7 @@ impl Owner for CheckedProcessOwner<'_> {
}
/// Ephemeral borrows of SAME actual system/control/domain resources; no state.
#[cfg(feature = "std")]
struct ProcessDispatcher<'call, 'code> {
address_space: u64,
controls: &'call FixedProcessMemoryControls,
@@ -598,6 +607,7 @@ struct ProcessDispatcher<'call, 'code> {
endpoint: &'call EventEndpoint,
bound: &'call BoundSource<'code>,
}
#[cfg(feature = "std")]
impl Dispatcher for ProcessDispatcher<'_, '_> {
fn address_space(&self) -> u64 {
self.address_space
@@ -679,26 +689,31 @@ impl Dispatcher for ProcessDispatcher<'_, '_> {
}
pub(crate) enum HelperOutcome {
#[cfg(feature = "std")]
PreparedPauth {
instruction: stela_compiler::block::PointerAuthentication,
effect: pauth_lr::PreparedEffect,
},
#[cfg(feature = "std")]
AuthenticationFault {
instruction: stela_compiler::block::PointerAuthentication,
code: u8,
},
NoEffect(anyhow::Error),
#[cfg(feature = "std")]
Complete {
continuation: GuestAddress,
event: HelperEvent,
},
Indeterminate(anyhow::Error),
}
#[cfg(feature = "std")]
pub(crate) enum HelperEvent {
Pauth(PointerAuthenticationEvent),
Clock(ClockEvent),
Thread(ThreadRegisterEvent),
}
#[cfg(feature = "std")]
impl HelperEvent {
pub(super) fn poisoned_transfer(
&self,
@@ -722,8 +737,9 @@ impl HelperEvent {
}
}
// Append to blocks::retirement::checked::provider, which owns these private
// concrete resource fields. No generic provider or caller callback is involved.
// This module owns these private concrete resource fields. No generic
// provider or caller callback is involved.
#[cfg(feature = "std")]
impl CheckedProcessOwner<'_> {
pub(crate) fn observe_retained(
&self,
@@ -772,6 +788,7 @@ impl CheckedProcessOwner<'_> {
}
}
#[cfg(feature = "std")]
fn raw_memory_observation(
raw: checked_memory::RawMemoryObservation,
) -> super::RawMemoryObservation {
@@ -70,6 +70,7 @@ impl<'code> BoundSource<'code> {
.ok_or_else(|| anyhow::anyhow!("original System instruction absent"))
}
#[cfg(feature = "std")]
pub(super) fn memory_profile(
&self,
) -> anyhow::Result<stela_compiler::block::CheckedMemoryProfile> {
@@ -79,6 +80,7 @@ impl<'code> BoundSource<'code> {
.ok_or_else(|| anyhow::anyhow!("bound source lacks checked memory profile"))
}
#[cfg(feature = "std")]
pub(super) fn trap(&self) -> Option<SynchronousTrap> {
self.analysis.trap
}
@@ -117,6 +119,7 @@ impl<'code> BoundSource<'code> {
Ok(edge.target)
}
#[cfg(feature = "std")]
pub(super) fn pauth(&self) -> Option<PointerAuthentication> {
self.analysis.pointer_authentication
}
@@ -477,18 +477,6 @@ impl BootFrames {
Ok(())
}
/// Retire only the actual original RX mapping after all original calls finish.
/// On failure the allocation is quarantined; no recycled frame can hide it.
pub(crate) fn retire(mut self) -> Result<(), FrameError> {
let result = self.unmap();
// Failure remains quarantined and must not become an implicit Drop retry.
self.live = false;
if let Err(error) = result {
self.pool.quarantine(error);
}
result
}
fn unmap(&mut self) -> Result<(), FrameError> {
self.validate()?;
let mut allocation = self
@@ -46,11 +46,8 @@ impl Mapping {
unsafe { NativeImage::borrow(&self.frames).call_block(state) }
}
// Legacy research calls have no fallible-storage report/finalizer contract.
// Refuse BEFORE FFI; mounted canonical paths use the two observed methods.
pub unsafe fn call(&self, _state: &mut GuestState) -> Result<()> {
anyhow::bail!("freestanding native entry requires the original observed canonical session")
}
// Legacy research context calls have no fallible-storage report/finalizer
// contract. Refuse BEFORE FFI; mounted canonical paths use observed methods.
pub unsafe fn call_context(
&self,
_state: &mut GuestState,
@@ -37,6 +37,7 @@ impl<R, E> ReachedCall<R, E> {
}
impl<R> ReachedCall<R, Infallible> {
#[cfg(feature = "std")]
pub(super) fn into_infallible(self) -> R {
let (returned, storage_after) = self.into_observations();
match storage_after {
@@ -64,6 +65,7 @@ impl<'rx, S: ExecutableStorage + ?Sized> NativeImage<'rx, S> {
/// An adopted PE may call ONLY under its original canonical retained Active,
/// full ThreadState/System/backend/source/domain loan through finalization and
/// once-only PC settlement. No raw component call can bypass that owner.
#[cfg(feature = "std")]
pub(super) unsafe fn call(
&self,
state: &mut GuestState,
@@ -106,6 +108,7 @@ impl<'rx, S: ExecutableStorage + ?Sized> NativeImage<'rx, S> {
/// counter is not a PE, source, checked-memory or retirement permission.
/// Original storage and any applicable canonical owner remain borrowed
/// through both observations.
#[cfg(feature = "std")]
pub(super) unsafe fn call_budgeted_block(
&self,
state: &mut GuestState,
+5 -4
View File
@@ -163,6 +163,8 @@ pub struct DataProtectionLimit {
pub writable: bool,
}
#[derive(Debug)]
// The freestanding mount does not create host mappings.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
struct Allocation {
shared_backing: Option<Arc<backing::MemoryBacking>>,
storage: Arc<NativeStorage>,
@@ -233,6 +235,7 @@ pub fn host_page_size() -> Result<usize> {
Ok(4096)
}
#[cfg(feature = "std")]
fn page_rounded(bytes: u64, page: u64) -> Result<u64> {
Ok(bytes
.checked_add(page - 1)
@@ -584,6 +587,7 @@ impl OwnedMemory {
Err(ProtectionError::PlatformUnavailable)
}
#[cfg(feature = "std")]
fn protect_data_with(
&mut self,
address: u64,
@@ -596,6 +600,7 @@ impl OwnedMemory {
}
#[allow(clippy::too_many_arguments)]
#[cfg(feature = "std")]
fn protect_data_with_service(
&mut self,
address: u64,
@@ -847,10 +852,6 @@ fn host_protection(readable: bool, writable: bool) -> i32 {
}) | (if writable { libc::PROT_WRITE } else { 0 })
}
#[cfg(not(feature = "std"))]
fn host_protection(readable: bool, writable: bool) -> i32 {
(if readable { 1 } else { 0 }) | (if writable { 2 } else { 0 })
}
/// Runtime-published data with a permanently read-only, non-executable guest
/// view and an unexposed writable alias. Publication and translated accesses
/// must be serialized by the caller; this is not a concurrent kernel seqlock.
+10 -4
View File
@@ -6,12 +6,13 @@
#[cfg(feature = "std")]
use super::DIRECT_RAM_USER_END;
#[cfg(feature = "std")]
use super::host_protection;
#[cfg(feature = "std")]
use super::storage::NativeMapping;
use super::storage::NativeStorage;
use super::{
Allocation, MAX_FILE_MEMORY_BYTES, MAX_IMAGE_MEMORY_BYTES, MemoryRegion, OwnedMemory,
host_protection,
};
#[cfg(feature = "std")]
use super::{Allocation, MemoryRegion};
use super::{MAX_FILE_MEMORY_BYTES, MAX_IMAGE_MEMORY_BYTES, OwnedMemory};
use alloc::sync::Arc;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
@@ -256,6 +257,8 @@ impl OwnedMemory {
/// An unpublished mapping borrowing the same non-Send/Sync `OwnedMemory` owner.
/// Initialization is private and serialized; it never grants host execute rights.
// The freestanding mount does not create host mappings.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub struct PendingDataAllocation<'a> {
owner: &'a mut OwnedMemory,
storage: Option<Arc<NativeStorage>>,
@@ -368,6 +371,7 @@ impl PendingDataAllocation<'_> {
Err(AllocateDataError::UnsupportedPlatform)
}
#[cfg(feature = "std")]
fn publish_with(
mut self,
protect: impl FnOnce(u64, u64, i32) -> Result<(), Option<i32>>,
@@ -480,6 +484,8 @@ impl PendingDataAllocation<'_> {
}
}
// Uninhabited without std: the freestanding mount creates no host mappings.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
struct NewMapping {
#[cfg(not(feature = "std"))]
_unmounted: core::convert::Infallible,
@@ -65,6 +65,8 @@ impl core::fmt::Display for SharedBindingError {
impl core::error::Error for SharedBindingError {}
/// One group/system, retained by its facades and returned immutable snapshot.
// Only hosted shared-binding lifecycle reads the attributes back.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(super) struct SharedBinding {
system: Arc<MemorySystem>,
pub(super) domain: Arc<MemoryDomain>,
@@ -218,6 +220,7 @@ impl OwnedMemory {
.flat_map(|owner| owner.allocations.iter().zip(&owner.regions))
{
match allocation.storage.kind() {
#[cfg(feature = "std")]
StorageKind::PrivateFile => return Err(E::FileCopyOnWrite),
StorageKind::Anonymous => {}
_ => return Err(E::IncompatibleStorage),
@@ -445,6 +448,7 @@ impl OwnedMemory {
pub(crate) mod tests;
#[path = "binding/lifecycle.rs"]
#[cfg(feature = "std")]
mod lifecycle;
impl PublishedReadOnlyRegion {
@@ -189,6 +189,7 @@ impl MemoryServiceLoan {
}
/// Prepare every fallible view/profile/monitor operation before host effects.
#[cfg(feature = "std")]
pub(in crate::memory) fn prepare(
&self,
mut views: Vec<(Arc<MemoryView>, MappingAttributes)>,
@@ -222,6 +223,7 @@ impl MemoryServiceLoan {
})
}
#[cfg(feature = "std")]
pub(in crate::memory) fn retire(&self, views: &[Arc<MemoryView>]) -> Result<(), MemoryStatus> {
for view in views {
self.domain.retire_view(view)?;
@@ -229,6 +231,7 @@ impl MemoryServiceLoan {
Ok(())
}
#[cfg(feature = "std")]
pub(in crate::memory) fn commit(&self, snapshot: DomainSnapshot) -> Result<(), MemoryStatus> {
let mut state = self.domain.state.lock().map_err(|_| MemoryStatus::Domain)?;
self.domain.check_execution()?;
@@ -130,6 +130,7 @@ impl MemoryControls {
/// Admit ordinary ASIMD only while the same installed FP context and process
/// memory owners remain borrowed by the opaque prepared invocation token.
/// This snapshot has no raw flag/boolean constructor for the Low128 scope.
#[cfg(feature = "std")]
pub(crate) fn for_low128_authority(
authority: &crate::system::process_memory::Low128ProcessMemoryAuthorization<'_, '_, '_>,
) -> Self {
@@ -11,6 +11,7 @@ use std::fs::File;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum StorageKind {
Anonymous,
#[cfg(feature = "std")]
PrivateFile,
PublishedAliases,
}
@@ -99,17 +100,20 @@ impl Drop for NativeMapping {
}
}
#[cfg(feature = "std")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum StorageError {
AliasExtentMismatch,
AliasesOverlap,
}
#[cfg(feature = "std")]
impl core::fmt::Display for StorageError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "retained native storage failed: {self:?}")
}
}
#[cfg(feature = "std")]
impl core::error::Error for StorageError {}
/// One physical storage lifetime, optionally retaining its two native aliases.
+7
View File
@@ -1070,16 +1070,23 @@ mod tests {
pub(crate) mod features;
pub use features::UnsupportedInstructionProfile;
#[cfg(feature = "std")]
pub(crate) mod lr_context;
#[cfg(feature = "std")]
pub(crate) mod lr_instruction;
#[cfg(feature = "std")]
pub(crate) mod lr_service;
#[cfg(feature = "std")]
mod two_modifier;
#[cfg(feature = "std")]
pub(crate) use two_modifier::ConfigurationError as TwoModifierError;
#[cfg(feature = "std")]
pub(crate) mod lr_effects;
#[cfg(feature = "std")]
pub(crate) mod conditional;
@@ -5,6 +5,7 @@
//! raw integers and Context key presence do not establish that provenance.
//! Source/control/effect authorization remains with the runtime owners.
#[cfg(feature = "std")]
use super::Version;
use crate::system::{identification::Register, identification_snapshot::Snapshot};
@@ -28,6 +29,8 @@ pub enum UnsupportedInstructionProfile {
/// Exact QARMA5 PAuth_LR feature fact borrowed from the same CPU snapshot.
/// This capability does not authorize controls, PACM, source, BTI or GCS effects.
// Only the hosted PAuth_LR owner reads the snapshot back.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(crate) struct LinkRegisterPauthCapability<'profile> {
source: &'profile Snapshot,
}
@@ -49,10 +52,12 @@ impl<'profile> LinkRegisterPauthCapability<'profile> {
Ok(Self { source })
}
#[cfg(feature = "std")]
pub(crate) const fn snapshot(&self) -> &Snapshot {
self.source
}
#[cfg(feature = "std")]
pub(crate) const fn version(&self) -> Version {
Version::FaultingCombined
}
+2 -6
View File
@@ -1,11 +1,10 @@
//! Host allocation error retains its original API. Freestanding resource
//! production is unavailable until the actual loader/frame owner is joined.
//! Host allocation error retains its original API. Freestanding resources come
//! from the mounted loader frame owner.
#[cfg(feature = "std")]
pub(crate) type Error = std::io::Error;
#[cfg(not(feature = "std"))]
#[derive(Debug)]
pub(crate) enum Error {
Unavailable,
Boot(crate::platform::boot::MountError),
InvalidLayout(alloc::string::String),
}
@@ -19,9 +18,6 @@ impl Error {
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Unavailable => {
f.write_str("freestanding RAM allocation/protection owner is not mounted")
}
Self::InvalidLayout(detail) => f.write_str(detail),
Self::Boot(error) => error.fmt(f),
}
@@ -66,6 +66,7 @@ impl PeExecutionAuthority {
/// The closed consumer must additionally hold the actual same-domain service
/// loan before reading retained backend snapshots. This grants no entry,
/// reset, mutable resource access or phase transition.
#[cfg(feature = "std")]
pub(crate) fn check_observation(
&self,
_consumer: &crate::blocks::retirement::ConsumerKey,
@@ -48,6 +48,7 @@ impl<'pe, B> SystemExecutionOwner<'pe, B> {
}
/// Descriptive identity only; cloning it cannot produce a loan or authority.
#[cfg(feature = "std")]
pub(crate) fn identity(&self) -> super::authority::PeIdentity {
self.authority.identity()
}
@@ -56,6 +57,7 @@ impl<'pe, B> SystemExecutionOwner<'pe, B> {
pub(crate) fn pc(&self) -> stela_compiler::GuestAddress {
self.thread.pc
}
#[cfg(feature = "std")]
pub(crate) fn registers(&self) -> &stela_compiler::GuestState {
&self.thread.registers
}
@@ -95,7 +97,8 @@ impl<'run, B> SystemExecutionLoan<'run, B> {
}
}
// Append to system::execution::owner, the owner of these actual private fields.
// Hosted process observation over this owner's actual private fields.
#[cfg(feature = "std")]
impl<'pe, 'backend>
SystemExecutionOwner<'pe, crate::blocks::retirement::checked::CheckedProcessOwner<'backend>>
{
@@ -39,16 +39,23 @@ pub use pointer_checks::Error as PointerChecksError;
pub(crate) use pointer_checks::ResolvedPointerChecks;
pub use source::SourceNormalWbDomain;
#[path = "process_memory/low128.rs"]
#[cfg(feature = "std")]
mod low128;
#[cfg(feature = "std")]
pub(crate) use low128::Low128ProcessMemoryAuthorization;
#[cfg(feature = "std")]
pub use low128::PreparedLow128ProcessMemory;
#[path = "process_memory/scalable.rs"]
mod scalable;
pub use scalable::ScalableExecutionError;
#[cfg(feature = "std")]
pub(crate) const SCTLR_ENIA: u64 = 1 << 31;
#[cfg(feature = "std")]
pub(crate) const SCTLR_ENIB: u64 = 1 << 30;
#[cfg(feature = "std")]
pub(crate) const SCTLR_ENDA: u64 = 1 << 27;
#[cfg(feature = "std")]
pub(crate) const SCTLR_ENDB: u64 = 1 << 13;
const SCTLR_MMU_ENABLE: u64 = 1;
const SCTLR_DATA_CACHE_ENABLE: u64 = 1 << 2;
@@ -327,6 +334,7 @@ impl FixedProcessMemoryControls {
/// The same immutable source used at construction, if this scope has one.
/// Legacy raw-ID construction intentionally supplies no scalable authority.
#[cfg(feature = "std")]
pub(crate) fn identification_snapshot_owner(&self) -> Option<&Arc<Snapshot>> {
self.identification.as_ref()
}
@@ -7,9 +7,11 @@
//! effects and PC settlement. No read loan grants native entry or completion.
use super::{
FixedProcessMemoryControls, MemoryControls, MemoryExecutionLoan, MemoryStatus, MemoryThread,
ProcessMemoryError, Register, Snapshot, SourceNormalWbDomain,
FixedProcessMemoryControls, MemoryStatus, ProcessMemoryError, Register, Snapshot,
SourceNormalWbDomain,
};
#[cfg(feature = "std")]
use super::{MemoryControls, MemoryExecutionLoan, MemoryThread};
use crate::{
pauth::features::{LinkRegisterPauthCapability, UnsupportedInstructionProfile},
system::identification_snapshot::{Origin, Unsupported},
@@ -39,6 +41,8 @@ const CPA_WITH_CHECKING: u8 = 2;
/// Full raw registers are retained. Future EnFPM or mutation belongs to this
/// same owner; the current constructor rejects unimplemented extended bits.
#[derive(Debug)]
// Only the hosted CPA read loan reads the retained raw registers back.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(super) struct ExtendedControlBank {
sctlr2_el1: u64,
tcr2_el1: u64,
@@ -180,6 +184,7 @@ impl FixedProcessMemoryControls {
/// integer ASID, equivalent-looking Snapshot or separate domain is accepted.
/// This bounded loan validates current source and actual outer-domain identity; it does
/// not expand MTE memory support or prove PE/ThreadState identity.
#[cfg(feature = "std")]
pub(crate) fn extended_controls<'run>(
&'run self,
expected_snapshot: &Snapshot,
@@ -212,6 +217,7 @@ impl FixedProcessMemoryControls {
/// Non-Clone loan: renewal/mutation of the bank and release of the actual outer
/// pin are excluded while borrowed. No copied controls/IDs or second bank.
#[cfg(feature = "std")]
pub(crate) struct ExtendedControlLoan<'run> {
bank: &'run FixedProcessMemoryControls,
extended: &'run ExtendedControlBank,
@@ -220,6 +226,7 @@ pub(crate) struct ExtendedControlLoan<'run> {
address_space: u64,
}
#[cfg(feature = "std")]
impl<'run> ExtendedControlLoan<'run> {
pub(crate) fn snapshot(&self) -> &'run Snapshot {
self.snapshot
@@ -4,13 +4,19 @@
//! bound compiler profile. The token retains those borrows and the original
//! SystemState; its parent prepared token owns the same-domain execution pin.
use super::pointer_checks::{self};
use super::{
EntryBoundary, EventEndpoint, FixedProcessMemoryControls, GuestState, MemoryControls,
MemoryExecutionLoan, MemoryRequirements, MemoryThread, PointerChecksError,
PreparedProcessMemory, ProcessMemoryError, ResolvedPointerChecks, SystemState, flags,
};
use super::{FixedProcessMemoryControls, ResolvedPointerChecks, SystemState};
use crate::system::debug::DebugControls;
// Preparation is reached only by the hosted EL0 process owner.
#[cfg(feature = "std")]
use super::pointer_checks::{self};
#[cfg(feature = "std")]
use super::{
EntryBoundary, EventEndpoint, GuestState, MemoryControls, MemoryExecutionLoan,
MemoryRequirements, MemoryThread, PointerChecksError, PreparedProcessMemory,
ProcessMemoryError, flags,
};
#[cfg(feature = "std")]
use stela_compiler::{
block::CheckedMemoryProfile,
context::memory::{
@@ -32,6 +38,7 @@ impl PointerMemoryAuthorization<'_> {
}
impl FixedProcessMemoryControls {
#[cfg(feature = "std")]
pub(super) fn qualify_pointer<'run>(
&'run self,
profile: CheckedMemoryProfile,
@@ -108,6 +115,7 @@ impl FixedProcessMemoryControls {
}
#[allow(clippy::too_many_arguments)]
#[cfg(feature = "std")]
pub(crate) fn prepare_profile<'run>(
&'run self,
boundary: &EntryBoundary,
@@ -139,6 +147,7 @@ impl FixedProcessMemoryControls {
/// debug owner, PE/source/outer and exact immutable runtime profile. This is
/// not a public loose-control or permission-boolean constructor.
#[allow(clippy::too_many_arguments)]
#[cfg(feature = "std")]
pub(crate) fn prepare_pointer<'run>(
&'run self,
boundary: &EntryBoundary,
@@ -4,11 +4,13 @@
//! The canonical consumer retains the actual PE/System/thread/source/outer and
//! immutable control/debug owners through native effects and retirement.
#[cfg(feature = "std")]
use super::extended_controls::{
ExtendedControlLoan, SCTLR2_CPTA, SCTLR2_CPTA0, SCTLR2_CPTM, SCTLR2_CPTM0,
};
#[cfg(feature = "std")]
use crate::system::debug::DebugControls;
use crate::system::{
debug::DebugControls,
identification::Register,
identification_snapshot::{Snapshot, Unsupported},
};
@@ -22,8 +24,11 @@ const ISAR3_CPA_SHIFT: u32 = 0;
const CPA_ABSENT: u8 = 0;
const CPA_ARITHMETIC: u8 = 1;
const CPA_CHECKED: u8 = 2;
#[cfg(feature = "std")]
const MMFR3_SCTLRX_SHIFT: u32 = 4;
#[cfg(feature = "std")]
const SCTLR2_ABSENT: u8 = 0;
#[cfg(feature = "std")]
const SCTLR2_PRESENT: u8 = 1;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -74,6 +79,7 @@ pub(crate) struct ResolvedPointerChecks {
}
impl ResolvedPointerChecks {
#[cfg(feature = "std")]
const fn unchecked(feature: CpaFeature) -> Self {
Self {
feature,
@@ -102,6 +108,7 @@ impl ResolvedPointerChecks {
}
}
#[cfg(feature = "std")]
fn field(snapshot: &Snapshot, register: Register, shift: u32) -> Result<u8, Error> {
let raw = snapshot.read(register).map_err(Error::Identification)?;
Ok(((raw >> shift) & FIELD_MASK) as u8)
@@ -118,6 +125,7 @@ fn unsupported(register: Register, name: &'static str, value: u8) -> Error {
/// Resolve both EL10 effects without collapsing a block's distinct access ELs.
/// CPA0/1 returns before debug/regime/SCTLR2 lookup as the source helpers require.
/// This does not select source AccessDescriptor.el or validate PSTATE legality.
#[cfg(feature = "std")]
pub(crate) fn resolve(
snapshot: &Snapshot,
actual_debug: Option<&DebugControls>,
@@ -1,7 +1,9 @@
//! Source-resolved ARM memory attributes for one exact domain generation.
//! Native storage eligibility is validated separately by the existing domain.
use crate::memory::domain::{DataPolicy, MemoryDomain, MemoryExecutionLoan, MemoryThread};
#[cfg(feature = "std")]
use crate::memory::domain::MemoryExecutionLoan;
use crate::memory::domain::{DataPolicy, MemoryDomain, MemoryThread};
use alloc::sync::Arc;
use stela_compiler::context::memory::MemoryStatus;
@@ -61,6 +63,7 @@ impl SourceNormalWbDomain {
/// Validate this original source generation while its actual counted domain
/// pin remains borrowed. No new pin or PE/thread identity is created.
#[cfg(feature = "std")]
pub(super) fn check_current_execution<P: DataPolicy>(
&self,
thread: &MemoryThread<P>,
+2
View File
@@ -152,6 +152,8 @@ impl Context {
}
}
// Only hosted thread events read the prior value back.
#[cfg_attr(not(feature = "std"), allow(dead_code))]
pub(crate) struct PlatformResult {
pub next_pc: stela_compiler::GuestAddress,
pub completion: platform::Completion,
+11 -2
View File
@@ -6,8 +6,9 @@ usage() {
cat <<'USAGE'
Usage: ./dev/check [--fix]
Run Rust formatting checks, strict workspace Clippy, then workspace tests.
Default checks do not format source files. --fix formats Rust sources first.
Run Rust formatting checks, strict workspace and freestanding Clippy, then
workspace tests. Default checks do not format source files. --fix formats Rust
sources first.
USAGE
}
fix=false
@@ -23,9 +24,17 @@ case "$#" in
*) usage >&2; exit 2 ;;
esac
cd "$root"
# The freestanding mount has its own manifest outside the workspace.
boot=dev/boot/Cargo.toml
if [ "$fix" = true ]; then
./dev/cargo fmt --all
./dev/cargo fmt --manifest-path "$boot" --all
fi
./dev/cargo fmt --all -- --check
./dev/cargo fmt --manifest-path "$boot" --all -- --check
./dev/cargo clippy --workspace --all-targets --locked -- -D warnings
# RUSTFLAGS also denies warnings in the runtime crates the mount builds without
# std; registry dependencies stay lint-capped. Output stays under ignored target/.
RUSTFLAGS="-D warnings" ./dev/cargo clippy --manifest-path "$boot" --locked \
--target x86_64-unknown-none --target-dir target/boot -- -D warnings
./dev/cargo test --workspace --locked
+1
View File
@@ -2,3 +2,4 @@
channel = "stable"
profile = "minimal"
components = ["rustfmt", "clippy"]
targets = ["x86_64-unknown-none"]