Skip to content

Commit 22af1e7

Browse files
committed
refactor: address review feedback
Refactor i686 page table code to follow the same architecture-independent API as amd64/aarch64, per reviewer feedback. hyperlight_common changes: - Extract shared page table iterators (modify_ptes, read_pte_if_present, require_pte_exist, write_entry_updating) to vmem.rs with PTE_SHIFT const generic for reuse across architectures. - Implement i686/vmem.rs with proper map()/virt_to_phys() using the shared iterators, replacing stubs and the host-side i686_guest submodule that was in amd64/vmem.rs. - Remove PAGE_USER from pte_for_table (PDEs are supervisor-only by default); user-space PDEs get PAGE_USER via post-processing. - Remove SCRATCH_TOP_PD_ROOTS_* and MAX_PD_ROOTS constants (replaced by set_pt_root_finder callback). hyperlight_host changes: - Unify GuestPageTableBuffer<PTE_BYTES> for both architectures, removing i686_pt::Builder, build_initial_i686_page_tables, and compact_i686_snapshot (~500 lines removed from snapshot.rs). - Add root_offset to GuestPageTableBuffer for targeting per-process PDs, with finalize_multi_root() to replicate kernel PDEs, map scratch, and set PAGE_USER across all roots. - Snapshot::new uses filtered_mappings with root-index tagging for per-process PD isolation in a single pass (no double PT walk). - Add set_pt_root_finder callback on MultiUseSandbox, replacing the scratch-based PD roots bookkeeping. - Add CR0 named constants (CR0_PE, CR0_ET, CR0_WP, CR0_PG). - Add compaction_kind() helper to deduplicate kind conversion. - Add 5 i686 unit tests for map/virt_to_phys. - Detailed comments on separate_pt_bytes explaining the map_file_cow GPA overlap constraint. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 8fcb7ea commit 22af1e7

11 files changed

Lines changed: 1031 additions & 1344 deletions

File tree

src/hyperlight_common/src/arch/aarch64/vmem.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ pub unsafe fn virt_to_phys<'a, Op: TableReadOps + 'a>(
4444
core::iter::empty()
4545
}
4646

47-
pub trait TableMovability<Op: TableReadOps + ?Sized, TableMoveInfo> {}
48-
impl<Op: TableOps<TableMovability = crate::vmem::MayMoveTable>> TableMovability<Op, Op::TableAddr>
47+
impl<Op: TableOps<TableMovability = crate::vmem::MayMoveTable>> crate::vmem::TableMovability<Op>
4948
for crate::vmem::MayMoveTable
5049
{
50+
type RootUpdateParent = crate::vmem::UpdateParentRoot;
51+
fn root_update_parent() -> Self::RootUpdateParent {
52+
crate::vmem::UpdateParentRoot {}
53+
}
54+
}
55+
impl<Op: TableReadOps> crate::vmem::TableMovability<Op> for crate::vmem::MayNotMoveTable {
56+
type RootUpdateParent = crate::vmem::UpdateParentNone;
57+
fn root_update_parent() -> Self::RootUpdateParent {
58+
crate::vmem::UpdateParentNone {}
59+
}
5160
}
52-
impl<Op: TableReadOps> TableMovability<Op, Void> for crate::vmem::MayNotMoveTable {}

0 commit comments

Comments
 (0)