There kernel-side signal handler trampoline needs to run in privileged mode

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5751 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-03-17 01:10:23 +00:00
parent b3890db5ce
commit 4ebca78ada
3 changed files with 30 additions and 6 deletions

View file

@ -4342,6 +4342,18 @@
* tools/mkconfig.c: Logic that attempts to suppressed buffered I/O
within the kernel is wrong. sizeof(struct file_struct) must be
the same in both kernel- and user-spaces (2013-03-16).
* arch/arm/src/common/up_pthread_start.c, nuttx/libc/pthread/pthread_startup.c,
* arch/arm/src/common/up_pthread_start.c, libc/pthread/pthread_startup.c,
and related files: Implement switch to user-space and user-space
pthread start-up function (2013-03-16).
pthread start-up function (2013-03-16).
* arch/arm/src/common/up_signal_handler.c, libc/pthread/pthread_startup.c,
and related files: Implement switch to user-space and user-space
pthread start-up function (2013-03-16).
* arch/arm/src/common/up_signal_handler.c, libc/signal/signal_handler.c,
arch/arm/src/armv[6|7]-m/up_svcall.c, arch/arm/include/armv[6|7]-m/svcall.h,
include/nuttx/userspace.h, and sched/sig_deliver.c: Implement switch
to user-space from kernel signal delivery trampoline before calling user-
space signal handler. Return from user-space signal handler using a
system call (2013-03-16).
* arch/arm/src/armv[6|7]-m/up_schedulesigaction.c: Need make sure we are
in kernel mode before switching to kernel-mode signal handler
trampoline.

View file

@ -46,6 +46,7 @@
#include <nuttx/arch.h>
#include "psr.h"
#include "exc_return.h"
#include "os_internal.h"
#include "up_internal.h"
#include "up_arch.h"
@ -159,12 +160,16 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.saved_xpsr = current_regs[REG_XPSR];
/* Then set up to vector to the trampoline with interrupts
* disabled
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
current_regs[REG_PC] = (uint32_t)up_sigdeliver;
current_regs[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
current_regs[REG_XPSR] = ARMV6M_XPSR_T;
#ifdef CONFIG_NUTTX_KERNEL
current_regs[REG_XPSR] = EXC_RETURN_PRIVTHR;
#endif
/* And make sure that the saved context in the TCB
* is the same as the interrupt return context.
@ -193,7 +198,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.saved_xpsr = tcb->xcp.regs[REG_XPSR];
/* Then set up to vector to the trampoline with interrupts
* disabled
* disabled. We must already be in privileged thread mode
* to be here.
*/
tcb->xcp.regs[REG_PC] = (uint32_t)up_sigdeliver;

View file

@ -46,6 +46,7 @@
#include <nuttx/arch.h>
#include "psr.h"
#include "exc_return.h"
#include "os_internal.h"
#include "up_internal.h"
#include "up_arch.h"
@ -163,7 +164,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.saved_xpsr = current_regs[REG_XPSR];
/* Then set up to vector to the trampoline with interrupts
* disabled
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
current_regs[REG_PC] = (uint32_t)up_sigdeliver;
@ -173,6 +175,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
current_regs[REG_PRIMASK] = 1;
#endif
current_regs[REG_XPSR] = ARMV7M_XPSR_T;
#ifdef CONFIG_NUTTX_KERNEL
current_regs[REG_XPSR] = EXC_RETURN_PRIVTHR;
#endif
/* And make sure that the saved context in the TCB
* is the same as the interrupt return context.
@ -205,7 +210,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.saved_xpsr = tcb->xcp.regs[REG_XPSR];
/* Then set up to vector to the trampoline with interrupts
* disabled
* disabled. We must already be in privileged thread mode
* to be here.
*/
tcb->xcp.regs[REG_PC] = (uint32_t)up_sigdeliver;