Skip to content

Commit 7af6491

Browse files
committed
fixup! Allow the guest to manage its own stack
Add more comments on new architecture-specific code Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
1 parent 002d18d commit 7af6491

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • src/hyperlight_guest_bin/src/arch/amd64

src/hyperlight_guest_bin/src/arch/amd64/init.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ unsafe fn init_tss(pc: *mut ProcCtrl) {
104104
}
105105
}
106106

107+
/// To initialise the main stack, we just pre-emptively map the first
108+
/// page of it.
107109
unsafe fn init_stack() -> u64 {
108110
use hyperlight_guest::layout::MAIN_STACK_TOP_GVA;
109111
let stack_top_page_base = (MAIN_STACK_TOP_GVA - 1) & !0xfff;
@@ -122,11 +124,18 @@ unsafe fn init_stack() -> u64 {
122124
#[unsafe(no_mangle)]
123125
pub extern "C" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_level: u64) {
124126
unsafe {
127+
// Allocate a VA for processor control structures which must
128+
// survive snapshotting at the same VA.
125129
let pc = ProcCtrl::init();
130+
126131
init_gdt(pc);
127132
init_tss(pc);
128133
init_idt(pc);
129134
let stack_top = init_stack();
135+
136+
// Architecture early init is complete! We pivot now to
137+
// executing on the main stack, and jump into generic
138+
// initialisation code in lib.rs
130139
pivot_stack(peb_address, seed, ops, max_log_level, stack_top);
131140
}
132141
}

0 commit comments

Comments
 (0)