linux: implement sigaltstack(2) on arm64
... by making it machine-independent. Reviewed By: dchagin Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D31286
This commit is contained in:
parent
85ae35ef37
commit
30c6d98219
@ -188,37 +188,6 @@ linux_pause(struct thread *td, struct linux_pause_args *args)
|
||||
return (kern_sigsuspend(td, sigmask));
|
||||
}
|
||||
|
||||
int
|
||||
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
||||
{
|
||||
stack_t ss, oss;
|
||||
l_stack_t lss;
|
||||
int error;
|
||||
|
||||
memset(&lss, 0, sizeof(lss));
|
||||
LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss);
|
||||
|
||||
if (uap->uss != NULL) {
|
||||
error = copyin(uap->uss, &lss, sizeof(l_stack_t));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
ss.ss_sp = PTRIN(lss.ss_sp);
|
||||
ss.ss_size = lss.ss_size;
|
||||
ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
|
||||
}
|
||||
error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
|
||||
(uap->uoss != NULL) ? &oss : NULL);
|
||||
if (!error && uap->uoss != NULL) {
|
||||
lss.ss_sp = PTROUT(oss.ss_sp);
|
||||
lss.ss_size = oss.ss_size;
|
||||
lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
|
||||
error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args)
|
||||
{
|
||||
|
@ -549,34 +549,6 @@ linux_pause(struct thread *td, struct linux_pause_args *args)
|
||||
return (kern_sigsuspend(td, sigmask));
|
||||
}
|
||||
|
||||
int
|
||||
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
||||
{
|
||||
stack_t ss, oss;
|
||||
l_stack_t lss;
|
||||
int error;
|
||||
|
||||
if (uap->uss != NULL) {
|
||||
error = copyin(uap->uss, &lss, sizeof(l_stack_t));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
ss.ss_sp = PTRIN(lss.ss_sp);
|
||||
ss.ss_size = lss.ss_size;
|
||||
ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
|
||||
}
|
||||
error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
|
||||
(uap->uoss != NULL) ? &oss : NULL);
|
||||
if (!error && uap->uoss != NULL) {
|
||||
lss.ss_sp = PTROUT(oss.ss_sp);
|
||||
lss.ss_size = oss.ss_size;
|
||||
lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
|
||||
error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_gettimeofday(struct thread *td, struct linux_gettimeofday_args *uap)
|
||||
{
|
||||
|
@ -55,7 +55,6 @@ LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
|
||||
|
||||
/* DTrace probes */
|
||||
LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo);
|
||||
LIN_SDT_PROBE_DEFINE0(machdep, linux_sigaltstack, todo);
|
||||
|
||||
/*
|
||||
* LINUXTODO: deduplicate; linux_execve is common across archs, except that on
|
||||
@ -123,15 +122,6 @@ linux_madvise(struct thread *td, struct linux_madvise_args *uap)
|
||||
return (linux_madvise_common(td, PTROUT(uap->addr), uap->len, uap->behav));
|
||||
}
|
||||
|
||||
/* LINUXTODO: implement arm64 linux_sigaltstack */
|
||||
int
|
||||
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
||||
{
|
||||
|
||||
LIN_SDT_PROBE0(machdep, linux_sigaltstack, todo);
|
||||
return (EDOOFUS);
|
||||
}
|
||||
|
||||
int
|
||||
linux_set_cloned_tls(struct thread *td, void *desc)
|
||||
{
|
||||
|
@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/sx.h>
|
||||
@ -184,6 +185,37 @@ linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa,
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
||||
{
|
||||
stack_t ss, oss;
|
||||
l_stack_t lss;
|
||||
int error;
|
||||
|
||||
memset(&lss, 0, sizeof(lss));
|
||||
LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss);
|
||||
|
||||
if (uap->uss != NULL) {
|
||||
error = copyin(uap->uss, &lss, sizeof(l_stack_t));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
ss.ss_sp = PTRIN(lss.ss_sp);
|
||||
ss.ss_size = lss.ss_size;
|
||||
ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
|
||||
}
|
||||
error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
|
||||
(uap->uoss != NULL) ? &oss : NULL);
|
||||
if (error == 0 && uap->uoss != NULL) {
|
||||
lss.ss_sp = PTROUT(oss.ss_sp);
|
||||
lss.ss_size = oss.ss_size;
|
||||
lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
|
||||
error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
||||
int
|
||||
linux_signal(struct thread *td, struct linux_signal_args *args)
|
||||
|
@ -257,7 +257,7 @@ typedef struct {
|
||||
} l_sigaction_t;
|
||||
|
||||
typedef struct {
|
||||
void *ss_sp;
|
||||
l_uintptr_t ss_sp;
|
||||
l_int ss_flags;
|
||||
l_size_t ss_size;
|
||||
} l_stack_t;
|
||||
|
@ -517,34 +517,6 @@ linux_pause(struct thread *td, struct linux_pause_args *args)
|
||||
return (kern_sigsuspend(td, sigmask));
|
||||
}
|
||||
|
||||
int
|
||||
linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
|
||||
{
|
||||
stack_t ss, oss;
|
||||
l_stack_t lss;
|
||||
int error;
|
||||
|
||||
if (uap->uss != NULL) {
|
||||
error = copyin(uap->uss, &lss, sizeof(l_stack_t));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
ss.ss_sp = lss.ss_sp;
|
||||
ss.ss_size = lss.ss_size;
|
||||
ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
|
||||
}
|
||||
error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
|
||||
(uap->uoss != NULL) ? &oss : NULL);
|
||||
if (!error && uap->uoss != NULL) {
|
||||
lss.ss_sp = oss.ss_sp;
|
||||
lss.ss_size = oss.ss_size;
|
||||
lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
|
||||
error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
|
||||
{
|
||||
|
@ -441,7 +441,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
frame.sf_sc.uc_flags = 0; /* XXX ??? */
|
||||
frame.sf_sc.uc_link = NULL; /* XXX ??? */
|
||||
|
||||
frame.sf_sc.uc_stack.ss_sp = td->td_sigstk.ss_sp;
|
||||
frame.sf_sc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp);
|
||||
frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size;
|
||||
frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
|
||||
? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
|
||||
@ -751,7 +751,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
||||
|
||||
/* Call sigaltstack & ignore results. */
|
||||
lss = &uc.uc_stack;
|
||||
ss.ss_sp = lss->ss_sp;
|
||||
ss.ss_sp = PTRIN(lss->ss_sp);
|
||||
ss.ss_size = lss->ss_size;
|
||||
ss.ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user