Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356685
b: refs/heads/master
c: 1e974c2
h: refs/heads/master
i:
  356683: dd0b793
v: v3
  • Loading branch information
Al Viro committed Feb 3, 2013
1 parent ed63dec commit aa70719
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b0375744f1c74b39a2677fc29045ad1cb6f4c6cd
refs/heads/master: 1e974c21661db89b30eb13040fc9ab99a83b6492
3 changes: 0 additions & 3 deletions trunk/arch/h8300/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ config H8300
select GENERIC_IRQ_SHOW
select GENERIC_CPU_DEVICES
select MODULES_USE_ELF_RELA
select GENERIC_SIGALTSTACK
select OLD_SIGSUSPEND3
select OLD_SIGACTION

config SYMBOL_PREFIX
string
Expand Down
7 changes: 7 additions & 0 deletions trunk/arch/h8300/include/asm/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;

struct old_sigaction {
__sighandler_t sa_handler;
old_sigset_t sa_mask;
unsigned long sa_flags;
void (*sa_restorer)(void);
};

#define __ARCH_HAS_SA_RESTORER

#include <asm/sigcontext.h>
Expand Down
72 changes: 64 additions & 8 deletions trunk/arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,56 @@
#include <asm/traps.h>
#include <asm/ucontext.h>

/*
* Atomically swap in the new signal mask, and wait for a signal.
*/
asmlinkage int
sys_sigsuspend(int unused1, int unused2, old_sigset_t mask)
{
sigset_t blocked;
siginitset(&blocked, mask);
return sigsuspend(&blocked);
}

asmlinkage int
sys_sigaction(int sig, const struct old_sigaction *act,
struct old_sigaction *oact)
{
struct k_sigaction new_ka, old_ka;
int ret;

if (act) {
old_sigset_t mask;
if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(mask, &act->sa_mask))
return -EFAULT;
siginitset(&new_ka.sa.sa_mask, mask);
}

ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);

if (!ret && oact) {
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
return -EFAULT;
}

return ret;
}

asmlinkage int
sys_sigaltstack(const stack_t *uss, stack_t *uoss)
{
return do_sigaltstack(uss, uoss, rdusp());
}


/*
* Do a signal return; undo the signal stack.
*
Expand Down Expand Up @@ -86,9 +136,9 @@ struct rt_sigframe
} __attribute__((aligned(2),packed));

static inline int
restore_sigcontext(struct sigcontext *usc, int *pd0)
restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc,
int *pd0)
{
struct pt_regs *regs = current_pt_regs();
int err = 0;
unsigned int ccr;
unsigned int usp;
Expand Down Expand Up @@ -117,8 +167,9 @@ restore_sigcontext(struct sigcontext *usc, int *pd0)
return err;
}

asmlinkage int sys_sigreturn(void)
asmlinkage int do_sigreturn(unsigned long __unused,...)
{
struct pt_regs *regs = (struct pt_regs *) (&__unused - 1);
unsigned long usp = rdusp();
struct sigframe *frame = (struct sigframe *)(usp - 4);
sigset_t set;
Expand All @@ -134,7 +185,7 @@ asmlinkage int sys_sigreturn(void)

set_current_blocked(&set);

if (restore_sigcontext(&frame->sc, &er0))
if (restore_sigcontext(regs, &frame->sc, &er0))
goto badframe;
return er0;

Expand All @@ -143,8 +194,9 @@ asmlinkage int sys_sigreturn(void)
return 0;
}

asmlinkage int sys_rt_sigreturn(void)
asmlinkage int do_rt_sigreturn(unsigned long __unused,...)
{
struct pt_regs *regs = (struct pt_regs *) &__unused;
unsigned long usp = rdusp();
struct rt_sigframe *frame = (struct rt_sigframe *)(usp - 4);
sigset_t set;
Expand All @@ -157,10 +209,10 @@ asmlinkage int sys_rt_sigreturn(void)

set_current_blocked(&set);

if (restore_sigcontext(&frame->uc.uc_mcontext, &er0))
if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &er0))
goto badframe;

if (restore_altstack(&frame->uc.uc_stack))
if (do_sigaltstack(&frame->uc.uc_stack, NULL, usp) == -EFAULT)
goto badframe;

return er0;
Expand Down Expand Up @@ -306,7 +358,11 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
/* Create the ucontext. */
err |= __put_user(0, &frame->uc.uc_flags);
err |= __put_user(0, &frame->uc.uc_link);
err |= __save_altstack(&frame->uc.uc_stack, rdusp());
err |= __put_user((void *)current->sas_ss_sp,
&frame->uc.uc_stack.ss_sp);
err |= __put_user(sas_ss_flags(rdusp()),
&frame->uc.uc_stack.ss_flags);
err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
if (err)
Expand Down
15 changes: 15 additions & 0 deletions trunk/arch/h8300/kernel/syscalls.S
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,18 @@ SYMBOL_NAME_LABEL(sys_call_table)
.long SYMBOL_NAME(sys_getcpu)
.long SYMBOL_NAME(sys_ni_syscall) /* sys_epoll_pwait */
.long SYMBOL_NAME(sys_setns) /* 320 */

.macro call_sp addr
mov.l #SYMBOL_NAME(\addr),er6
bra SYMBOL_NAME(syscall_trampoline):8
.endm

SYMBOL_NAME_LABEL(sys_sigreturn)
call_sp do_sigreturn

SYMBOL_NAME_LABEL(sys_rt_sigreturn)
call_sp do_rt_sigreturn

SYMBOL_NAME_LABEL(syscall_trampoline)
mov.l sp,er0
jmp @er6
1 change: 1 addition & 0 deletions trunk/arch/hexagon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ config HEXAGON
select GENERIC_CLOCKEVENTS
select GENERIC_CLOCKEVENTS_BROADCAST
select MODULES_USE_ELF_RELA
select GENERIC_SIGALTSTACK
---help---
Qualcomm Hexagon is a processor architecture designed for high
performance and low power across a wide variety of applications.
Expand Down
15 changes: 1 addition & 14 deletions trunk/arch/hexagon/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,6 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
/*
* Architecture-specific wrappers for signal-related system calls
*/
asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
{
struct pt_regs *regs = current_pt_regs();

return do_sigaltstack(uss, uoss, regs->r29);
}

asmlinkage int sys_rt_sigreturn(void)
{
Expand Down Expand Up @@ -288,14 +282,7 @@ asmlinkage int sys_rt_sigreturn(void)
*/
regs->syscall_nr = __NR_rt_sigreturn;

/*
* If we were meticulous, we'd only call this if we knew that
* we were actually going to use an alternate stack, and we'd
* consider any error to be fatal. What we do here, in common
* with many other architectures, is call it blindly and only
* consider the -EFAULT return case to be proof of a problem.
*/
if (do_sigaltstack(&frame->uc.uc_stack, NULL, pt_psp(regs)) == -EFAULT)
if (restore_altstack(&frame->uc.uc_stack))
goto badframe;

return 0;
Expand Down

0 comments on commit aa70719

Please sign in to comment.