@@ -23,6 +23,7 @@ use crate::protocol::HCL_VMSA_PAGE_OFFSET;
2323use crate :: protocol:: MSHV_APIC_PAGE_OFFSET ;
2424use crate :: protocol:: hcl_intr_offload_flags;
2525use crate :: protocol:: hcl_run;
26+ use bitvec:: vec:: BitVec ;
2627use deferred:: RegisteredDeferredActions ;
2728use deferred:: push_deferred_action;
2829use deferred:: register_deferred_actions;
@@ -3231,22 +3232,27 @@ impl Hcl {
32313232 }
32323233 }
32333234
3235+ /// Causes the specified CPUs to be woken out of a lower VTL.
32343236 pub fn kick_cpus (
32353237 & self ,
32363238 cpus : impl IntoIterator < Item = u32 > ,
32373239 cancel_run : bool ,
32383240 wait_for_other_cpus : bool ,
32393241 ) {
3240- let cpu_bitmap = cpus. into_iter ( ) . fold ( 0u64 , |bitmap, cpu| bitmap | 1 << cpu) ;
3242+ let mut cpu_bitmap: BitVec < u8 > = BitVec :: from_vec ( vec ! [ 0 ; self . vps. len( ) . div_ceil( 8 ) ] ) ;
3243+ for cpu in cpus {
3244+ cpu_bitmap. set ( cpu as usize , true ) ;
3245+ }
32413246
32423247 let data = protocol:: hcl_kick_cpus {
3243- len : size_of_val ( & cpu_bitmap) as u64 ,
3244- cpu_mask : cpu_bitmap. as_bytes ( ) . as_ptr ( ) ,
3248+ len : cpu_bitmap. len ( ) as u64 ,
3249+ cpu_mask : cpu_bitmap. as_bitptr ( ) . pointer ( ) ,
32453250 flags : protocol:: hcl_kick_cpus_flags:: new ( )
32463251 . with_cancel_run ( cancel_run)
32473252 . with_wait_for_other_cpus ( wait_for_other_cpus) ,
32483253 } ;
32493254
3255+ // SAFETY: ioctl has no prerequisites.
32503256 unsafe {
32513257 hcl_kickcpus ( self . mshv_vtl . file . as_raw_fd ( ) , & data) . expect ( "should always succeed" ) ;
32523258 }
0 commit comments