Skip to content
Snippets Groups Projects
Verified Commit d6588668 authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Fix pre-Rust part of trampoline!.

parent a1e1a159
No related branches found
No related tags found
1 merge request!480Refactor redox runtime and impl signals in userspace
...@@ -135,30 +135,37 @@ asmfunction!(__relibc_internal_sigentry: [" ...@@ -135,30 +135,37 @@ asmfunction!(__relibc_internal_sigentry: ["
// First, select signal, always pick first available bit // First, select signal, always pick first available bit
// Read first signal word // Read first signal word
mov rdx, fs:[{tcb_sc_off} + {sc_word}] mov rax, fs:[{tcb_sc_off} + {sc_word}]
mov rcx, rdx mov rcx, rax
shr rcx, 32 shr rcx, 32
and edx, ecx and eax, ecx
and edx, {SIGW0_PENDING_MASK} and eax, {SIGW0_PENDING_MASK}
bsf edx, edx bsf eax, eax
jnz 2f jnz 2f
// Read second signal word // Read second signal word
mov rdx, fs:[{tcb_sc_off} + {sc_word} + 8] mov rax, fs:[{tcb_sc_off} + {sc_word} + 8]
mov rcx, rdx mov rcx, rax
shr rcx, 32 shr rcx, 32
and edx, ecx and eax, ecx
and edx, {SIGW1_PENDING_MASK} and eax, {SIGW1_PENDING_MASK}
bsf edx, edx bsf eax, eax
jnz 4f jnz 4f
add edx, 32 add eax, 32
2: 2:
// By now we have selected a signal, stored in edx (6-bit). We now need to choose whether or // By now we have selected a signal, stored in eax (6-bit). We now need to choose whether or
// not to switch to the alternate signal stack. If SA_ONSTACK is clear for this signal, then // not to switch to the alternate signal stack. If SA_ONSTACK is clear for this signal, then
// skip the sigaltstack logic. // skip the sigaltstack logic.
bt fs:[{tcb_sa_off} + {sa_onstack}], edx bt fs:[{tcb_sa_off} + {sa_onstack}], edx
jc 3f jc 3f
// Otherwise, the altstack is already active. The sigaltstack being disabled, is equivalent
// to setting 'top' to usize::MAX and 'bottom' to 0.
sub rsp, {REDZONE_SIZE}
and rsp, -{STACK_ALIGN}
jmp 4f
3:
// If current RSP is above altstack region, switch to altstack // If current RSP is above altstack region, switch to altstack
mov rdx, fs:[{tcb_sa_off} + {sa_altstack_top}] mov rdx, fs:[{tcb_sa_off} + {sa_altstack_top}]
cmp rdx, rsp cmp rdx, rsp
...@@ -168,11 +175,9 @@ asmfunction!(__relibc_internal_sigentry: [" ...@@ -168,11 +175,9 @@ asmfunction!(__relibc_internal_sigentry: ["
mov rdx, fs:[{tcb_sa_off} + {sa_altstack_bottom}] mov rdx, fs:[{tcb_sa_off} + {sa_altstack_bottom}]
cmp rdx, rsp cmp rdx, rsp
cmovbe rsp, rdx cmovbe rsp, rdx
3:
// Otherwise, the altstack is already active. The sigaltstack being disabled, is equivalent .p2align 4
// to setting 'top' to usize::MAX and 'bottom' to 0. 4:
//
// Now that we have a stack, we can finally start initializing the signal stack! // Now that we have a stack, we can finally start initializing the signal stack!
push 0 // SS push 0 // SS
...@@ -274,6 +279,8 @@ asmfunction!(__relibc_internal_sigentry: [" ...@@ -274,6 +279,8 @@ asmfunction!(__relibc_internal_sigentry: ["
SIGW0_TSTP_IS_STOP_BIT | SIGW0_TTIN_IS_STOP_BIT | SIGW0_TTOU_IS_STOP_BIT | SIGW0_NOCLDSTOP_BIT | SIGW0_UNUSED1 | SIGW0_UNUSED2 SIGW0_TSTP_IS_STOP_BIT | SIGW0_TTIN_IS_STOP_BIT | SIGW0_TTOU_IS_STOP_BIT | SIGW0_NOCLDSTOP_BIT | SIGW0_UNUSED1 | SIGW0_UNUSED2
), ),
SIGW1_PENDING_MASK = const !0, SIGW1_PENDING_MASK = const !0,
REDZONE_SIZE = const 128,
STACK_ALIGN = const 64, // if xsave is used
]); ]);
static SUPPORTS_XSAVE: AtomicU8 = AtomicU8::new(0); // FIXME static SUPPORTS_XSAVE: AtomicU8 = AtomicU8::new(1); // FIXME
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment