Skip to content

Commit 0244efc

Browse files
committed
fix: speculative fix for CI failure
Synchronize the instruction cache before running the TLBI trampoline. Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
1 parent 9b9389c commit 0244efc

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎src/hyperlight_host/src/hypervisor/virtual_machine/hvf/bindings.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright 2025 The Hyperlight Authors.
33

44
#include <Hypervisor/Hypervisor.h>
5+
#include <libkern/OSCacheControl.h>
56

67
hv_return_t
78
hv_vcpu_get_simd_fp_reg_rsabi(hv_vcpu_t vcpu, hv_simd_fp_reg_t reg, char *val);

‎src/hyperlight_host/src/hypervisor/virtual_machine/hvf/mod.rs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ struct TlbiRegion {
764764
insn_memory: ReadonlySharedMemory,
765765
}
766766
impl TlbiRegion {
767+
/// Prepare the TLB-flush instructions for execution on any vCPU.
767768
fn new() -> Result<Self, SharedMemoryError> {
768769
let mut bytes = vec![0; page_size::get()];
769770
bytes[0..20].copy_from_slice(&[
@@ -773,9 +774,18 @@ impl TlbiRegion {
773774
0xdf, 0x3f, 0x03, 0xd5, // isb sy
774775
0x02, 0x00, 0x00, 0xd4, // hvc #0
775776
]);
776-
Ok(Self {
777-
insn_memory: ReadonlySharedMemory::from_bytes(&bytes, page_size::get())?,
778-
})
777+
let insn_memory = ReadonlySharedMemory::from_bytes(&bytes, page_size::get())?;
778+
let instructions = insn_memory.as_slice();
779+
780+
// SAFETY: The range is a live mapping. Cache maintenance completes before guest execution.
781+
unsafe {
782+
bindings::sys_icache_invalidate(
783+
instructions.as_ptr().cast_mut().cast(),
784+
instructions.len(),
785+
);
786+
}
787+
788+
Ok(Self { insn_memory })
779789
}
780790
}
781791
impl From<&TlbiRegion> for MemoryRegion {

0 commit comments

Comments
 (0)