Skip to content

Commit b56fa68

Browse files
committed
fix: run cargo fmt
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
1 parent 14ee7bc commit b56fa68

4 files changed

Lines changed: 32 additions & 25 deletions

File tree

src/hyperlight_common/src/arch/amd64/vmem.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,8 @@ pub unsafe fn walk_va_spaces<Op: TableReadOps>(
282282
)> {
283283
use ::alloc::vec::Vec;
284284

285-
let mut out: Vec<(
286-
crate::vmem::SpaceId,
287-
Vec<crate::vmem::SpaceAwareMapping>,
288-
)> = Vec::with_capacity(roots.len());
285+
let mut out: Vec<(crate::vmem::SpaceId, Vec<crate::vmem::SpaceAwareMapping>)> =
286+
Vec::with_capacity(roots.len());
289287

290288
let addr = address & ((1u64 << VA_BITS) - 1);
291289
let vmin = addr & !(PAGE_SIZE as u64 - 1);

src/hyperlight_common/src/arch/i686/vmem.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,12 @@ pub unsafe fn space_aware_map<Op: TableOps>(
346346

347347
let new_pde: u64 = their_pt_pa | (their_pde & !PTE_ADDR_MASK) | PAGE_PRESENT;
348348
unsafe {
349-
write_entry_updating(op, Op::TableMovability::root_update_parent(), our_pde_ptr, new_pde);
349+
write_entry_updating(
350+
op,
351+
Op::TableMovability::root_update_parent(),
352+
our_pde_ptr,
353+
new_pde,
354+
);
350355
}
351356
}
352357

src/hyperlight_common/src/vmem.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,22 @@ pub enum SpaceAwareMapping {
576576
AnotherSpace(SpaceReferenceMapping),
577577
}
578578

579+
/// Counterpart of [`walk_va_spaces`]'s `AnotherSpace` entries on the
580+
/// write side: installs a link in `op`'s root PT tree at `ref_map.our_va`
581+
/// that points at whatever intermediate table the owning space ended
582+
/// up with at `ref_map.their_va` (in `built_roots[ref_map.space]`).
583+
///
584+
/// Callers must process [`SpaceAwareMapping`]s in the order returned
585+
/// by `walk_va_spaces`, populating `built_roots` with each space's
586+
/// rebuilt root PA before moving on to the next space — that way, by
587+
/// the time we see an `AnotherSpace` entry, the owning space's
588+
/// rebuilt root is guaranteed to be in `built_roots`.
589+
///
590+
/// # Safety
591+
/// Same invariants as [`map`]: the caller owns the concurrency story
592+
/// around the page tables being written, and must invalidate TLBs
593+
/// afterwards if they were live.
594+
pub use arch::space_aware_map;
579595
/// Walk multiple page-table roots together, emitting either a normal
580596
/// leaf mapping (`ThisSpace`) or a reference to an alias that was
581597
/// already seen via an earlier root (`AnotherSpace`).
@@ -597,20 +613,3 @@ pub enum SpaceAwareMapping {
597613
/// Same invariants as [`virt_to_phys`]. Callers must ensure the page
598614
/// tables are not being mutated concurrently.
599615
pub use arch::walk_va_spaces;
600-
601-
/// Counterpart of [`walk_va_spaces`]'s `AnotherSpace` entries on the
602-
/// write side: installs a link in `op`'s root PT tree at `ref_map.our_va`
603-
/// that points at whatever intermediate table the owning space ended
604-
/// up with at `ref_map.their_va` (in `built_roots[ref_map.space]`).
605-
///
606-
/// Callers must process [`SpaceAwareMapping`]s in the order returned
607-
/// by `walk_va_spaces`, populating `built_roots` with each space's
608-
/// rebuilt root PA before moving on to the next space — that way, by
609-
/// the time we see an `AnotherSpace` entry, the owning space's
610-
/// rebuilt root is guaranteed to be in `built_roots`.
611-
///
612-
/// # Safety
613-
/// Same invariants as [`map`]: the caller owns the concurrency story
614-
/// around the page tables being written, and must invalidate TLBs
615-
/// afterwards if they were live.
616-
pub use arch::space_aware_map;

src/hyperlight_host/src/sandbox/snapshot.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
2020
use hyperlight_common::layout::{scratch_base_gpa, scratch_base_gva};
2121
use hyperlight_common::vmem;
2222
use hyperlight_common::vmem::{
23-
BasicMapping, CowMapping, Mapping, MappingKind, PAGE_SIZE, SpaceAwareMapping, SpaceId,
24-
TableOps,
23+
BasicMapping, CowMapping, Mapping, MappingKind, PAGE_SIZE, SpaceAwareMapping, SpaceId, TableOps,
2524
};
2625
use tracing::{Span, instrument};
2726

@@ -495,7 +494,13 @@ impl Snapshot {
495494
continue;
496495
}
497496
let Some(contents) = (unsafe {
498-
guest_page(snap_c, scratch_c, &regions, layout, mapping.phys_base)
497+
guest_page(
498+
snap_c,
499+
scratch_c,
500+
&regions,
501+
layout,
502+
mapping.phys_base,
503+
)
499504
}) else {
500505
continue;
501506
};

0 commit comments

Comments
 (0)