Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/hyperlight_guest_bin/src/arch/aarch64/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub fn phys_to_virt(gpa: vmem::PhysAddr) -> Option<*mut u8> {
}

pub mod barrier {
use hyperlight_common::vmem;

/// # Architecture-specific (aarch64) notes
///
/// I_WZCBG from [1]:
Expand Down Expand Up @@ -171,4 +173,16 @@ pub mod barrier {
);
}
}

#[inline(always)]
pub fn downgrade_in_place(var: core::ops::Range<vmem::VirtAddr>) {
unsafe {
Comment thread
syntactically marked this conversation as resolved.
Resolved
core::arch::asm!("dsb ish");
// todo: use TLBI RVAE1IS if FEAT_TLBIRANGE is available
for va in var.step_by(vmem::PAGE_SIZE) {
core::arch::asm!("tlbi vae1is, {}", in(reg) va >> 12);
}
core::arch::asm!("dsb ish\nisb");
}
}
}
11 changes: 11 additions & 0 deletions src/hyperlight_guest_bin/src/arch/amd64/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ pub fn phys_to_virt(gpa: vmem::PhysAddr) -> Option<*mut u8> {

/// Barriers that other code may need to use when updating page tables
pub mod barrier {
use hyperlight_common::vmem;

/// Call this function when a virtual address has just been made
/// valid for the first time after the last tlb invalidate that
/// affected it, and it will be used for the first time in the
Expand Down Expand Up @@ -204,4 +206,13 @@ pub mod barrier {
", out("rax") _);
}
}

pub fn downgrade_in_place(var: core::ops::Range<vmem::VirtAddr>) {
unsafe {
Comment thread
syntactically marked this conversation as resolved.
Resolved
// todo: use TLBI RVAE1IS if FEAT_TLBIRANGE is available
for va in var.step_by(vmem::PAGE_SIZE) {
core::arch::asm!("invlpg [{}]", in(reg) va, options(readonly, nostack, preserves_flags));
}
}
}
}
6 changes: 6 additions & 0 deletions src/hyperlight_guest_bin/src/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ mod arch;
pub use arch::{map_region, modify_mapping, phys_to_virt, virt_to_phys};
/// Barriers that other code may need to use when updating page tables
pub mod barrier {
/// Call this function when a virtual address has had its
/// permissions changed in a way that makes previously-valid
/// accesses invalid.
///
/// Range must be page-aligned.
pub use arch::downgrade_in_place;
Comment thread
syntactically marked this conversation as resolved.
Resolved
Comment thread
syntactically marked this conversation as resolved.
Resolved
/// Call this function when a virtual address has just been made
/// valid for the first time after the last tlb invalidate that
/// affected it, and it will be used for the first time in the
Expand Down
Loading