Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751384AbdFDMFg (ORCPT ); Sun, 4 Jun 2017 08:05:36 -0400 Received: from mail-bl2nam02on0044.outbound.protection.outlook.com ([104.47.38.44]:47264 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751248AbdFDMDX (ORCPT ); Sun, 4 Jun 2017 08:03:23 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com, Bamvor Jian Zhang Subject: [PATCH 15/20] arm64: signal: share lp64 signal routines to ilp32 Date: Sun, 4 Jun 2017 15:00:04 +0300 Message-Id: <20170604120009.342-16-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: HE1PR09CA0079.eurprd09.prod.outlook.com (10.174.50.151) To BY1PR0701MB1272.namprd07.prod.outlook.com (10.160.108.18) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0701MB1272: X-MS-Office365-Filtering-Correlation-Id: 9be96b64-3304-4c0f-998d-08d4ab41ae0b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;3:JRIEq89clns1DZeZmXYSLyOzxRKdjklcZfPfj9fimKipQu3b01U6fGe85fKNQGAqyAGKkjFMCu2VgvyGVFMPY3m3SEmfsP5EH0eMGqeB2YOgnexQdjRdxN9bLqieVSgUIfryHID9+synVQOXTZG7Y+aic2PS2ZEKIA2CpL0GRkFxC635JtasStQC+GMfGkqbfdgEB+gotc8wiR3UNy7LsxSNWHvWgHjQL9XJ/TaxWUhesYgxox+QtzX3A/+W4O94lvNIOQDM0+GBMpTxpQHk7DOk/+ZoEFml6k9ce+/RYcMo5Cte9WETx5PvSC+Tmr2HNRPkQTfflVEtU98a4GG0mQ==;25:lIfqbpXtW5fdo/wcG7F/E0sTYAipfDGWLgq1yncyGNW5JR6q/Ftxzrj+SB0WbHIdyW0d3ieN76lwD4Ae+7eeP2aa7BCpX/aVwVZdA5M7l76vp+m1j+YbT0PNh3LPBOhDVprX2frV2Ewf9ipaSgUIm21DoYXjGxtCy/qTqc0lh1I1jdE04Ve9YMwpjzLkezOXUTmMXLCVvbgHfWxRqt5WtLodWMSkKLYaP3v7KrhaPPeHH/Dgz2kE+y/vAvKQfsx/QlccqRYYVLW4RovpbENeCQJlav9Jb+M7x3itkkOoP49DTT6T57o3DS0Ks3JnWM0iSlUnlT7PNO+V8AGss/AdQpREA8x7fIHjFFK3P0UrepUxa3TWZBc5K0Rhui4xRR7d7HsJbnuDgEA8W2HoFDSov3bB/leXDUQOwRD7nMbfhhIPsVshnhwDhSjM+praNsnpjFpx2BuQQUviQvelLZ2X6XSWO8meeee8/tw+FKEKC8k= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;31:Qgf0/5UZywha999WNNURoAUqZs0zgV0Cx/oYaCU/V5NmlwAUiOfoht0nUg2VzaZy2BoT4ATlK0Me43490QoOce4UFG3/ZA8FeLaAiEYwvrLtQbtpb+B3Dpur7/2nhBi6vtjn2JkEpAGGvrhmMpm0hSwGoji3otQrskEG15r9pgu8UVguCI4vMw302iCZlSRRRWv1pvRG/O5H3DOBRWQSK0GpBuFhcj+z9VXEQuDCrzE=;20:OEfWaXP7ew5xVODUri55+UUHaDfpD4ORto72QhZLZ/G1WwmDXyio3CefYsnOS/SiuLQCszlL8n/FtURwRhnDOK4osJ2yaoQ88VDhoclZZEYbWkdYfnG+//OuH+mBh7VuVDp3Dswdu2ahEJ4Qzw7RnG241MR8jizT15/UM8/6XUoKwrL438//V+XfZ4eOOsb8S9nAlCiYgEjHX1JKiNngDmt/O356kCv1x7Ha5KcOY6p4/w0RWZt/htX6daugiwfkzEVjDfNLZ0Hycz9NsNM2o5G+EtzD80SQYfrx6AZ178ve/VK5/VVTjKdPofQP6vLMZJsgQRN+eFFvQvxKgh4NRKV+nBj4PzEvQokFB/uES1QsC5IgRYlUc8DxvVYZ5FUGMC2o7mAgDtBjDRPCJ3EZS6WAB33XPxW1EhuaPxTgwHrezAcV/hqzOMC+7aCf+J3cEDzgbR3nZEos9n1OBguhH7G0xwMifWnb7UNkhd+qxJ8cgMe5gKcXcjA33o4cjPNJrhLtC4OHtQT6gYm3YI/E2OgTcwg1xzOP2nm/UsRyrqQQDpLvsO/gBczvyCSY27hsyWfg2Z8+Bcdux5zcwJWDEFmog0cWp9IegCSIFjaJbGc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0701MB1272;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1272;4:GoR41PHWAVfmpBKtMIV6MP26EmkkS8hN1Uzrra+U?= =?us-ascii?Q?ZGq+nHDqeDU6kViByTnUANuutirh+jSGbFkNhfcRWdrAjXz7whiYLWSKC9ik?= =?us-ascii?Q?8CMLE+t07mmg7kIPDHvAykmZ+edFoeGC4aQwXgmakFTR9HYDmmlWESygaRvD?= =?us-ascii?Q?u9r1CFo8s8xKz6Z2NPyY6ESezVkVSiw6a/dJoRl4UmY8XwOw+ma7CB7fY+Rz?= =?us-ascii?Q?QdO1aulrD4EnbGuLrA3mR5jTsjj4uio1u5XgrD4KtTLLzBXx+wfOVogzksBI?= =?us-ascii?Q?Umy8+H8p48kFMBmRQ3r4HyDYLNxgxPl8BxpyRu05N2RAfmkG8ymJvpXzGeig?= =?us-ascii?Q?Q6mcBdLHwuYE14dYE6knHA8fwwafO44tNVPqNF5bYKxxEndDqNvuSlFPhHjP?= =?us-ascii?Q?y6mQYkDrr47+VSn6aySKrjC2sbK4WhV9FYH9RYl9PUzu6MmIMjC7dB3WmFSC?= =?us-ascii?Q?TnAqcn+BDHXlP2o60/74G4CysvquM4zIjJPnbJUNrmfpF99xGlQxBzYmmJe/?= =?us-ascii?Q?FRYcexa26GE0gJ0aZ3GkkqbFMLgVef7qHiK7YvQa5Kx4Vparmlp0vEJnEd7G?= =?us-ascii?Q?y20ndvzGq9Rf6iUmJE9zIUrKbkTbrZZnjem5UsfMfYwiOcNc5z1/m7nDmpT6?= =?us-ascii?Q?ja56djhXJAJ6Kk+diWcys0ZEgOE2b+oQ0zAc0yQFNEQHU7S7cRceVd3bzMag?= =?us-ascii?Q?gYpS/HP0lRQONpV6k6EDg/oLgz/KFTP3QEB0clL39c/aHODwky59XTgTIoZC?= =?us-ascii?Q?O/ot/sFargZaVhq3GDldYozptc9utXhy8S66ka6COXqYxbJ/VjAAtg7eP4+s?= =?us-ascii?Q?0sYV0QPe5k+SD/GZlggAyJq4v/hJTxNWbGHXOf4Q3OVqwmvWmi1ooEdSy4iY?= =?us-ascii?Q?dBAft0IyB4Rn1JWbpQPtmAs7a1SISYIO7yqoClfFDCIjV+xCw5UcTPpy5NP5?= =?us-ascii?Q?gzDOrXDLvedxHvgDo/PB4Oi6cS9CqbPB6cvW0jQy4LScunHDN/Ma2QwdOkPZ?= =?us-ascii?Q?0HhHtH0fQGdWHnnhrLDxdccO021J2fKyGdlhvc1VBW/rIpHFH6OhzgpU9eIg?= =?us-ascii?Q?OUFtmwBxgzx0KxVvC9IB4EkNou3zYt64zqKl3x1WfuGcVF83x4Ptx9vhUSWv?= =?us-ascii?Q?EZWNQgIZbLiG8l/+qcq43aomQi95Su6+tEr4BcK1IRLj2pT45KZwoOziMrm9?= =?us-ascii?Q?/5KPtJ8d778rSzXUcBSgz8knA1wGZzmH1n1J?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39850400002)(39400400002)(39410400002)(6666003)(42882006)(6306002)(2950100002)(6496005)(47776003)(38730400002)(66066001)(36756003)(6486002)(54906002)(478600001)(48376002)(72206003)(2906002)(50466002)(81166006)(76506005)(3846002)(305945005)(53936002)(33646002)(6116002)(5660300001)(42186005)(50986999)(25786009)(50226002)(76176999)(1076002)(4326008)(189998001)(8676002)(7416002)(7406005)(5003940100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1272;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701M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6mIKEoK3J3GG22gHdJ0G8p1eXg+7im51doGP2oWiEDhZMhF0UW8k+bIN4LU7T2Vq1qvx40LF6yKjq2nK0gVdcRIEvQ7yygRrIeUlK2jkOX00k24OMSMN6+Lw01XnpoJmcC71eSBy5ueA1WS7CP4/yq+Naz4I/vkYjJAKEqPSDy8G/kM6Knv7MIWQMU0eXFCOz3Kk+I/OdhI1MS7qyUXxb9707Dq+xYApnERdRRpbvK30Qe1YqoNaXW+ZI+gFwwqUwlBuLoysKhLyvUwUmR4OCWUGOJrprPFMUVJ08P+U8x;24:LgLRaNfpVgbO1M/Jue0/0reLhYeVkZwmc4CS1+LopRAumZ5RW8cEwdMqYXcnizRUm1ofFPLeLEBpooVi/wDDADpU4ObaaNO7o9HwRMANF2g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;7:HZCackhvgP1gwVb5c/Q/oIxkejpC0n2xB/knaAdt+ddVepoRMcq7+GYMAIv9y36pWw8Y3u9U6KYjoV6iqYN5odT+8rBMPQ09DMlSxXC3hPsWPPaUAFWBEPSCsuUQN38CDrXdM2e+ttNdTKiX1EB1LMs5hm3z6Uns8uRHz3Ha2rnnLf3+vLa7LBkGDF+vQFn9pbD2l0StJxDr2sauXRlvV4QZoYczOfu7uNdt54Si5Z1H7HROgHyjDZW7lvDZ1TcOOWbqO3emO4fPZwFtG8hCITxlMHo8FH8d3uGl57++7Lg6jr0+wPY3o1q0OF7V41J722dhyZfAs2MCj9YUQ43v9w== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:03:14.1520 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1272 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7960 Lines: 236 After that, it will be possible to reuse it in ilp32. Signed-off-by: Yury Norov Signed-off-by: Bamvor Jian Zhang --- 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 000000000000..f68238160940 --- /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) 2017 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 5fa1b401c5d6..9f2ea60b9fac 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 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) 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; } } -- 2.11.0