Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751432AbdFDMEL (ORCPT ); Sun, 4 Jun 2017 08:04:11 -0400 Received: from mail-bl2nam02on0045.outbound.protection.outlook.com ([104.47.38.45]:24488 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751415AbdFDMDz (ORCPT ); Sun, 4 Jun 2017 08:03:55 -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, Andrew Pinski Subject: [PATCH 17/20] arm64: ilp32: introduce ilp32-specific handlers for sigframe and ucontext Date: Sun, 4 Jun 2017 15:00:06 +0300 Message-Id: <20170604120009.342-18-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: HE1PR09CA0067.eurprd09.prod.outlook.com (10.174.50.139) To BY1PR0701MB1272.namprd07.prod.outlook.com (10.160.108.18) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0701MB1272: X-MS-Office365-Filtering-Correlation-Id: bc53f36c-0bbb-4a2a-9bbe-08d4ab41ba11 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1272; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;3:DvWBSxgcaqjK6RHgmFeIu7wk9Q4jSr8tDFs/ZeStT0FhD9VohiXxoaEe3z4A4++9rew8IEKotheejxYbEl8raR80Q1XnpBqP/SYD0emuiFnptqkYCGXxOSd3625DAta/ZTFNzd7rIjViYHMcNBlHxf7GrOhB4YRt2VZeIxisGoo+0S0IbxIDQMpU9DjWBmgPDCvE2sQJtibNAzf9VlwUJQeB7zd//pUkXTL/gstNmVQP1BI3d0ARCrjMCRAi36tjs/dSRFONGG5/h/bdWr9aT4RG7KwJtI1ltdJAB4BBM2nGT4JI1QnQ5vA/d7lZZvowuLaM+JnwjqjJFhCvqzF72g==;25:spskctj2R7Ji898Ghuw6dlH7XMA96ORWJhXYWVzSRqQDBiVPkovfwiRtBrgbe/Nq+IbEzDF57gQq/DF1OP4yow6m9IeLAcpDPhZB+g4LsTEWJgxkF/eeNjlx4ae8NDakjTkJvKUUkilOJ3MkYsu3kIuQgD/yU8YUxrj5rD8sh273t7Ws3Cjn6b7frGB9kcHexSfm7NB3jFJv78iStXPucMad2dw7CC3svyrvEvbMvSIYXtkLHyurKt1UEBuWiWiTK9BIhcX7XuIC2SHXKwdowviQAUUBkBYOg6Pz91xDBih+r7IX7CDvym6OVihpdsGLIhz/jzSrZzV6uR9U7Ji4kSkGl8KJGFzezVjpULZJ2/WLjLX+FJT+ELF4bcCxfuPEtGrsA3ABD/jewz4pNEu+gegQot4uKlagvv046MV8+sQ1Cx3AXRxleqLTt697qty612UG7xBRxGrxvyEPKZZNgOYgL4Zr5YFw6ArMVqq5q+A= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;31:uxeYQbGTrDkofBLg6OBq6HvX1DP40XkYcAIjj8sZOo2+EWxeCXmgEsrGP3JmqOtGLhBEaPBZhdyWWTv0OuwhV1XbnMmCXPRsk5/UiZCIQC4919EmzGpAuL9aKDLy6OphUN9g0x+kek8D2+c2KdvlMCpqhhdKrLpSzpBmdRxyDXn0FyuuuYP2PJnlo4xmm+RdeLebi1VXt1t1/Rf22GsL7rvSs5sNpxwtuW+xOmnyoZY=;20:JbPp0whVQMuPSUvVoiNrxeDCbm8tMjR/BnkYko05GpTF4xR7rWKo24tzHmTvuYgzfxhI4y8kdO2k4RikYj+g0BGfC6LqGLrDDsx2fs8akS3p9CneZUtRA1H8Txu4/YpqwgMuxOub3e3ytKlcx31Q7c5kLHGwEaTW7Rtw9GIrPoyp9h/1pP4EUouwDM5YzLwmGnYIAvcB0UMg09hO4mY204dLFKtJy5t/EBzYqcdBk0NKdThnO3TRkbf0gOx7LUhtPEF79UItxOOqai5DAlIYIrB1tH5a6L4KNIKi11ZcfhHccpFaHaDpYhhAC4PjYu7s9nqWuQuJSX0byl3B3oMqu+ND73FPzJ6vA/SudpHfCgakDqxar43tjaC4pgTnnRZjVU7Akxqq3tZKHvNEEAhCyQld8+kVHUMccJv8XvQ9mLqM0hD210lV4T6gX6CgLcyJE08YRLEQcfCldI5Olg7xyrtnG4IJrmVsXyKqS+aQeF6AvHhcaSgH2N2LaKdUx9V/g5UvNM+BszRqwQs907KvqZ6ByStNzUEqFxsk++ONNnf64HjXVEUNZcSvFp7KgBnEbGgjqdWLX9+rgER0DQQtv9hwfHjXvFShca2ZAREKAAg= 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:3poXaGXDm5duZ4AO9zVeuKEl64rEP30wjiSAv32m?= =?us-ascii?Q?fZ5THy7l9ApaAbCdjWhpcYXO+F9OQPq/qnIpNrlawR70xpbofVBn3xLhlYB5?= =?us-ascii?Q?K/3w8J2vCGRBOhCXY8YrRnnlqQZAS0x1bVxMKFJyLLmo9YDykG95bkC42KFn?= =?us-ascii?Q?+Teg0Ygjb/kw4PcpWs2cHGiP2/5Mfei7Kgl3Nzmxb6RoauSVHmR7K+gOlKZ4?= =?us-ascii?Q?iQlbI3rVHV4w42iMQQgEBh7a7PBR6MfKJmtk38bC2iJR4Kjvwq4J6jAwCYEM?= =?us-ascii?Q?Z3r3gcQL/VGX0ZS522TOG8HFfdHjncOO3NZJUzczVEasQ6pR2ZNCtNKELk32?= =?us-ascii?Q?PbbCYqJrE953rcooHw1eHKH1A0WUPVO3mM0r7BO6SkfRVZG+GVYGhQdZ0m2f?= =?us-ascii?Q?15/REHYwjUIgVZJ2te87lWNpNlYYgBw7Y3E0UBcn0VbwrX7lP9MT86N1/ww7?= =?us-ascii?Q?CKtkTdHDno7k6ei89SLF272RoeFvajHjcTvDYwy1EHWODBLrks+Uhn46yN9c?= =?us-ascii?Q?62uOBLa5EByKDLkcLg5giUDUdn28RB75BH0zqTWe9qkNNQ1/NRbiy1K6Q09m?= =?us-ascii?Q?+BIax54Y8+y14gX7VV7A5pMBAo37VuFoK0eR/Wp6CKcNIUStnUY6HVNNs6AK?= =?us-ascii?Q?5UPlnL7Cf8y5r8Rw7aXSaF+nRDUZs67/i9fKtn3Dw9RaSY4jfU9WHcTKK0zT?= =?us-ascii?Q?8E36Vz8p3P0QHv54UUnvUuTuYApCjOBQZO7XbNDp9HBuuloADOmJKQTR5suf?= =?us-ascii?Q?h03kLMtt3QK+2dPkJdpIQ8zvsLJw5bmXrqY19KiyvdZuV63k2d3O17SzOifc?= =?us-ascii?Q?wJEziBmaZ1DsR8yceXVLPa2l3i2mq4vsbX+fzeDFvFmWDrGvlvBqkp5uS0ca?= =?us-ascii?Q?FrwGBcaQo343+CiPoGv4jTUhjKsnkB6Md7WjEQNTuhpa33AyR7HuzMkgWuIk?= =?us-ascii?Q?+bx7Mroz4J8GrP3VlNXzN0UgR9RrObCLPRnAD8ZacyEZwPben/MCXEEfnqa7?= =?us-ascii?Q?2mgxa7D8pQXyp9LzktKZwtZzoWQ03hisEVQMdQ7TXwAO8UEeYcmZ4UfVQUht?= =?us-ascii?Q?PDhz23ESiiETSIImgxsHYnV9ulBRsUN9XJ/Dhcpg+QxOqSdvJo2644di1hzl?= =?us-ascii?Q?k1Fk4EtqkdSq1fSucvoh6pWXn0wK8kQ1AEshHzcRzGYmOqJGvy0554c7/bM/?= =?us-ascii?Q?jFSVpQxX50hqajArDtuyrvai9cSakNu52tnf?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39850400002)(39400400002)(39410400002)(43544003)(107886003)(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)(5003940100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1272;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii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4HXAJoquA03oFmrdbzj1SN+KbSiJFvhkoVbfUCN8m2f4DjlQCGkDeYacWYklpeUesAM5xhUXdJBSLxmmFp1PIC8qXBwG0q46VyUpsBqODABlsR7BlyGYd+wtyq6gjKLPY8o0YP/pzqhY8+wRfSJhQutIISSOI49H199NYd6YRJp1nUbvy0NcNvejeq4334Yttne3XO16i1t3JsQaDNZbPj/xluwklWqN5nBstk9Yx0G96+Mpn3b5BHEPZ0ud/RyoUIGLWwY607rGjrCxpFCSn9T2qcCFo7NGw3h1ifFmRkMMYrO6tpmya/UHF81kFfynxlGpHphDciicBCQdko8QpDoETdAv/p;24:PzOg8TUqV90SlauQWcwbGl/UHiOujLVpbWMVr5lj6D5IcvzYN/GfLQDbomUZasVkND+CKIzvGGXJPQgJMya9+CzpT3OK6uaACthXzJJWvS0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1272;7:+aGtr88JzoCEHErZeRAuSCVB9SrqF/KIRAHEo/pkoNfIOLd1+1wOg9/6hq0456XqBVejAW9zy5bEI5H4lFT5bMNUdUyUSwI7u01LPJZlyN4Svv/vm2vx/gSd5azhLYynb+YZdfqBPhlobU0u56tHXnh5Rx6fipFxx7Wm+sTt7DUE69ueICw0sbQsmycoFxmeqcttKIS1/DgreHAJTp2AOr/nthQ6Lr6zfTH6Gy4z2OIxQ4EZAikKV/30Ytz0P/EiRb1IgTTK5f9gcRKYwIhsWuAqnVlV2dsjIVEZnSB/lnk2sIyaUsW1Cts08GP3RkMqhk8Q2XLM+U3FAwuzVH6owg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:03:34.2303 (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: 9654 Lines: 304 From: Andrew Pinski ILP32 uses AARCH32 compat structures and syscall handlers for signals. But ILP32 struct rt_sigframe and ucontext differs from both LP64 and AARCH32. So some specific mechanism is needed to take care of it. Signed-off-by: Andrew Pinski Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal_ilp32.h | 38 ++++++++ arch/arm64/kernel/Makefile | 3 +- arch/arm64/kernel/entry_ilp32.S | 22 +++++ arch/arm64/kernel/signal.c | 3 + arch/arm64/kernel/signal_ilp32.c | 170 ++++++++++++++++++++++++++++++++++ 5 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/signal_ilp32.h create mode 100644 arch/arm64/kernel/entry_ilp32.S create mode 100644 arch/arm64/kernel/signal_ilp32.c diff --git a/arch/arm64/include/asm/signal_ilp32.h b/arch/arm64/include/asm/signal_ilp32.h new file mode 100644 index 000000000000..3c6d737c07c0 --- /dev/null +++ b/arch/arm64/include/asm/signal_ilp32.h @@ -0,0 +1,38 @@ +/* + * 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 . + */ + +#include +#include + +#ifndef __ASM_SIGNAL_ILP32_H +#define __ASM_SIGNAL_ILP32_H + +#ifdef CONFIG_ARM64_ILP32 + +#include + +int ilp32_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, + struct pt_regs *regs); + +#else + +static inline int ilp32_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, + struct pt_regs *regs) +{ + return -ENOSYS; +} + +#endif /* CONFIG_ARM64_ILP32 */ + +#endif /* __ASM_SIGNAL_ILP32_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 1dd659907f34..f3bf1b74bb4a 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,7 +29,8 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o binfmt_elf32.o -arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o sys_ilp32.o +arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o sys_ilp32.o \ + signal_ilp32.o entry_ilp32.o arm64-obj-$(CONFIG_COMPAT) += entry32_common.o signal32_common.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o diff --git a/arch/arm64/kernel/entry_ilp32.S b/arch/arm64/kernel/entry_ilp32.S new file mode 100644 index 000000000000..a8bb94b3901b --- /dev/null +++ b/arch/arm64/kernel/entry_ilp32.S @@ -0,0 +1,22 @@ +/* + * ILP32 system call wrappers + * + * 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 . + */ + +#include + +ENTRY(ilp32_sys_rt_sigreturn_wrapper) + mov x0, sp + b ilp32_sys_rt_sigreturn +ENDPROC(ilp32_sys_rt_sigreturn_wrapper) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 9f2ea60b9fac..b78f4c255636 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -35,6 +35,7 @@ #include #include #include +#include #define RT_SIGFRAME_FP_POS (offsetof(struct rt_sigframe, sig) \ + offsetof(struct sigframe, fp)) @@ -325,6 +326,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) ret = compat_setup_rt_frame(usig, ksig, oldset, regs); else ret = compat_setup_frame(usig, ksig, oldset, regs); + } else if (is_ilp32_compat_task()) { + ret = ilp32_setup_rt_frame(usig, ksig, oldset, regs); } else { ret = setup_rt_frame(usig, ksig, oldset, regs); } diff --git a/arch/arm64/kernel/signal_ilp32.c b/arch/arm64/kernel/signal_ilp32.c new file mode 100644 index 000000000000..b9a3372b0142 --- /dev/null +++ b/arch/arm64/kernel/signal_ilp32.c @@ -0,0 +1,170 @@ +/* + * Based on arch/arm/kernel/signal.c + * + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2017 Cavium Networks. + * Yury Norov + * + * 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 . + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +#define ILP32_RT_SIGFRAME_FP_POS (offsetof(struct ilp32_rt_sigframe, sig) \ + + offsetof(struct ilp32_sigframe, fp)) + +struct ilp32_ucontext { + u32 uc_flags; + u32 uc_link; + compat_stack_t uc_stack; + compat_sigset_t uc_sigmask; + /* glibc uses a 1024-bit sigset_t */ + __u8 __unused[1024 / 8 - sizeof(compat_sigset_t)]; + /* last for future expansion */ + struct sigcontext uc_mcontext; +}; + +struct ilp32_sigframe { + struct ilp32_ucontext uc; + u64 fp; + u64 lr; +}; + +struct ilp32_rt_sigframe { + struct compat_siginfo info; + struct ilp32_sigframe sig; +}; + +static int restore_ilp32_sigframe(struct pt_regs *regs, + struct ilp32_sigframe __user *sf) +{ + sigset_t set; + int err; + err = get_sigset_t(&set, &sf->uc.uc_sigmask); + if (err == 0) + set_current_blocked(&set); + err |= restore_sigcontext(regs, &sf->uc.uc_mcontext); + return err; +} + +static int setup_ilp32_sigframe(struct ilp32_sigframe __user *sf, + struct pt_regs *regs, sigset_t *set) +{ + 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 |= put_sigset_t(&sf->uc.uc_sigmask, set); + err |= setup_sigcontext(&sf->uc.uc_mcontext, regs); + return err; +} + +asmlinkage long ilp32_sys_rt_sigreturn(struct pt_regs *regs) +{ + struct ilp32_rt_sigframe __user *frame; + + /* Always make any pending restarted system calls return -EINTR */ + current->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 it's + * not, then the user is trying to mess with us. + */ + if (regs->sp & 15) + goto badframe; + + frame = (struct ilp32_rt_sigframe __user *)regs->sp; + + if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) + goto badframe; + + if (restore_ilp32_sigframe(regs, &frame->sig)) + goto badframe; + + if (compat_restore_altstack(&frame->sig.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 struct ilp32_rt_sigframe __user *ilp32_get_sigframe(struct ksignal *ksig, + struct pt_regs *regs) +{ + unsigned long sp, sp_top; + struct ilp32_rt_sigframe __user *frame; + + sp = sp_top = sigsp(regs->sp, ksig); + + sp = (sp - sizeof(struct ilp32_rt_sigframe)) & ~15; + frame = (struct ilp32_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; +} + +/* + * ILP32 signal handling routines called from signal.c + */ +int ilp32_setup_rt_frame(int usig, struct ksignal *ksig, + sigset_t *set, struct pt_regs *regs) +{ + struct ilp32_rt_sigframe __user *frame; + int err = 0; + + frame = ilp32_get_sigframe(ksig, regs); + + if (!frame) + return 1; + + err |= copy_siginfo_to_user32(&frame->info, &ksig->info); + + __put_user_error(0, &frame->sig.uc.uc_flags, err); + __put_user_error(0, &frame->sig.uc.uc_link, err); + + err |= __compat_save_altstack(&frame->sig.uc.uc_stack, regs->sp); + err |= setup_ilp32_sigframe(&frame->sig, regs, set); + if (err == 0) { + setup_return(regs, &ksig->ka, frame, ILP32_RT_SIGFRAME_FP_POS, usig); + regs->regs[1] = (unsigned long)&frame->info; + regs->regs[2] = (unsigned long)&frame->sig.uc; + } + + return err; +} -- 2.11.0