You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 117b974
Browse filesBrowse the repository at this point in the historyBrowse files
Make ELF loading respect program header virtual addresses for non-PIE binaries (#1530)
## Summary
For non-PIE (ET_EXEC) ELF binaries, the guest page table now maps the
code region at the ELF's declared virtual address rather than
identity-mapping it at the GPA. This allows statically-linked binaries
with a fixed load address (e.g., `--image-base=0x200000`) to execute
correctly.
## Problem
Previously, Hyperlight assumed code GVA == code GPA (identity mapping).
Non-PIE binaries that declare a non-zero base virtual address (via
program header `p_vaddr`) would triple-fault because the guest CPU
jumped to the ELF's declared entrypoint VA, which wasn't mapped in the
page tables.
## Solution
- Compute `code_virt_base` from the ELF's lowest LOAD segment `p_vaddr`
- For non-PIE (`base_va > 0`): map code at the declared VA in the guest
page tables
- For PIE (`base_va == 0`): preserve existing identity mapping behavior
(with assertion to guard the invariant)
- Compute entrypoint as `code_virt_base + (entrypoint_va - base_va)`
The fix leverages the existing `Mapping` struct's support for `phys_base
!= virt_base` — no changes to the page table code itself.
## Testing
- New `non_pie_guest_hello_world` integration test exercises full guest
lifecycle (init, COW, function call, return value) with a non-PIE
simpleguest built at `--image-base=0x200000`
- All existing PIE guest tests continue to pass (identity mapping
preserved)
- Tested on Windows/WHP and Linux/KVM
## Build infrastructure
- Added `build-rust-guests-non-pie` Justfile targets
- Non-PIE build runs first in `guests` recipe to avoid clobbering normal
guest binaries
- Added `simple_guest_non_pie_as_string()` test helper
Contributes to: #1408
---------
Signed-off-by: cshung <3410332+cshung@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f20a05d-6bee-4e2e-b320-12f8d9759bbc
0 commit comments