File tree Expand file tree Collapse file tree
src/hyperlight_common/src/virtq Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -319,9 +319,12 @@ mod tests {
319319
320320 #[ test]
321321 fn desc_table_get_out_of_bounds ( ) {
322- let mut vec = vec ! [ Descriptor :: zeroed( ) ; 4 ] ;
323- let ptr = vec. as_mut_ptr ( ) ;
324- let table = unsafe { DescTable :: from_raw_parts ( ptr. addr ( ) as u64 , 4 ) } ;
322+ // Allocate with extra space to guarantee 16-byte alignment
323+ // (Descriptor requires ALIGN=16 but repr(C) only gives 8).
324+ let mut buf = vec ! [ 0u8 ; 4 * Descriptor :: SIZE + Descriptor :: ALIGN ] ;
325+ let base = buf. as_mut_ptr ( ) as usize ;
326+ let aligned = ( base + Descriptor :: ALIGN - 1 ) & !( Descriptor :: ALIGN - 1 ) ;
327+ let table = unsafe { DescTable :: from_raw_parts ( aligned as u64 , 4 ) } ;
325328 assert ! ( table. desc_addr( 3 ) . is_some( ) ) ;
326329 assert ! ( table. desc_addr( 4 ) . is_none( ) ) ;
327330 }
You can’t perform that action at this time.
0 commit comments