File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
src/hyperlight_host/src/mem Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -90,18 +90,17 @@ impl vmem::TableOps for GuestPageTableBuffer {
9090 unsafe fn read_entry ( & self , addr : ( usize , usize ) ) -> PageTableEntry {
9191 let b = self . buffer . borrow ( ) ;
9292 let byte_offset = addr. 0 * PAGE_TABLE_SIZE + addr. 1 * 8 ;
93- unsafe {
94- let ptr = b . as_ptr ( ) . add ( byte_offset ) as * const PageTableEntry ;
95- ptr . read_unaligned ( )
96- }
93+ b . get ( byte_offset..byte_offset + 8 )
94+ . and_then ( |s| < [ u8 ; 8 ] > :: try_from ( s ) . ok ( ) )
95+ . map ( u64 :: from_ne_bytes )
96+ . unwrap_or ( 0 )
9797 }
9898
9999 unsafe fn write_entry ( & self , addr : ( usize , usize ) , x : PageTableEntry ) {
100100 let mut b = self . buffer . borrow_mut ( ) ;
101101 let byte_offset = addr. 0 * PAGE_TABLE_SIZE + addr. 1 * 8 ;
102- unsafe {
103- let ptr = b. as_mut_ptr ( ) . add ( byte_offset) as * mut PageTableEntry ;
104- ptr. write_unaligned ( x) ;
102+ if let Some ( slice) = b. get_mut ( byte_offset..byte_offset + 8 ) {
103+ slice. copy_from_slice ( & x. to_ne_bytes ( ) ) ;
105104 }
106105 }
107106
You can’t perform that action at this time.
0 commit comments