Date: Thu, 06 Mar 2014 13:53:49 +0900 From: Takashi Komatsu <komatsu.taka@jp.panasonic.com> To: freebsd-arm <freebsd-arm@freebsd.org> Subject: The arguments of sys_sigreturn Message-ID: <20140306135349.5C75.2910CF64@jp.panasonic.com>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hi,
I have a question about the function of sys_sigreturn.
[sys/arm/arm/machdep.c]
In arm codes, the sys_sigreturn function use sigreturn_args.
I think it has to be used for "struct __ucontext".
But it use "struct sigframe".
In fact, it's called with the argument "sigframe" by other function.
(sys/arm/arm/locore.S: L558)
On the one hand, it's called by the thread library with "ucontext_t".
(lib/libthr/thread/thr_sig.c: L256)
There is collision types.
I attached my patch.
Please review.
Best regards,
Takashi Komatsu
[-- Attachment #2 --]
diff --git a/sys/arm/arm/genassym.c b/sys/arm/arm/genassym.c
index 029529a..e38733b 100644
--- a/sys/arm/arm/genassym.c
+++ b/sys/arm/arm/genassym.c
@@ -109,6 +109,8 @@ ASSYM(TF_PC, offsetof(struct trapframe, tf_pc));
ASSYM(P_PID, offsetof(struct proc, p_pid));
ASSYM(P_FLAG, offsetof(struct proc, p_flag));
+ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
+
#ifdef ARM_TP_ADDRESS
ASSYM(ARM_TP_ADDRESS, ARM_TP_ADDRESS);
ASSYM(ARM_RAS_START, ARM_RAS_START);
diff --git a/sys/arm/arm/locore.S b/sys/arm/arm/locore.S
index 364d19e..90eeeaf 100644
--- a/sys/arm/arm/locore.S
+++ b/sys/arm/arm/locore.S
@@ -557,6 +557,7 @@ END(abort)
ENTRY_NP(sigcode)
mov r0, sp
+ add r0, r0, #SIGF_UC
/*
* Call the sigreturn system call.
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
index 68f4318..35f1432 100644
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -742,28 +742,26 @@ sys_sigreturn(td, uap)
const struct __ucontext *sigcntxp;
} */ *uap;
{
- struct sigframe sf;
- struct trapframe *tf;
+ ucontext_t uc;
int spsr;
if (uap == NULL)
return (EFAULT);
- if (copyin(uap->sigcntxp, &sf, sizeof(sf)))
+ if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
return (EFAULT);
/*
* Make sure the processor mode has not been tampered with and
* interrupts have not been disabled.
*/
- spsr = sf.sf_uc.uc_mcontext.__gregs[_REG_CPSR];
+ spsr = uc.uc_mcontext.__gregs[_REG_CPSR];
if ((spsr & PSR_MODE) != PSR_USR32_MODE ||
(spsr & (I32_bit | F32_bit)) != 0)
return (EINVAL);
/* Restore register context. */
- tf = td->td_frame;
- set_mcontext(td, &sf.sf_uc.uc_mcontext);
+ set_mcontext(td, &uc.uc_mcontext);
/* Restore signal mask. */
- kern_sigprocmask(td, SIG_SETMASK, &sf.sf_uc.uc_sigmask, NULL, 0);
+ kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
return (EJUSTRETURN);
}
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140306135349.5C75.2910CF64>
