Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ostd/src/mm/kspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,17 @@ pub exec static KERNEL_PAGE_TABLE: OnceImpl<PageTable<KernelPtConfig>, TrivialPr
OnceImpl::new(Ghost(TrivialPred));


#[derive(Clone, Debug)]
pub(crate) struct KernelPtConfig {}
#[derive(Debug)]
pub struct KernelPtConfig {}

#[verus_verify]
impl Clone for KernelPtConfig {
#[inline(always)]
#[verus_spec(returns self)]
fn clone(&self) -> Self {
KernelPtConfig {}
}
}

// We use the first available PTE bit to mark the frame as tracked.
// SAFETY: `item_into_raw` and `item_from_raw` are implemented correctly,
Expand Down
13 changes: 12 additions & 1 deletion ostd/src/mm/tlb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl<'a /*, G: PinCurrentCpu*/ > TlbFlusher<'a /*, G*/ > {
}

/// The operation to flush TLB entries.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq)]
pub enum TlbFlushOp {
/// Flush all TLB entries except for the global entries.
All,
Expand All @@ -198,6 +198,17 @@ pub enum TlbFlushOp {
Range(Range<Vaddr>),
}

impl Clone for TlbFlushOp {
#[verus_spec(returns self)]
fn clone(&self) -> Self {
match self {
TlbFlushOp::All => TlbFlushOp::All,
TlbFlushOp::Address(addr) => TlbFlushOp::Address(*addr),
TlbFlushOp::Range(range) => TlbFlushOp::Range(range.clone()),
}
}
}

impl TlbFlushOp {
/// Performs the TLB flush operation on the current CPU.
#[verifier::external_body]
Expand Down
11 changes: 10 additions & 1 deletion ostd/src/mm/vm_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,18 @@ pub(super) fn get_activated_vm_space() -> *const VmSpace {
}*/

/// The configuration for user page tables.
#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct UserPtConfig {}

#[verus_verify]
impl Clone for UserPtConfig {
#[inline(always)]
#[verus_spec(returns self)]
fn clone(&self) -> Self {
Self {}
}
}

/// The item that can be mapped into the [`VmSpace`].
pub struct MappedItem {
pub frame: UFrame,
Expand Down
23 changes: 22 additions & 1 deletion ostd/src/util/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,35 @@
use vstd::prelude::*;

#[verus_verify]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[derive(Copy, PartialEq, Eq, Debug)]
pub enum Either<L, R> {
/// Contains the left value
Left(L),
/// Contains the right value
Right(R),
}

#[verus_verify]
impl<L, R> Clone for Either<L, R>
where
L: Clone,
R: Clone,
{
#[inline(always)]
#[verus_spec(r =>
ensures
(forall|l1, l2: L| call_ensures(L::clone, (l1,), l2) ==> l1 == l2) &&
(forall|r1, r2: R| call_ensures(R::clone, (r1,), r2) ==> r1 == r2)
==> r == self,
)]
fn clone(&self) -> Self {
match self {
Self::Left(left) => Self::Left(left.clone()),
Self::Right(right) => Self::Right(right.clone()),
}
}
}

impl<L, R> Either<L, R> {
#[verus_verify(dual_spec)]
/// Converts to the left value, if any.
Expand Down