From patchwork Mon Sep 9 21:32:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 2863211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DEF349F485 for ; Mon, 9 Sep 2013 21:39:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3E82203F4 for ; Mon, 9 Sep 2013 21:39:54 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ADE6920270 for ; Mon, 9 Sep 2013 21:39:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJ9BG-0002K7-Pz; Mon, 09 Sep 2013 21:39:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJ9B5-0002VH-4Z; Mon, 09 Sep 2013 21:39:23 +0000 Received: from mail-oa0-x22a.google.com ([2607:f8b0:4003:c02::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJ9B2-0002U9-CV for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2013 21:39:21 +0000 Received: by mail-oa0-f42.google.com with SMTP id n12so7190974oag.29 for ; Mon, 09 Sep 2013 14:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references:to:to:to :to; bh=UTnZzVcoV0OWhYOUQlg4me8CEiFf+0UTCdHjgjfLr8g=; b=d12DxRR2B42Mx3dXpPPKImIrblrXOmczxPBZldsjPCyu6aY6ZfirrOYtq0i2nG9i93 pxyFRbMnZu1qrnrXr1i/n68lN9i/oxWuDfoxX4UrTbSRkRh8sIwyfW+X+2hV8SynT0je ZasvUuiRRzQnC7zZRJTdEkXHonVyrEdKLg71oggG+RsEPBCiCEZAXt5WqoziMlmCEDnk mdHjoFFWWZlc3zSLFPYDgsipN6r8u/mE+R3PwlQZNyfcm2gxOxsorLsvwlhmrbAbh5Ne ydGVHtZeJLojDEhz9iGZdbtUXoeAxM1s5wn5isifE0iVUxt1mmwDb4+YARolaRfBcZ96 bhiA== X-Received: by 10.60.60.5 with SMTP id d5mr12797165oer.0.1378762388864; Mon, 09 Sep 2013 14:33:08 -0700 (PDT) Received: from localhost.localdomain (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id it7sm14983320obb.11.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 09 Sep 2013 14:33:08 -0700 (PDT) Received: from localhost.localdomain (apinskidesktop [127.0.0.1]) by localhost.localdomain (8.14.3/8.14.3/Debian-9.4) with ESMTP id r89LX6It013194 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Mon, 9 Sep 2013 14:33:06 -0700 Received: (from apinski@localhost) by localhost.localdomain (8.14.3/8.14.3/Submit) id r89LX69g013193; Mon, 9 Sep 2013 14:33:06 -0700 From: Andrew Pinski To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] ARM64: Move some signal code to a seperate file to be reused by ILP32. Date: Mon, 9 Sep 2013 14:32:56 -0700 Message-Id: <1378762380-13152-2-git-send-email-apinski@cavium.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1378762380-13152-1-git-send-email-apinski@cavium.com> References: <1378762380-13152-1-git-send-email-apinski@cavium.com> To: Catalin Marinas To: Will Deacon To: linux-arm-kernel@lists.infradead.org To: linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130909_173920_948563_0744106B X-CRM114-Status: GOOD ( 17.47 ) X-Spam-Score: -2.0 (--) Cc: Catalin Marinas , Will Deacon , Andrew Pinski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the ILP32 ABI uses similar signal code as the LP64 ABI, it makes sense to reuse rather than copy the same code. Signed-off-by: Andrew Pinski --- arch/arm64/kernel/signal.c | 170 +------------------------------------------- 1 files changed, 1 insertions(+), 169 deletions(-) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 3fbd848..d97a0c0 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -95,176 +95,8 @@ static int restore_fpsimd_context(struct fpsimd_context __user *ctx) return err ? -EFAULT : 0; } -static int restore_sigframe(struct pt_regs *regs, - struct rt_sigframe __user *sf) -{ - sigset_t set; - int i, err; - struct aux_context __user *aux = - (struct aux_context __user *)sf->uc.uc_mcontext.__reserved; - - err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); - if (err == 0) - set_current_blocked(&set); - - for (i = 0; i < 31; i++) - __get_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], - err); - __get_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); - __get_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); - __get_user_error(regs->pstate, &sf->uc.uc_mcontext.pstate, err); - - /* - * Avoid sys_rt_sigreturn() restarting. - */ - regs->syscallno = ~0UL; - - err |= !valid_user_regs(®s->user_regs); - - if (err == 0) - err |= restore_fpsimd_context(&aux->fpsimd); - - return err; -} - -asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) -{ - struct rt_sigframe __user *frame; - - /* Always make any pending restarted system calls return -EINTR */ - current_thread_info()->restart_block.fn = do_no_restart_syscall; - - /* - * Since we stacked the signal on a 128-bit boundary, then 'sp' should - * be word aligned here. - */ - if (regs->sp & 15) - goto badframe; - - frame = (struct rt_sigframe __user *)regs->sp; - - if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) - goto badframe; - - if (restore_sigframe(regs, frame)) - goto badframe; - - if (restore_altstack(&frame->uc.uc_stack)) - goto badframe; - - return regs->regs[0]; - -badframe: - if (show_unhandled_signals) - pr_info_ratelimited("%s[%d]: bad frame in %s: pc=%08llx sp=%08llx\n", - current->comm, task_pid_nr(current), __func__, - regs->pc, regs->sp); - force_sig(SIGSEGV, current); - return 0; -} - -static int setup_sigframe(struct rt_sigframe __user *sf, - struct pt_regs *regs, sigset_t *set) -{ - int i, err = 0; - struct aux_context __user *aux = - (struct aux_context __user *)sf->uc.uc_mcontext.__reserved; - - /* set up the stack frame for unwinding */ - __put_user_error(regs->regs[29], &sf->fp, err); - __put_user_error(regs->regs[30], &sf->lr, err); - - for (i = 0; i < 31; i++) - __put_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], - err); - __put_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); - __put_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); - __put_user_error(regs->pstate, &sf->uc.uc_mcontext.pstate, err); - - __put_user_error(current->thread.fault_address, &sf->uc.uc_mcontext.fault_address, err); - - err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); - - if (err == 0) - err |= preserve_fpsimd_context(&aux->fpsimd); - - /* set the "end" magic */ - __put_user_error(0, &aux->end.magic, err); - __put_user_error(0, &aux->end.size, err); +#include "signal_template.c" - return err; -} - -static struct rt_sigframe __user *get_sigframe(struct k_sigaction *ka, - struct pt_regs *regs) -{ - unsigned long sp, sp_top; - struct rt_sigframe __user *frame; - - sp = sp_top = regs->sp; - - /* - * This is the X/Open sanctioned signal stack switching. - */ - if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) - sp = sp_top = current->sas_ss_sp + current->sas_ss_size; - - sp = (sp - sizeof(struct rt_sigframe)) & ~15; - frame = (struct rt_sigframe __user *)sp; - - /* - * Check that we can actually write to the signal frame. - */ - if (!access_ok(VERIFY_WRITE, frame, sp_top - sp)) - frame = NULL; - - return frame; -} - -static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, - void __user *frame, int usig) -{ - __sigrestore_t sigtramp; - - regs->regs[0] = usig; - regs->sp = (unsigned long)frame; - regs->regs[29] = regs->sp + offsetof(struct rt_sigframe, fp); - regs->pc = (unsigned long)ka->sa.sa_handler; - - if (ka->sa.sa_flags & SA_RESTORER) - sigtramp = ka->sa.sa_restorer; - else - sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); - - regs->regs[30] = (unsigned long)sigtramp; -} - -static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, - sigset_t *set, struct pt_regs *regs) -{ - struct rt_sigframe __user *frame; - int err = 0; - - frame = get_sigframe(ka, regs); - if (!frame) - return 1; - - __put_user_error(0, &frame->uc.uc_flags, err); - __put_user_error(NULL, &frame->uc.uc_link, err); - - err |= __save_altstack(&frame->uc.uc_stack, regs->sp); - err |= setup_sigframe(frame, regs, set); - if (err == 0) { - setup_return(regs, ka, frame, usig); - if (ka->sa.sa_flags & SA_SIGINFO) { - err |= copy_siginfo_to_user(&frame->info, info); - regs->regs[1] = (unsigned long)&frame->info; - regs->regs[2] = (unsigned long)&frame->uc; - } - } - - return err; -} static void setup_restart_syscall(struct pt_regs *regs) {