Skip to content

Commit 473aec9

Browse files
committed
more
1 parent 5676c02 commit 473aec9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,6 +2736,7 @@ version = "0.0.0"
27362736
dependencies = [
27372737
"anyhow",
27382738
"bitfield-struct 0.10.1",
2739+
"bitvec",
27392740
"build_rs_guest_arch",
27402741
"fs-err",
27412742
"getrandom 0.3.2",

openhcl/hcl/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ inspect.workspace = true
1818
user_driver.workspace = true
1919

2020
anyhow.workspace = true
21+
bitvec.workspace = true
2122
parking_lot.workspace = true
2223
signal-hook.workspace = true
2324
thiserror.workspace = true

openhcl/hcl/src/ioctl.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::protocol::HCL_VMSA_PAGE_OFFSET;
2323
use crate::protocol::MSHV_APIC_PAGE_OFFSET;
2424
use crate::protocol::hcl_intr_offload_flags;
2525
use crate::protocol::hcl_run;
26+
use bitvec::vec::BitVec;
2627
use deferred::RegisteredDeferredActions;
2728
use deferred::push_deferred_action;
2829
use 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

Comments
 (0)