From d0db6a1ce07fcac9f18f85e9e12211597a3547cd Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 1 Aug 2024 20:25:20 +0200 Subject: [PATCH] Fix i686. --- redox-rt/src/arch/i686.rs | 19 +++++++------------ redox-rt/src/arch/x86_64.rs | 2 +- redox-rt/src/signal.rs | 2 +- src/platform/redox/signal.rs | 5 +++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/redox-rt/src/arch/i686.rs b/redox-rt/src/arch/i686.rs index 67213b982..9bf7b73ff 100644 --- a/redox-rt/src/arch/i686.rs +++ b/redox-rt/src/arch/i686.rs @@ -22,7 +22,7 @@ pub struct SigArea { pub tmp_eax: usize, pub tmp_ecx: usize, pub tmp_edx: usize, - pub tmp_ptr: usize, + pub tmp_inf: RtSigInfo, pub pctl: usize, // TODO: reference pctl directly pub disable_signals_depth: u64, pub last_sig_was_restart: bool, @@ -83,11 +83,7 @@ unsafe extern "cdecl" fn fork_impl(initial_rsp: *mut usize) -> usize { unsafe extern "cdecl" fn child_hook(cur_filetable_fd: usize, new_pid_fd: usize) { let _ = syscall::close(cur_filetable_fd); - // TODO: Currently pidfd == threadfd, but this will not be the case later. - RtTcb::current() - .thr_fd - .get() - .write(Some(FdGuard::new(new_pid_fd))); + crate::child_hook_common(FdGuard::new(new_pid_fd)); } asmfunction!(__relibc_internal_fork_wrapper -> usize: [" @@ -176,7 +172,7 @@ asmfunction!(__relibc_internal_sigentry: [" lea ecx, [eax+32] mov eax, {SYS_SIGDEQUEUE} mov edx, gs:[0] - add edx, {tcb_sa_off} + {sa_tmp_ptr} + add edx, {tcb_sa_off} + {sa_tmp_inf} int 0x80 mov ebx, edx test eax, eax @@ -221,15 +217,14 @@ asmfunction!(__relibc_internal_sigentry: [" sub esp, 2 * 4 + 29 * 16 fxsave [esp] - push eax - push dword ptr gs:[{tcb_sa_off} + {sa_tmp_ptr}] - sub esp, 24 + mov [esp - 4], eax + sub esp, 48 mov ecx, esp call {inner} fxrstor [esp + 32] - add esp, 32 + 29 * 16 + 2 * 4 + add esp, 48 + 29 * 16 + 2 * 4 pop ebp pop esi @@ -274,7 +269,7 @@ __relibc_internal_sigentry_crit_third: sa_tmp_eax = const offset_of!(SigArea, tmp_eax), sa_tmp_ecx = const offset_of!(SigArea, tmp_ecx), sa_tmp_edx = const offset_of!(SigArea, tmp_edx), - sa_tmp_ptr = const offset_of!(SigArea, tmp_ptr), + sa_tmp_inf = const offset_of!(SigArea, tmp_inf), sa_altstack_top = const offset_of!(SigArea, altstack_top), sa_altstack_bottom = const offset_of!(SigArea, altstack_bottom), sa_pctl = const offset_of!(SigArea, pctl), diff --git a/redox-rt/src/arch/x86_64.rs b/redox-rt/src/arch/x86_64.rs index 6b9849e6c..bb757638b 100644 --- a/redox-rt/src/arch/x86_64.rs +++ b/redox-rt/src/arch/x86_64.rs @@ -298,7 +298,7 @@ asmfunction!(__relibc_internal_sigentry: [" vextractf128 [rsp + 16], ymm14, 1 vextractf128 [rsp], ymm15, 1 5: - mov [rsp - 8], eax + mov [rsp - 4], eax sub rsp, 64 // alloc space for ucontext fields mov rdi, rsp diff --git a/redox-rt/src/signal.rs b/redox-rt/src/signal.rs index 3573b0326..83768a296 100644 --- a/redox-rt/src/signal.rs +++ b/redox-rt/src/signal.rs @@ -37,8 +37,8 @@ pub struct SigStack { pub old_stack: PosixStackt, pub old_mask: u64, pub(crate) sival: usize, - pub(crate) sig_num: u32, pub(crate) sig_code: u32, + pub(crate) sig_num: u32, // x86_64: 864 bytes // i686: 512 bytes diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index abcb486ce..367c49bd4 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -28,13 +28,14 @@ pub struct ucontext_t { _pad: [usize; 1], // pad from 7*8 to 64 #[cfg(target_arch = "x86")] - _pad: [usize; 0], // don't pad from 8*4 + _pad: [usize; 3], // pad from 9*4 to 12*4 pub uc_link: *mut ucontext_t, pub uc_stack: stack_t, pub uc_sigmask: sigset_t, _sival: usize, - _signum: usize, + _sigcode: u32, + _signum: u32, pub uc_mcontext: mcontext_t, } -- GitLab