Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753892AbdFSPx2 (ORCPT ); Mon, 19 Jun 2017 11:53:28 -0400 Received: from mail-by2nam03on0057.outbound.protection.outlook.com ([104.47.42.57]:52789 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752081AbdFSPxX (ORCPT ); Mon, 19 Jun 2017 11:53: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 , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Yury Norov , Adam Borowski , Andreas Schwab , Andrew Pinski , Bamvor Zhangjian , Chris Metcalf , Chris Metcalf , Florian Weimer , Heiko Carstens , James Hogan , James Morse , Joseph Myers , Maxim Kuvyrkov , Nathan_Lynch@mentor.com, Prasun.Kapoor@caviumnetworks.com, Ramana Radhakrishnan , Steve Ellcey , Alexander Graf , Mark Brown , christoph.muellner@theobroma-systems.com, davem@davemloft.net, Geert Uytterhoeven , Alexey Klimov , linyongting@huawei.com, manuel.montezelo@gmail.com, philipp.tomsich@theobroma-systems.com, schwidefsky@de.ibm.com, szabolcs.nagy@arm.com, zhouchengming1@huawei.com, Bamvor Jian Zhang Subject: [PATCH 15/20] arm64: signal: share lp64 signal routines to ilp32 Date: Mon, 19 Jun 2017 18:49:58 +0300 Message-Id: <20170619155003.13218-16-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619155003.13218-1-ynorov@caviumnetworks.com> References: <20170619155003.13218-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [85.253.137.34] X-ClientProxiedBy: VI1P190CA0010.EURP190.PROD.OUTLOOK.COM (10.165.188.151) To BY1PR0701MB1864.namprd07.prod.outlook.com (10.162.143.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe91329d-8fda-41b1-0302-08d4b72b4b98 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1864; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1864;3:cj99uXT/TJAB0kP9D6NwBYvHJtIsSBImcshDkNf6cCssJdxsV4gQtt0WiPDuFVvxaDu2aRKw/M01otnSr3WVyQ2aPJbrCOPgZmgaQHkz9I3aD7MeXrbOU9KtEmzwJdrt8EVooZfGlzYwjBCD6em/kvNOskJch2M2TqFu3NhXtr3jU/s4kVTkOVTFRgybJ7pzjgIFXKPeFUWz0UJ82Eqvp/GbBY/gk/0x/nBKheSOIlTTBay9Tz8fJt340KPpYqTelOG4ifWiwWq1MIA0hTv+HDxiJANm7TQ+wVKqc31W/jG+HPM7sdexBpLxGTuIi+LdyMkwJMXtiD3MCmKk7wez6A==;25:XBUfKADKe+LinggnNtczCOxrM1/6vjB76TWYreqfnPX7IuirbhIQh7oYkAv7LNB9AVbTVRo/tar9oznH6N5ug4LO0aE9ap8z1AFH+WIYaqnD3dcGd3ge3Gxrlxc3mKLcGXBAonhCYlO770OTVrW9XMmblfvGlyC/Ds8FCQdokTOsxIy4/9m4fcjGZWOgmTb9xYHHZ5H1mENIyIyRpSpuWVTiPQykNAxuSuP++4ciEoWClyecfgNfprSl4GemFrtb9fSh0yVQKTFAApPE7m9PzfmNCb5eoIsGeryTH96/bW7/alnj7TZFTqM8lr2Ib7QURD+u9V8M6rvmyJLr1vSOCAjb1LqNYJDXb2qg1UF5s6qqnK2QiIkDXXSqsQRp0m8lPnz11N71Zx3bAYOpR5pQa1JofEGEIF8yk0rU4yn026C8GhdR/eiXSzNMn/qgW7c3rPUSYv0xjEvmrGMDI0zCVUsmWK7cin7+0Xcaiw7EME4= X-MS-TrafficTypeDiagnostic: BY1PR0701MB1864: X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1864;31:+lo8VVo8svE6LIIjj0m6mjztGs6p9s0e/MV088wtIWeOqb2AIAui2rKcPZ8Uqh4vIv6rbWjLTSeEL7KngHQcs/2aJxpwBZU7onkaJIT+Thz26SbbAqJMq/jODdVsRJEZP8aAH19RW6SNDaTzMw+SLjPl1pCAkL3efQRug3U26/hiqB+mDh3VMrNsOH8oMn4BcyNk+oxBkZFz0eJCV6ygJie5LC/TYFPjudKTwNo2FuA=;20:MGsi9IPYfkN6dhmiIPuAY4efdK/KQAKHNXm1pl7R6pit73oP2N4gWQ/JIIlcSzW7LmApcFKaxFgT7KitpC3N0kVKt0l0PxacMgSh33aIjLiZkb6dW9CsduQRu50jQTwE5RowOSJEBtkm1cMi3P1uFKnoKSTqqaYtFRChSDcLt0RVv7b/4Bq+pCwX9DW9G551++9bCFaYvLoQfxBpwEa56f5Z3KvgxEjDOhd9m40doy1fut0/nUnHu827fN7FB9YOVpOcwlZGo69EIpVXveiDUt7i2BSbTz6iRQzq2n3Y6GMLbbn8sHMT87oFAPGYTOO0Hsj649XJFqDmcHAPpxU4KHe1uS9GFcKEo1F0GAmoqSIviUa3MxY+XO5UaYCayvX1HGsb3df640Q6JosXfEHhAvb/ghvLu4eP+zFYwhkJ/81DtAugPxYhlRCAMhgKukGRaGOFhPi86HBB0BxxAsMeOkrTody8ndD/mT+efxLxI/+4Xi+WqmgPF8WYOGMHifmHQfp4MzAalQNj9S0KN5pbkg6lzh6kJofP0ahpgZyyOz3ZeVowbO4MAQaVmYtexZ59/8pTBrclY+OkuvsYGH98nU29GgAlrgjsqS/BuHSEa34= 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)(93006095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123558100)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0701MB1864;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0701MB1864; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1864;4:/mF6U6TrjaqC1mhwBxrKbFjPbaP0sGgQtKbMEycn?= =?us-ascii?Q?Vw+dxfw2UHk03x1wLhJEDlBH7GwSJHV82Nu9oh/646vqzn1oR7MrL64T3BDY?= =?us-ascii?Q?i5YeD1jfqmfcbKM93O/f9TrpgW3eTO66V1osE+TuA4EQnM2JIK3XHMbz/7yJ?= =?us-ascii?Q?mcnFU1mPHZ4YB1Xf23kixhepGyeaQ1Xo1KzAsjj6PnDwBcqaKxVWbSMHlQGk?= =?us-ascii?Q?YyQVFEnPAkR6n0VxH0QzdvvcKKVqawlw77jivbOkZJyQkh7sY8ob7TIKL3dp?= =?us-ascii?Q?18Oy9ux4nr7x6sSFRKfWCD6a/JuzSRmQEDchGBDBFGY4pd2Mzxx38sRcrzUG?= =?us-ascii?Q?db9Mpkh+BULdEe2ttFuOI0gJJPCDM0MG4iV7P34JkKxCJooAnp0WPKxU1YE0?= =?us-ascii?Q?SWLlodZ0QRcTNDYZrrumd61mWzTbzMp/jh8vw0QJih2FP5bTNgdTk8qDJ//u?= =?us-ascii?Q?MQTZQeaq60wfbPKR96h1kMQ4LgI0Bgi0bgWkTCjbGMntUD2Nb+vmQcfMNEve?= =?us-ascii?Q?64tFYePHqfSswBc0SvYTBqBJIS9BBY+LOHMXqzia6iKnKR6kcTEaYZsdNNAT?= =?us-ascii?Q?X6+pgQaWjvRvZi/lae0shp85tCWFQZ2cUG6JVFPd41Y8TwCbJlAko01mPOEs?= =?us-ascii?Q?/wMchSPJfhoAaJleoRUeU+rdvf/nYN3tdmncMKGybqOlBsrTWlsw9Z3xnsuM?= =?us-ascii?Q?s2bNg0BvvzYLr06NhT5SpRA5cXt9eieemVTqT6FWVFgIKhyHqY09t0YhkZ8U?= =?us-ascii?Q?YKuinDTRQ6wUiY6t9VIUcoNNH97HOnfJRz2vTV/cwVkqWCuMRJWRl4x3Rlfw?= =?us-ascii?Q?LR7en1jLwuwz4fmHUnzryqvnqeuVri+A02Uvz5orVcqGdDX4R1Pd3vxyM1xc?= =?us-ascii?Q?hmlaWIiKLvtiMmzHnoGI9BifrR8zWqKZonnBznLrgbIdbixmAR3EGt89boXz?= =?us-ascii?Q?xQHFBDrzem+Lq2L1GAGRAswanLKkOmXAqONB0sNeyxV+DEX4gC05OspalxB9?= =?us-ascii?Q?qZ8nGwPAmlDo3B2v7O04ad6qcXnK6a/VFqylNwVpF0aIUy/pqiBQNX3O7s3y?= =?us-ascii?Q?+eUpzdWUSx4soaw7xoDdl5bs0SWfo6msO5eOLfU6ierj74g2c+umqSWKTZK1?= =?us-ascii?Q?HgCn1fH20DKLJleYg21oevyj2swHMJwz58J2o859aMY2bFkjdf00x9ITZlNl?= =?us-ascii?Q?9B9ZNykw7g8wVQyZaQ6p58+31cFZv9TPLXEq?= X-Forefront-PRVS: 0343AC1D30 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39840400002)(39450400003)(39850400002)(39410400002)(39400400002)(50226002)(33646002)(7416002)(7406005)(6666003)(5003940100001)(76176999)(305945005)(42882006)(2950100002)(6486002)(8676002)(50986999)(42186005)(7736002)(76506005)(50466002)(5660300001)(81166006)(48376002)(6306002)(25786009)(54906002)(478600001)(189998001)(66066001)(1076002)(47776003)(72206003)(3846002)(6116002)(36756003)(38730400002)(53936002)(2906002)(6496005);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1864;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1864;23:G+eLLrglzV0sA7ohbayqVXutcMNugurGmGKebZa?= =?us-ascii?Q?x/ab6fxWLMjbWzc0LfWi4EA7XngzsAj5e4skT18JNwTF98hdPeX1dNuEtohJ?= =?us-ascii?Q?L6sfqU0nUhg/4HEkpT9qgtLkYikZrId/8LCyQbDPLg+daoBmNTj0FHXH8hLH?= =?us-ascii?Q?cPu7zmmqAugrM01OQvgbywl8G7++LOMH+TK7Q5/xQdO/gZvLxbCUKbSCqd6c?= =?us-ascii?Q?z6bNG+/FDdXEtXAkPGdBQllKfuIg4u85b0vvLb0YXrmtbHqMcs5fPljGcuYw?= =?us-ascii?Q?1gkT9snCb087fIeSvn+L5e2KtvAv9Y9M40hkXXJnmWMIO89mv8C0R7fE03sr?= =?us-ascii?Q?dJCLKHhhHovtpXLCXn+eEBZVBRvXvW14LWsFE993zWoA1sE6zMmyIjPz7EJk?= =?us-ascii?Q?bGe9N1iph5CiaYk31FLhJl4vj5SZEZAdCLz7c1RUvTYcifIEmSGv8R8zUa0g?= =?us-ascii?Q?cxWJvO0VO9TQJf2RwhMQksoS2D+a0A5yDOAHOfIt1mVzR6ukabA0XdhUtfgH?= =?us-ascii?Q?mOT6T6ai+fFDiiJKGJ0ht9Vd80pfDcSb8T9D689sYkG3NhlcPHoniE1fQe6k?= =?us-ascii?Q?vokv79Vs5noRYMMYBd7BxSwDCTa4oPtsXLv+EkuMAnI+g291bupsMh/H6xpo?= =?us-ascii?Q?Bje0UOhQ2sqRYKew5OzQJdLH+dnk0crX9PfT+Guji+j57i4KpGIYuDsqKQta?= =?us-ascii?Q?qSSuSJEluVAmLNx83JUcglP5+QKbUzcwGyj23U7v7HZB23ogv3CF1glqxUjQ?= =?us-ascii?Q?WTdH/+kNexDvc8AX31n7hbG9mjCRjILr6UbXBVlBMfAQUz0jp6hztQG131mU?= =?us-ascii?Q?5pacLctUaGuv5D21X9BaOgiYMUcXnFogz8Hnzfg/5bUHUdW62J5gy4F59ZK5?= =?us-ascii?Q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F9EsjSNXd+/a4f6mpd0aHxc2HzK+rQua+K5phpid7g9KGUegAulH9Il4XOI8vTm0/faSM9j96jpxFoNtVWEukknCaftk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1864;7:xbosK1xd9ngLJGVDi5niZzqwjjHnptsAd4upi7DWEEdl5pJXwOQ5WC0GdZbkLpFfjRHdok3t0EtJlaMyDVX8ZYzThW9f9DuT6e7q0XWjYpvFkfv6LMzq0iMRVneECcMEpYSWGNe7z5etgTDdLIBYQ/325cdIHF7eoUtUUce/f9SAyTARHtUc5r60hJg4znPkRpQKljATSN4oiSGN823Pln+V0XIwDo33MMQ46MUYkuCamolTqwx7Eocu9Ctzd9Xwueif8DiI6koi0JyF5SoSBQIFeFrl0CFPM9fq2nlfRSI9tjyXgD63rwEGbw0aVtqCOLMUL0ooX9FSPNrFl6uPAXbdhC3dETB1XHocuWpRMiFAu0u2fi8rZ6Y051W5oi2CzEgXf7Ol0709XBxlKnfC4gbYKHKH3rmFL6y/s666EzAWIm6lQTMfQNzRsaJ5qk6ozL05E8+gLNSqBx7p84BbInvUYkv4VGdem3+A8Z8QkLm2dfd5FLqu4eUYR4iQy2K5JUkSqx89fAXl8NQ69YO3huLF9NKcNNG3Dpx4zNFNYz+ysYUljG6NPHT0trqNJpIhf3+89o3/l77rk4IsBOVvcxJ/o4Wvql5/Bic4tsz5M6kP+P475PZQLvWqLEL4SpHnB/BVhY9/OykQ3aETkyeSROT/gSs5/8L0Z/KL7CYeFiv98ku/P9viTPJ21JIecN2t1GPnPwVa7ZYwXgvu5bNYupRGloMJC4dvd2HGI0Ta/Yz49mloSDDbjTf5/06556CzusKXh4ekhC3E8aAcFiCNcn8Y6CIRFv2oITt5q5YTVv0= X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2017 15:53:14.0656 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1864 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