Skip to content

Commit ef6485a

Browse files
committed
fix: use scratch base GPA instead of scratch size in page table walker
The access_gpa and SharedMemoryPageTableBuffer::new functions now take a scratch_base_gpa (u64) instead of scratch_size (usize). Update the read_guest_memory_by_gva caller to pass the correct value from layout.get_scratch_base_gpa().
1 parent b961eb1 commit ef6485a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • src/hyperlight_host/src/mem

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ impl SandboxMemoryManager<HostSharedMemory> {
435435

436436
use crate::sandbox::snapshot::{SharedMemoryPageTableBuffer, access_gpa};
437437

438-
let scratch_size = self.scratch_mem.mem_size();
438+
let scratch_base_gpa = self.layout.get_scratch_base_gpa();
439439

440440
self.shared_mem.with_exclusivity(|snap| {
441441
self.scratch_mem.with_exclusivity(|scratch| {
442-
let pt_buf = SharedMemoryPageTableBuffer::new(snap, scratch, scratch_size, root_pt);
442+
let pt_buf = SharedMemoryPageTableBuffer::new(snap, scratch, scratch_base_gpa, root_pt);
443443

444444
// Walk page tables to get all mappings that cover the GVA range
445445
let mappings: Vec<_> = unsafe {
@@ -479,7 +479,7 @@ impl SandboxMemoryManager<HostSharedMemory> {
479479

480480
// Translate the GPA to host memory
481481
let gpa = mapping.phys_base + page_offset as u64;
482-
let (mem, offset) = access_gpa(snap, scratch, scratch_size, gpa)
482+
let (mem, offset) = access_gpa(snap, scratch, scratch_base_gpa, gpa)
483483
.ok_or_else(|| {
484484
new_error!(
485485
"Failed to resolve GPA {:#x} to host memory (GVA {:#x})",

0 commit comments

Comments
 (0)