@@ -528,9 +528,15 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
528528 }
529529
530530 fn setup_mpu ( & self ) -> MpuConfiguredCapability {
531+ let dwt = self . chip . dwt ( ) ;
532+ dwt. reset ( ) ;
533+ dwt. start ( ) ;
531534 self . app_memory_allocator
532535 . map_or ( Err ( ( ) ) , |am| Ok ( am. configure_mpu ( self . chip . mpu ( ) ) ) )
533536 . expect ( "Fatal kernel bug in setting up MPU - cannot branch to process as it would be unsafe" )
537+ dwt. stop ( ) ;
538+ let count = dwt. count ( ) ;
539+ crate :: debug!( "[EVAL] setup_mpu {}" , count) ;
534540 }
535541
536542 #[ flux_rs:: sig( fn ( _, start: FluxPtrU8 , size: usize { valid_size( start+size) } ) -> _) ]
@@ -552,12 +558,15 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
552558 }
553559
554560 fn brk ( & self , new_break : FluxPtrU8Mut ) -> Result < FluxPtrU8Mut , Error > {
561+ let dwt = self . chip . dwt ( ) ;
562+ dwt. reset ( ) ;
563+ dwt. start ( ) ;
555564 // Do not modify an inactive process.
556565 if !self . is_running ( ) {
557566 return Err ( Error :: InactiveApp ) ;
558567 }
559568
560- self . app_memory_allocator
569+ let res = self . app_memory_allocator
561570 . map_or ( Err ( Error :: KernelError ) , |am| {
562571 am. update_app_memory ( new_break) ?;
563572 // VTOCK Note:
@@ -566,7 +575,11 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
566575 // apps as they seem to use the value returned here to immediately
567576 // read/write to memory.
568577 Ok ( new_break)
569- } )
578+ } ) ;
579+ dwt. stop ( ) ;
580+ let count = dwt. count ( ) ;
581+ crate :: debug!( "[EVAL] brk {:?}" , count) ;
582+ res
570583 }
571584
572585 #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
@@ -575,6 +588,9 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
575588 buf_start_addr : FluxPtrU8Mut ,
576589 size : usize ,
577590 ) -> Result < ReadWriteProcessBuffer , ErrorCode > {
591+ let dwt = self . chip . dwt ( ) ;
592+ dwt. reset ( ) ;
593+ dwt. start ( ) ;
578594 if !self . is_running ( ) {
579595 // Do not operate on an inactive process
580596 return Err ( ErrorCode :: FAIL ) ;
@@ -631,10 +647,14 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
631647 // We encapsulate the unsafe here on the condition in the TODO
632648 // above, as we must ensure that this `ReadWriteProcessBuffer` will
633649 // be the only reference to this memory.
634- match process_buffer {
650+ let res = match process_buffer {
635651 Some ( Ok ( process_buffer) ) => return Ok ( process_buffer) ,
636652 _ => return Err ( ErrorCode :: INVAL ) ,
637- }
653+ } ;
654+ dwt. stop ( ) ;
655+ let count = dwt. count ( ) ;
656+ crate :: debug!( "[EVAL] build_readwrite_process_buffer {:?}" , count) ;
657+ res
638658 }
639659 }
640660
@@ -644,6 +664,9 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
644664 buf_start_addr : FluxPtrU8Mut ,
645665 size : usize ,
646666 ) -> Result < ReadOnlyProcessBuffer , ErrorCode > {
667+ let dwt = self . chip . dwt ( ) ;
668+ dwt. reset ( ) ;
669+ dwt. start ( ) ;
647670 if !self . is_running ( ) {
648671 // Do not operate on an inactive process
649672 return Err ( ErrorCode :: FAIL ) ;
@@ -652,7 +675,7 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
652675 // A process is allowed to pass any pointer if the buffer length is 0,
653676 // as to revoke kernel access to a memory region without granting access
654677 // to another one
655- if size == 0 {
678+ let res = if size == 0 {
656679 // Clippy complains that we're dereferencing a pointer in a public
657680 // and safe function here. While we are not dereferencing the
658681 // pointer here, we pass it along to an unsafe function, which is as
@@ -718,7 +741,11 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
718741 // above, as we must ensure that this `ReadOnlyProcessBuffer` will
719742 // be the only reference to this memory.
720743 Ok ( unsafe { ReadOnlyProcessBuffer :: new ( buf_start_addr, size, self . processid ( ) ) } )
721- }
744+ } ;
745+ dwt. stop ( ) ;
746+ let count = dwt. count ( ) ;
747+ crate :: debug!( "[EVAL] build_readonly_process_buffer {:?}" , count) ;
748+ res
722749 }
723750
724751 fn set_byte ( & self , addr : FluxPtrU8Mut , value : u8 ) -> Result < bool , ( ) > {
@@ -749,6 +776,10 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
749776 size : usize ,
750777 align : usize ,
751778 ) -> Result < ( ) , ( ) > {
779+ let dwt = self . chip . dwt ( ) ;
780+ dwt. reset ( ) ;
781+ dwt. start ( ) ;
782+
752783 // Do not modify an inactive process.
753784 if !self . is_running ( ) {
754785 return Err ( ( ) ) ;
@@ -789,7 +820,7 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
789820
790821 // Use the shared grant allocator function to actually allocate memory.
791822 // Returns `None` if the allocation cannot be created.
792- if let Some ( grant_ptr) = self . allocate_in_grant_region_internal ( size, align) {
823+ let res = if let Some ( grant_ptr) = self . allocate_in_grant_region_internal ( size, align) {
793824 // Update the grant pointer to the address of the new allocation.
794825 self . grant_pointers . map_or ( Err ( ( ) ) , |grant_pointers| {
795826 // Implement `grant_pointers[grant_num] = grant_ptr` without a
@@ -808,14 +839,21 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
808839 } else {
809840 // Could not allocate the memory for the grant region.
810841 Err ( ( ) )
811- }
842+ } ;
843+ dwt. stop ( ) ;
844+ let count = dwt. count ( ) ;
845+ crate :: debug!( "[EVAL] allocate_grant {:?}" , count) ;
846+ res
812847 }
813848
814849 fn allocate_custom_grant (
815850 & self ,
816851 size : usize ,
817852 align : usize ,
818853 ) -> Result < ( ProcessCustomGrantIdentifier , NonNull < u8 > ) , ( ) > {
854+ let dwt = self . chip . dwt ( ) ;
855+ dwt. reset ( ) ;
856+ dwt. start ( ) ;
819857 // Do not modify an inactive process.
820858 if !self . is_running ( ) {
821859 return Err ( ( ) ) ;
@@ -827,8 +865,12 @@ impl<C: Chip> Process for ProcessStandard<'_, C> {
827865
828866 // Use the shared grant allocator function to actually allocate memory.
829867 // Returns `None` if the allocation cannot be created.
830- self . app_memory_allocator
831- . map_or ( Err ( ( ) ) , |am| am. allocate_custom_grant ( size, align) )
868+ let res = self . app_memory_allocator
869+ . map_or ( Err ( ( ) ) , |am| am. allocate_custom_grant ( size, align) ) ;
870+ dwt. stop ( ) ;
871+ let count = dwt. count ( ) ;
872+ crate :: debug!( "[EVAL] allocate_custom_grant {:?}" , count) ;
873+ res
832874 }
833875
834876 fn enter_grant ( & self , grant_num : usize ) -> Result < NonNull < u8 > , Error > {
@@ -1308,6 +1350,9 @@ impl<C: 'static + Chip> ProcessStandard<'_, C> {
13081350 index : usize ,
13091351 ) -> Result < ( Option < & ' static dyn Process > , & ' a mut [ u8 ] ) , ( ProcessLoadError , & ' a mut [ u8 ] ) >
13101352 {
1353+ let dwt = chip. dwt ( ) ;
1354+ dwt. reset ( ) ;
1355+ dwt. start ( ) ;
13111356 let process_name = pb. header . get_package_name ( ) ;
13121357 let process_ram_requested_size = pb. header . get_minimum_app_ram_size ( ) as usize ;
13131358
@@ -1739,6 +1784,9 @@ impl<C: 'static + Chip> ProcessStandard<'_, C> {
17391784 } ) ) ;
17401785 Ok :: < ( ) , ProcessLoadError > ( ( ) )
17411786 } ) ;
1787+ dwt. stop ( ) ;
1788+ let count = dwt. count ( ) ;
1789+ crate :: debug!( "[EVAL] create {}" , count) ;
17421790 // Return the process object and a remaining memory for processes slice.
17431791 Ok ( ( Some ( process) , unused_memory) )
17441792 }
0 commit comments