@@ -89,8 +89,9 @@ struct UatRegion {
8989 map : io_mem:: Mem ,
9090}
9191
92- /// It's safe to share UAT region records across threads.
92+ /// SAFETY: It's safe to share UAT region records across threads.
9393unsafe impl Send for UatRegion { }
94+ /// SAFETY: It's safe to share UAT region records across threads.
9495unsafe impl Sync for UatRegion { }
9596
9697/// Handoff region flush info structure
@@ -353,7 +354,7 @@ impl gpuvm::DriverGpuVm for VmInner {
353354 . prev_va
354355 . take ( )
355356 . expect ( "Multiple step_remap calls with prev_op" ) ;
356- if prev_op. map_and_link_va ( self , prev_gpuva, & vm_bo) . is_err ( ) {
357+ if prev_op. map_and_link_va ( self , prev_gpuva, vm_bo) . is_err ( ) {
357358 dev_err ! ( self . dev. as_ref( ) , "step_remap: could not relink prev gpuva" ) ;
358359 return Err ( EINVAL ) ;
359360 }
@@ -364,7 +365,7 @@ impl gpuvm::DriverGpuVm for VmInner {
364365 . next_va
365366 . take ( )
366367 . expect ( "Multiple step_remap calls with next_op" ) ;
367- if next_op. map_and_link_va ( self , next_gpuva, & vm_bo) . is_err ( ) {
368+ if next_op. map_and_link_va ( self , next_gpuva, vm_bo) . is_err ( ) {
368369 dev_err ! ( self . dev. as_ref( ) , "step_remap: could not relink next gpuva" ) ;
369370 return Err ( EINVAL ) ;
370371 }
@@ -399,7 +400,7 @@ impl VmInner {
399400
400401 /// Returns the translation table base for this Vm
401402 fn ttb ( & self ) -> u64 {
402- self . page_table . ttb ( ) as u64
403+ self . page_table . ttb ( )
403404 }
404405
405406 /// Map an `mm::Node` representing an mapping in VA space.
@@ -541,7 +542,6 @@ pub(crate) struct KernelMappingInner {
541542}
542543
543544/// An object mapping into a [`Vm`], which reserves the address range from use by other mappings.
544-
545545pub ( crate ) struct KernelMapping ( mm:: Node < ( ) , KernelMappingInner > ) ;
546546
547547impl KernelMapping {
@@ -899,6 +899,7 @@ unsafe impl Send for HandoffFlush {}
899899impl HandoffFlush {
900900 /// Set up a flush operation for the coprocessor
901901 fn begin_flush ( & self , start : u64 , size : u64 ) {
902+ // SAFETY: Per the type invariant, this is safe
902903 let flush = unsafe { self . 0 . as_ref ( ) . unwrap ( ) } ;
903904
904905 let state = flush. state . load ( Ordering :: Relaxed ) ;
@@ -912,6 +913,7 @@ impl HandoffFlush {
912913
913914 /// Complete a flush operation for the coprocessor
914915 fn end_flush ( & self ) {
916+ // SAFETY: Per the type invariant, this is safe
915917 let flush = unsafe { self . 0 . as_ref ( ) . unwrap ( ) } ;
916918 let state = flush. state . load ( Ordering :: Relaxed ) ;
917919 if state != 2 {
@@ -1461,6 +1463,8 @@ impl Uat {
14611463 let handoff_rgn = Self :: map_region ( dev. as_ref ( ) , c_str ! ( "handoff" ) , HANDOFF_SIZE , true ) ?;
14621464 let ttbs_rgn = Self :: map_region ( dev. as_ref ( ) , c_str ! ( "ttbs" ) , SLOTS_SIZE , true ) ?;
14631465
1466+ // SAFETY: The Handoff struct layout matches the firmware's view of memory at this address,
1467+ // and the region is at least large enough per the size specified above.
14641468 let handoff = unsafe { & ( handoff_rgn. map . ptr ( ) as * mut Handoff ) . as_ref ( ) . unwrap ( ) } ;
14651469
14661470 dev_info ! ( dev. as_ref( ) , "MMU: Initializing kernel page table\n " ) ;
0 commit comments