From patchwork Wed Aug 17 11:46:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9285701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C4A2A60459 for ; Wed, 17 Aug 2016 11:57:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B840D290B8 for ; Wed, 17 Aug 2016 11:57:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC673290BF; Wed, 17 Aug 2016 11:57:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E17CF290B8 for ; Wed, 17 Aug 2016 11:57:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZzSZ-0000zx-G7; Wed, 17 Aug 2016 11:56:39 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZzLT-0001A5-RY for linux-arm-kernel@bombadil.infradead.org; Wed, 17 Aug 2016 11:49:20 +0000 Received: from mail-bl2nam02on0074.outbound.protection.outlook.com ([104.47.38.74] helo=NAM02-BL2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZzLS-00031v-E1 for linux-arm-kernel@lists.infradead.org; Wed, 17 Aug 2016 11:49:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hIH2X12BtmEe+3WYKdVXXvu6hL/Etq9POhodmouqOrs=; b=nJvIHgMcAp0lolxPMqe87H4Y/EfT8DOkoGiDwmz0H/umu5bu/hWLyTayZw7DWjUD4yjtY5Fnuhs54my+ciYNV+jujU7gmWCCBF4TS15AeR2H67CBQSk6JkReAdb98oeNjX9EjpMjFA+SlLWrIrjMjlCS058pUXpoUeNE5t5rdNM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by BN4PR07MB2241.namprd07.prod.outlook.com (10.164.63.147) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Wed, 17 Aug 2016 11:48:54 +0000 From: Yury Norov To: , , , , , , Subject: [PATCH 13/18] arm64: signal: share lp64 signal routines to ilp32 Date: Wed, 17 Aug 2016 14:46:38 +0300 Message-ID: <1471434403-25291-14-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471434403-25291-1-git-send-email-ynorov@caviumnetworks.com> References: <1471434403-25291-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR03CA045.eurprd03.prod.outlook.com (10.141.191.173) To BN4PR07MB2241.namprd07.prod.outlook.com (10.164.63.147) X-MS-Office365-Filtering-Correlation-Id: b257fa54-ef6c-430b-3956-08d3c6947755 X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2241; 2:iwcY+FS+TIdEJbvbuLb46tYrIt/NTC6BTfbdov4qZZjVhwfD8SP4VcCINTgGALERfZrl4lqG8hp8d1D0O9DyhchTZ3wQY7j3FH8BX2qdFDZBSQXgsjCrkweUnSyZrydDl4XKkrQDSB0xytOJ8qPwp79c236by9fRRpzGMeuRBHGIRVbcxyJebmg7cchpMRdg; 3:nI8TobtSB87nbFzByJHaxU7P0/0wkcKTujaleOabX3lwmIVQTsmacFr24+iUo9zZPOxW1KEDhH7s4lZ5NOH66fzkR1bVPjcg5t94ikQWQ9vJpYX3r44QfPXtDjJaTV6W X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN4PR07MB2241; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2241; 25:S6p8bCdkcyZIvmbzRGaEZ69/6Bz52A4F9k1hMb0cWjrX8tjN19VRwkGN1sB9pARAurpquarlT3P9/alXWdHJPxJVje6m1d4LqCQYDKxiEUA/xdKmoJoSxNGkUOErqnznlwq+JrloxdIJd39QoWZpnHhhIAb+hZehN29PtbA3sur7nKIKt0hN4ZH4qzRHvhsWqntgRXBSBeh2GYo9wxepcgzMQaruOJ157GAtoF34+cvP881kxpvdE5gr7iHVWUysN+5nRoYHove6yaPqOgGyGCmj+pAlmVw+6KuVIz7ApxpjnbkmPnPNIOEaONwnSgaB/RkiZoXhN+KOr2bwCS0FikslRF9SR9MRIi3oba3NUeGup6dZwcpRPKbYTmaPE7w+e/ij4SMLN0i0zBmTI7OwUP1w7gOou4ViIV6AUo1mjOnxFu/R/9jYY4QLRlGKCuwfKO4sPLzyjtTK5Hs8RFMz6mV2X74kYjeQYqXsuvzf3v1ek6PcovFaCuUKk9gXBxH1Jjafoaw8ZulspufgVzYGicAFw748/hzoPisNunkA1jthcXiFbGYhJjRMpO07wHbrEFufPHyJsvUJ1dP3gsCGkDZJXzAaJayq9zp2wralmvbyubWutAdAsvFKDEyUclqubU/OlGV0FAGOhoi2QH6q36Zbcb+mnbZ2VmPzSWXQQh/D7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zgmkkcqN3Hfy+EUW4JveeJcyagkDg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BN4PR07MB2241; BCL:0; PCL:0; RULEID:; SRVR:BN4PR07MB2241; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2241; 4:GqgEauopNGq9D9u7sMKhAsfDb5kFGg55Vebubwqd8XtvRWNnEFfOplI64AX4JB2bExO5e/qA4DYCEiPp+KZM7x9EQrbNUztFzuG6IQMrqmFwscN2bR6wnt/YdtWk8KUyuM9ICHJFjNwsW/ptep5+dcBwO86NmUrcI6GB6+YmFMmar5enQ4IUjk3sG6sD07jgmru2Pt2XEiKu6cCrvEyH1dG04ztGxxxtU1GBpC6qmgK8HhwiVQumsrRWBqy+CAvkQSS6F48HgXsBJRG4WCkP2U5l/JVgBFGz+sxwmP0CihD4cHmrlR0h0KDxACZbSp+DI6bdAvI+EYT9u7hk+GmAR7Om6j14xusvbHXulPQ+hjvLyz/zN2Ruuff+gF/dUIYYvDinGpXrZ4au9k7S7q2q2O4ITICvxHyAy1mirVs985xEXcMbO6m4qchZyj7A7XwGcrXVxX7FihVpjED5dBQ8cQ== X-Forefront-PRVS: 0037FD6480 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(2950100001)(68736007)(97736004)(76506005)(4326007)(5001770100001)(2906002)(7846002)(7736002)(92566002)(189998001)(19580405001)(7416002)(3846002)(36756003)(15975445007)(50466002)(77096005)(42186005)(101416001)(50226002)(66066001)(106356001)(229853001)(305945005)(19580395003)(48376002)(586003)(81166006)(33646002)(81156014)(2201001)(47776003)(8676002)(76176999)(5003940100001)(6116002)(105586002)(50986999)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR07MB2241; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR07MB2241; 23:EQnqgb0YkF4dN4e1Mj1sY3SAG1pNuoR2X8BqRcKBa?= =?us-ascii?Q?XXkEuhKcyK+MTIcgdY/SQX9KCTKF55+FXLI2BJ3V/jsIktHLLimxc6v+Annb?= =?us-ascii?Q?mv3/0IgYFqYJ+yoszJYUaySKxA2s1c84CDRdnIG9Zqtv5uBkqsMZuuhW0ln9?= =?us-ascii?Q?MC9xoKq0mrkDLGV/8edmZalcrWf7XB2ltnJD0/H+XD4eSXxIDNEdoZKdrZ4J?= =?us-ascii?Q?6tAxZ7G+USFgpOvaYG1HlKotDPdQSUvSueOy+teOrNF+fY/CvuaxQGsl3kZr?= =?us-ascii?Q?LFHr+iqAeTMdul8EGJFmeLpDGnZkfbfXPIhULezgnxk1Ryj7f7qMQHc+KA5F?= =?us-ascii?Q?l5noIs8MD7Vt0Aje4F75qkBsimqEkxXpfmFHTlf19ZIdq9L4UrfCY9lRZi0j?= =?us-ascii?Q?2LF/mXTVbdvsMsfRDYwDIOLUYx5Jp7mi1ZWGKlmah21ik7Sd3nV6kSBFQKrL?= =?us-ascii?Q?ArH1H7zI8J/CWjg9rT83IQPVfRwv66/tZfYEbUlkaNPAYwRUOULJew0nZfHc?= =?us-ascii?Q?sXztvOXkDv3yvlvbc0AwKhEnmY3rwxu1EAWfHMfHYKQ5gxHGb5+NcmKH//qK?= =?us-ascii?Q?dtcpfgnnk5jOfaR4FMW7PtoF9PIqAAdx/8FAF5yBU8XFEYcCv4ZrMVZJqgcV?= =?us-ascii?Q?2ZgZF0u7Ay9n/rnOlj4hzpmA3x9d92KOBLqlEa4TcgD5vS21zOhljny17/N+?= =?us-ascii?Q?iEVXUdYfuFnbBiD+nnJ6yaCtENky7GAFnQzXlBpcf53039KUM0xGKMlavWV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v9Zz4BYyTqmD4QWbWHnX+fSpmFOxlmXN2D2EVMNiT1hFULv9+pY0Msozr3P7p0jyxtJR+rBpXbUnxagL0wyytQTE=; 7:FKC78GchxW+KXBA6I7YHw/LlbpSX8Pw/zPCLDsbUFaaUnajyOB8nnMZVvD4gg7+FVNBr5FvwNIUV7HrcwutYs14fhrhIDn22rz6r3Snr3KtoCd1HuqSgHiAPePLrjAxniruGyqTWITmI72zhwewQLqEieb5anKW1K90s5RPl6qhAy2+TNKCdkikTyP0ta+G/0tx/kzTy2bcV7U8HLONo3bH6NRlopFKp49ijuhWaDhyc1AG5YNR18+vIxoNsVPx8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2016 11:48:54.6092 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2241 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160817_074918_570318_3B293900 X-CRM114-Status: GOOD ( 22.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: szabolcs.nagy@arm.com, heiko.carstens@de.ibm.com, cmetcalf@ezchip.com, ynorov@caviumnetworks.com, philipp.tomsich@theobroma-systems.com, joseph@codesourcery.com, zhouchengming1@huawei.com, Prasun.Kapoor@caviumnetworks.com, agraf@suse.de, geert@linux-m68k.org, kilobyte@angband.pl, manuel.montezelo@gmail.com, pinskia@gmail.com, linyongting@huawei.com, klimov.linux@gmail.com, broonie@kernel.org, bamvor.zhangjian@huawei.com, maxim.kuvyrkov@linaro.org, Nathan_Lynch@mentor.com, schwidefsky@de.ibm.com, davem@davemloft.net, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP After that, it will be possible to reuse it in ilp32. Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal_common.h | 33 ++++++++++++ arch/arm64/kernel/signal.c | 93 +++++++++++++++++++++------------- 2 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 arch/arm64/include/asm/signal_common.h diff --git a/arch/arm64/include/asm/signal_common.h b/arch/arm64/include/asm/signal_common.h new file mode 100644 index 0000000..756ed2c --- /dev/null +++ b/arch/arm64/include/asm/signal_common.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2016 Cavium Networks. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __ASM_SIGNAL_COMMON_H +#define __ASM_SIGNAL_COMMON_H + +#include +#include +#include + +int preserve_fpsimd_context(struct fpsimd_context __user *ctx); +int restore_fpsimd_context(struct fpsimd_context __user *ctx); +int setup_sigcontext(struct sigcontext __user *uc_mcontext, struct pt_regs *regs); +int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sf); +void setup_return(struct pt_regs *regs, struct k_sigaction *ka, + void __user *frame, off_t sigframe_off, int usig); + +#endif /* __ASM_SIGNAL_COMMON_H */ diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index be02f65..5c73864 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -34,18 +34,26 @@ #include #include #include +#include + +#define RT_SIGFRAME_FP_POS (offsetof(struct rt_sigframe, sig) \ + + offsetof(struct sigframe, fp)) + +struct sigframe { + struct ucontext uc; + u64 fp; + u64 lr; +}; /* * Do a signal return; undo the signal stack. These are aligned to 128-bit. */ struct rt_sigframe { struct siginfo info; - struct ucontext uc; - u64 fp; - u64 lr; + struct sigframe sig; }; -static int preserve_fpsimd_context(struct fpsimd_context __user *ctx) +int preserve_fpsimd_context(struct fpsimd_context __user *ctx) { struct fpsimd_state *fpsimd = ¤t->thread.fpsimd_state; int err; @@ -65,7 +73,7 @@ static int preserve_fpsimd_context(struct fpsimd_context __user *ctx) return err ? -EFAULT : 0; } -static int restore_fpsimd_context(struct fpsimd_context __user *ctx) +int restore_fpsimd_context(struct fpsimd_context __user *ctx) { struct fpsimd_state fpsimd; __u32 magic, size; @@ -93,22 +101,30 @@ static int restore_fpsimd_context(struct fpsimd_context __user *ctx) } static int restore_sigframe(struct pt_regs *regs, - struct rt_sigframe __user *sf) + struct sigframe __user *sf) { sigset_t set; - int i, err; - void *aux = sf->uc.uc_mcontext.__reserved; - + int err; err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); if (err == 0) set_current_blocked(&set); + err |= restore_sigcontext(regs, &sf->uc.uc_mcontext); + return err; +} + + +int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *uc_mcontext) +{ + int i, err = 0; + void *aux = uc_mcontext->__reserved; + for (i = 0; i < 31; i++) - __get_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], + __get_user_error(regs->regs[i], &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); + __get_user_error(regs->sp, &uc_mcontext->sp, err); + __get_user_error(regs->pc, &uc_mcontext->pc, err); + __get_user_error(regs->pstate, &uc_mcontext->pstate, err); /* * Avoid sys_rt_sigreturn() restarting. @@ -145,10 +161,10 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) goto badframe; - if (restore_sigframe(regs, frame)) + if (restore_sigframe(regs, &frame->sig)) goto badframe; - if (restore_altstack(&frame->uc.uc_stack)) + if (restore_altstack(&frame->sig.uc.uc_stack)) goto badframe; return regs->regs[0]; @@ -162,27 +178,36 @@ badframe: return 0; } -static int setup_sigframe(struct rt_sigframe __user *sf, +static int setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) { - int i, err = 0; - void *aux = sf->uc.uc_mcontext.__reserved; - struct _aarch64_ctx *end; + int err = 0; /* 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); + err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); + err |= setup_sigcontext(&sf->uc.uc_mcontext, regs); + + return err; +} + +int setup_sigcontext(struct sigcontext __user *uc_mcontext, + struct pt_regs *regs) +{ + void *aux = uc_mcontext->__reserved; + struct _aarch64_ctx *end; + int i, err = 0; for (i = 0; i < 31; i++) - __put_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], + __put_user_error(regs->regs[i], &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); + __put_user_error(regs->sp, &uc_mcontext->sp, err); + __put_user_error(regs->pc, &uc_mcontext->pc, err); + __put_user_error(regs->pstate, &uc_mcontext->pstate, err); - err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); + __put_user_error(current->thread.fault_address, &uc_mcontext->fault_address, err); if (err == 0) { struct fpsimd_context *fpsimd_ctx = @@ -229,14 +254,14 @@ static struct rt_sigframe __user *get_sigframe(struct ksignal *ksig, return frame; } -static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, - void __user *frame, int usig) +void setup_return(struct pt_regs *regs, struct k_sigaction *ka, + void __user *frame, off_t fp_pos, 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->regs[29] = regs->sp + fp_pos; regs->pc = (unsigned long)ka->sa.sa_handler; if (ka->sa.sa_flags & SA_RESTORER) @@ -257,17 +282,17 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, if (!frame) return 1; - __put_user_error(0, &frame->uc.uc_flags, err); - __put_user_error(NULL, &frame->uc.uc_link, err); + __put_user_error(0, &frame->sig.uc.uc_flags, err); + __put_user_error(NULL, &frame->sig.uc.uc_link, err); - err |= __save_altstack(&frame->uc.uc_stack, regs->sp); - err |= setup_sigframe(frame, regs, set); + err |= __save_altstack(&frame->sig.uc.uc_stack, regs->sp); + err |= setup_sigframe(&frame->sig, regs, set); if (err == 0) { - setup_return(regs, &ksig->ka, frame, usig); + setup_return(regs, &ksig->ka, frame, RT_SIGFRAME_FP_POS, usig); if (ksig->ka.sa.sa_flags & SA_SIGINFO) { err |= copy_siginfo_to_user(&frame->info, &ksig->info); regs->regs[1] = (unsigned long)&frame->info; - regs->regs[2] = (unsigned long)&frame->uc; + regs->regs[2] = (unsigned long)&frame->sig.uc; } }