diff --git a/src/arch/x86/init.s b/src/arch/x86/init.s index e10d4be..7ed3771 100644 --- a/src/arch/x86/init.s +++ b/src/arch/x86/init.s @@ -7,7 +7,6 @@ //! * eax: stack pointer //! * ebx: function pointer //! * ecx: data pointer -//! * edx: stack limit //! //! return values: //! * eax: new stack pointer @@ -15,18 +14,15 @@ // switch to the fresh stack xchg %esp, %eax -// save the data pointer, function pointer, and stack limit, respectively +// save the data pointer and the function pointer, respectively pushl %ecx pushl %ebx -pushl %edx // save the return address, control flow continues at label 1 call 1f // we arrive here once this context is reactivated (see swap.s) -// restore the stack limit, data pointer, and function pointer, respectively -// TODO: this stack limit location is specific to Linux/FreeBSD. -popl %gs:0x30 +// restore the function pointer (the data pointer is the first argument, which lives at the top of the stack) popl %eax // initialise the frame pointer diff --git a/src/arch/x86/mod.rs b/src/arch/x86/mod.rs index e5ab7b3..850f776 100644 --- a/src/arch/x86/mod.rs +++ b/src/arch/x86/mod.rs @@ -18,7 +18,6 @@ impl Registers { #[inline] pub unsafe fn new(stack: &mut S, f: F) -> Registers where S: Stack, F: FnOnce() -> Void { - let sp_limit = stack.limit(); let mut sp = stack.top() as *mut usize; let f_ptr = push(&mut sp, f); @@ -26,8 +25,7 @@ impl Registers { : "={eax}"(sp) : "{eax}" (sp), "{ebx}" (rust_trampoline::), - "{ecx}" (f_ptr), - "{edx}" (sp_limit) + "{ecx}" (f_ptr) : : "volatile"); diff --git a/src/arch/x86/swap.s b/src/arch/x86/swap.s index bee1140..baca48a 100644 --- a/src/arch/x86/swap.s +++ b/src/arch/x86/swap.s @@ -6,19 +6,15 @@ //! arguments: //! * eax: stack pointer pointer -// save the Rust stack limit and the frame pointer, respectively -// TODO: this stack limit location is specific to Linux/FreeBSD. -pushl %gs:0x30 +// save the frame pointer pushl %ebp // save the return address to the stack, control flow continues at label 1 call 1f // we arrive here once this context is reactivated -// restore the frame pointer and the Rust stack limit, respectively +// restore the frame pointer popl %ebp -// TODO: this stack limit location is specific to Linux/FreeBSD. -popl %gs:0x30 // and we merrily go on our way, back into Rust-land jmp 2f diff --git a/src/arch/x86_64/init.s b/src/arch/x86_64/init.s index 7faa2e5..7f3983c 100644 --- a/src/arch/x86_64/init.s +++ b/src/arch/x86_64/init.s @@ -7,7 +7,6 @@ //! * rdi: stack pointer //! * rsi: function pointer //! * rdx: data pointer -//! * rcx: stack limit //! //! return values: //! * rdi: new stack pointer @@ -15,17 +14,15 @@ // switch to the fresh stack xchg %rsp, %rdi -// save the function pointer, data pointer, and stack limit, respectively +// save the function pointer the data pointer, respectively pushq %rsi pushq %rdx -pushq %rcx // save the return address, control flow continues at label 1 call 1f // we arrive here once this context is reactivated (see swap.s) -// restore the stack limit, data pointer, and function pointer, respectively -popq %fs:0x70 +// restore the data pointer and the function pointer, respectively popq %rdi popq %rax diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs index 157b843..b3fd228 100644 --- a/src/arch/x86_64/mod.rs +++ b/src/arch/x86_64/mod.rs @@ -17,7 +17,6 @@ impl Registers { #[inline] pub unsafe fn new(stack: &mut S, f: F) -> Registers where S: Stack, F: FnOnce() -> Void { - let sp_limit = stack.limit(); let mut sp = stack.top() as *mut usize; let f_ptr = push(&mut sp, f); @@ -25,8 +24,7 @@ impl Registers { : "={rdi}"(sp) : "{rdi}" (sp), "{rsi}" (rust_trampoline::), - "{rdx}" (f_ptr), - "{rcx}" (sp_limit) + "{rdx}" (f_ptr) : : "volatile"); diff --git a/src/arch/x86_64/swap.s b/src/arch/x86_64/swap.s index 19d958f..a4270a9 100644 --- a/src/arch/x86_64/swap.s +++ b/src/arch/x86_64/swap.s @@ -9,17 +9,15 @@ // make sure we leave the red zone alone sub $$128, %rsp -// save the Rust stack limit and the frame pointer, respectively -pushq %fs:0x70 +// save the frame pointer pushq %rbp // save the return address to the stack, control flow continues at label 1 call 1f // we arrive here once this context is reactivated -// restore the frame pointer and the Rust stack limit, respectively +// restore the frame pointer popq %rbp -popq %fs:0x70 // give back the red zone add $$128, %rsp