@@ -138,12 +138,12 @@ impl<'a> Inv for VmSpaceOwner<'a> {
138138}
139139
140140impl <' a> VmSpaceOwner <' a> {
141- /// This specification function ensures that the `mem_view` (remaining view),
142- /// `mv_range` (total view), and the views held by active readers and writers
141+ /// This specification function ensures that the `mem_view` (remaining view),
142+ /// `mv_range` (total view), and the views held by active readers and writers
143143 /// maintain a consistent global state.
144- ///
144+ ///
145145 /// The key properties include:
146- ///
146+ ///
147147 /// ### 1. Existence Invariants
148148 /// * `mem_view` is present if and only if `mv_range` is present.
149149 ///
@@ -255,7 +255,7 @@ impl<'a> VmSpaceOwner<'a> {
255255
256256 /// Determines whether a new reader can be safely instantiated within the VM address space.
257257 ///
258- /// This specification function enforces memory isolation by ensuring that the
258+ /// This specification function enforces memory isolation by ensuring that the
259259 /// requested memory range does not intersect with the domain of any active writer.
260260 pub open spec fn can_create_reader( & self , vaddr: Vaddr , len: usize ) -> bool
261261 recommends
@@ -453,165 +453,8 @@ impl<'a> VmSpaceOwner<'a> {
453453
454454 }
455455
456- /// Activates the given reader to read data from the user space of the current task.
457- /// # Verified Properties
458- /// ## Preconditions
459- /// - The [`VmSpace`] invariants must hold with respect to the [`VmSpaceOwner`], which must be active.
460- /// - The reader must be well-formed with respect to the [`VmSpaceOwner`].
461- /// - The reader's virtual address range must be mapped within the [`VmSpaceOwner`]'s memory view.
462- /// ## Postconditions
463- /// - The reader will be added to the [`VmSpace`]'s readers list.
464- /// - The reader will be activated with a view of its virtual address range taken from the [`VmSpaceOwner`]'s memory view.
465- /// ## Safety
466- /// - The function preserves all memory invariants.
467- /// - The [`MemView`] invariants ensure that the reader has a consistent view of memory.
468- /// - The [`VmSpaceOwner`] invariants ensure that the viewed memory is owned exclusively by this [`VmSpace`].
469- #[ inline( always) ]
470- #[ verus_spec( r =>
471- requires
472- old( self ) . mem_view matches Some ( mv) &&
473- forall |va: usize |
474- #![ auto]
475- old( owner_r) . range@. start <= va < old( owner_r) . range@. end ==>
476- mv. addr_transl( va) is Some
477- ,
478- old( self ) . inv( ) ,
479- old( self ) . active,
480- old( owner_r) . inv_with_reader( * reader) ,
481- old( owner_r) . mem_view is None ,
482- reader. inv( ) ,
483- ensures
484- owner_r. inv_with_reader( * reader) ,
485- owner_r. mem_view == Some ( VmIoMemView :: ReadView ( & old( self ) . mem_view@. unwrap( ) . borrow_at_spec(
486- old( owner_r) . range@. start,
487- ( old( owner_r) . range@. end - old( owner_r) . range@. start) as usize ,
488- ) ) ) ,
489- ) ]
490- pub proof fn activate_reader( tracked & mut self , reader: & ' a VmReader <' a>, owner_r: & ' a mut VmIoOwner <' a>) {
491- let tracked mv = match self . mem_view {
492- Some ( ref mv) => mv,
493- _ => { proof_from_false( ) } ,
494- } ;
495- let tracked borrowed_mv = mv. borrow_at(
496- owner_r. range@. start,
497- ( owner_r. range@. end - owner_r. range@. start) as usize ,
498- ) ;
499-
500- owner_r. mem_view = Some ( VmIoMemView :: ReadView ( borrowed_mv) ) ;
501-
502- assert forall|va: usize |
503- #![ auto]
504- owner_r. range@. start <= va < owner_r. range@. end implies borrowed_mv. addr_transl(
505- va,
506- ) is Some by {
507- if owner_r. range@. start <= va && va < owner_r. range@. end {
508- assert( borrowed_mv. mappings =~= mv. mappings. filter(
509- |m: Mapping |
510- m. va_range. start < ( owner_r. range@. end) && m. va_range. end
511- > owner_r. range@. start,
512- ) ) ;
513- let o_borrow_mv = borrowed_mv. mappings. filter(
514- |m: Mapping | m. va_range. start <= va < m. va_range. end,
515- ) ;
516- let o_mv = mv. mappings. filter(
517- |m: Mapping | m. va_range. start <= va < m. va_range. end,
518- ) ;
519- assert( mv. addr_transl( va) is Some ) ;
520- assert( o_mv. len( ) > 0 ) ;
521- assert( o_borrow_mv. len( ) > 0 ) by {
522- let m = o_mv. choose( ) ;
523- assert( o_mv. contains( m) ) by {
524- vstd:: set:: axiom_set_choose_len( o_mv) ;
525- }
526- assert( o_borrow_mv. contains( m) ) ;
527- }
528- }
529- }
530-
531- }
532-
533-
534- /// Activates the given writer to write data to the user space of the current task.
535- /// # Verified Properties
536- /// ## Preconditions
537- /// - The [`VmSpace`] invariants must hold with respect to the [`VmSpaceOwner`], which must be active.
538- /// - The writer must be well-formed with respect to the [`VmSpaceOwner`].
539- /// - The writer's virtual address range must be mapped within the [`VmSpaceOwner`]'s memory view.
540- /// ## Postconditions
541- /// - The writer will be added to the [`VmSpace`]'s writers list.
542- /// - The writer will be activated with a view of its virtual address range taken from the [`VmSpaceOwner`]'s memory view.
543- /// ## Safety
544- /// - The function preserves all memory invariants.
545- /// - The [`MemView`] invariants ensure that the writer has a consistent view of memory.
546- /// - The [`VmSpaceOwner`] invariants ensure that the viewed memory is owned exclusively by
547- /// this [`VmSpace`].
548- #[ inline( always) ]
549- #[ verus_spec( r =>
550- requires
551- old( self ) . mem_view matches Some ( mv) &&
552- forall |va: usize |
553- #![ auto]
554- old( owner_w) . range@. start <= va < old( owner_w) . range@. end ==>
555- mv. addr_transl( va) is Some
556- ,
557- old( self ) . inv( ) ,
558- old( self ) . active,
559- old( owner_w) . inv_with_writer( * writer) ,
560- old( owner_w) . mem_view is None ,
561- writer. inv( ) ,
562- ensures
563- owner_w. inv_with_writer( * writer) ,
564- owner_w. mem_view == Some ( VmIoMemView :: WriteView ( old( self ) . mem_view@. unwrap( ) . split_spec(
565- old( owner_w) . range@. start,
566- ( old( owner_w) . range@. end - old( owner_w) . range@. start) as usize ,
567- ) . 0 ) ) ,
568- ) ]
569- pub proof fn activate_writer( tracked & mut self , writer: & ' a VmWriter <' a>, owner_w: & ' a mut VmIoOwner <' a>) {
570- let tracked mut mv = self . mem_view. tracked_take( ) ;
571- let ghost old_mv = mv;
572- let tracked ( lhs, rhs) = mv. split(
573- owner_w. range@. start,
574- ( owner_w. range@. end - owner_w. range@. start) as usize ,
575- ) ;
576-
577- owner_w. mem_view = Some ( VmIoMemView :: WriteView ( lhs) ) ;
578- self . mem_view = Some ( rhs) ;
579-
580- assert forall|va: usize |
581- #![ auto]
582- owner_w. range@. start <= va < owner_w. range@. end implies lhs. addr_transl(
583- va,
584- ) is Some by {
585- if owner_w. range@. start <= va && va < owner_w. range@. end {
586- assert( lhs. mappings =~= old_mv. mappings. filter(
587- |m: Mapping |
588- m. va_range. start < ( owner_w. range@. end) && m. va_range. end
589- > owner_w. range@. start,
590- ) ) ;
591- let o_lhs = lhs. mappings. filter(
592- |m: Mapping | m. va_range. start <= va < m. va_range. end,
593- ) ;
594- let o_mv = old_mv. mappings. filter(
595- |m: Mapping | m. va_range. start <= va < m. va_range. end,
596- ) ;
597-
598- assert( old_mv. addr_transl( va) is Some ) ;
599- assert( o_mv. len( ) > 0 ) ;
600- assert( o_lhs. len( ) > 0 ) by {
601- broadcast use vstd:: set:: axiom_set_choose_len;
602-
603- let m = o_mv. choose( ) ;
604- assert( o_mv. contains( m) ) ;
605- assert( m. va_range. start <= va < m. va_range. end) ;
606- assert( o_lhs. contains( m) ) ;
607- }
608- }
609- }
610-
611- }
612-
613456 /// Removes the given reader from the active readers list.
614- ///
457+ ///
615458 /// # Verified Properties
616459 /// ## Preconditions
617460 /// - The [`VmSpace`] invariants must hold with respect to the [`VmSpaceOwner`], which must be active.
@@ -636,7 +479,7 @@ impl<'a> VmSpaceOwner<'a> {
636479
637480
638481 /// Removes the given writer from the active writers list.
639- ///
482+ ///
640483 /// # Verified Properties
641484 /// ## Preconditions
642485 /// - The [`VmSpace`] invariants must hold with respect to the [`VmSpaceOwner`], which must be active.
0 commit comments