From patchwork Wed Mar 1 19:19:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9599051 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 CFAA060453 for ; Wed, 1 Mar 2017 19:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB6C928564 for ; Wed, 1 Mar 2017 19:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF91A2856D; Wed, 1 Mar 2017 19:34:42 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0CB7C28564 for ; Wed, 1 Mar 2017 19:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KbHvuaho3XyPIFV2vnVNWi90AdRiAe3lyYALnkMG1hQ=; b=Xz9K4pdGkPj+YW oGZO12+iKVyUR86tOjLx1ODxdU6US1NKOCWceh/4fSE6A7zwLUcl78vkp00maKWVPEMZj+pprQMAJ 3fbzlPKiJ71UW6B0pE3VFa1imbJ37iJu2aenbIgfKYhf8owy/kt49Q4jdFq0g5zxURpRPJqhTpLlT 4dDmbAOiLRas0vmURO6pt+W4ntn4x40AjxG7u7EfLuhcqKjFjCMoU+JFQgVg0w5ZBfcmTnZ2CkWXs cEfQKZm7kddhJL+gWQ78UirUYFMOCNTKPN+i15sM238BYxImKI554pB9Pv4UzYKPqb9jxeBVZSksa w+lKtUmI99Gy07xoAbCQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjA1I-0005FV-3J; Wed, 01 Mar 2017 19:34:40 +0000 Received: from mail-sn1nam02on0051.outbound.protection.outlook.com ([104.47.36.51] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cj9qK-0002pJ-P9 for linux-arm-kernel@lists.infradead.org; Wed, 01 Mar 2017 19:24:01 +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=nUwypbFKrpE8LZqqltO3DnlQM2rXzo1vYVT7dq4Z/J4=; b=EG1cjaEpb1rjQPLHMQ2+ZfEjv7HTpSOaLF2KOgybeBjtWfkp2ixqdIs9KDS9m4io17LNpLhTQzjFkwVOYc6t/BRK3itf6xNlrzVMIr7PlHtYv63sz1vv4beQLUoCcTg74QI32uq7/2b6sKb7RL6hvNIT/+QYvbRzDh3mg7jgFFA= Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none; lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (27.97.135.110) by BN4PR07MB2244.namprd07.prod.outlook.com (10.164.63.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12; Wed, 1 Mar 2017 19:22:57 +0000 From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann , Catalin Marinas Subject: [PATCH 17/20] arm64: ilp32: introduce ilp32-specific handlers for sigframe and ucontext Date: Thu, 2 Mar 2017 00:49:25 +0530 Message-Id: <1488395968-14313-18-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> References: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [27.97.135.110] X-ClientProxiedBy: DB6P191CA0018.EURP191.PROD.OUTLOOK.COM (10.175.236.156) To BN4PR07MB2244.namprd07.prod.outlook.com (10.164.63.150) X-MS-Office365-Filtering-Correlation-Id: cb14b573-0d5d-4b63-46fe-08d460d85eed X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN4PR07MB2244; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2244; 3:D2dODN1gMO4rR1OEegvcn63l5HTgEHCtXzagoH43LhVLFoYrtWNwWWitB+43jyIk6U/n7EZXKpfmvRXipHvO2DdLnaImX+CDu0zhdC7RgKpr7R+TwiWgVd7AGFz7GAZZhCa4iE+CDxHXcMeDZxsFmmiUVUCEsEKY6RiJZp2JZJtln7lE4rmF2sATVijrQUs/WSuemjKRifsntcHyJRWvPy5RXR/3O/zaexHdhUxQZTTxVuk/t/hz2FB99IelpxjSSIhts+gHMzHsPSr+LEqIvg==; 25:nbxOVw/gM9XQT7xEApH/LBeCLlzjvvojp4c5DRxCkY9LndwKmzQoghJNI0m/LK3tCRBNXk98z3YApztgusSlQh9MZtCtpHgXRYImLCCMHgTFYSu0CsNba2hmEY4H2hgv0wLNdu4g9qA0vRs0KV4qtOK7Mj0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kZO+4x0xyxy2so4ihLcGxLa8GHAbU541d/3UfYI1025mnHIiVr3IkCIZaoyp5mXEuZYp6vT9iw9kQL/8I7KO46hZ9fTNU5hxtaOnZFYFMrC796kCAe/owQ/eYSM6+ZLzuijrNBghu+yrZxHx1EP3ZxQFHI06lnGmHOuSjo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123558025)(20161123562025)(20161123560025)(6072148); SRVR:BN4PR07MB2244; BCL:0; PCL:0; RULEID:; SRVR:BN4PR07MB2244; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2244; 4:Zsg52N3KWUs8Z810bwBd8To4CX1ak7ylf1lYX1b1bpoIDuVE6r7hxgGR9m8M9kBUXJDFT3ddnAt3xK+CiJaR4f4vWj8WZJdQfzgT4V3pSESbMlGroJBdDc9VYtMaQauSBUMqF21RBISjZuh0va1b3RUU7441TCUjIj0ktSNQiHX2gjNnKhtLUJjNbJYqv96lyxasmK6dNORPL2s9ywOu14DQyY8laYqvn1VnWQ/pDaCIugGOTSR8fRp6qN0g6qHjtq5MKR1qPiID1GNGhS9qFKI9jxln4TCIQsjTT0TWlIEgpwzte2vXebXb8I6AYD+nP41MuSlPQ7AwLfCsM8zFO3N06UaNW0kb+hff6eHaiasqR8kVqdELj4c5wEjrQJCj6dzeyElg47i6G18bM6ALgfVTzxG3tDTpm4dzuoQOArXJljC2tgeSXXQhhlirspDUJpFevZrCU2Lh4o5ZmXLiWfYB7/iico74diqbjTxj0nFPOvr12FI0VpjhDbKKyISqQ9Lj4VZfOP+tXpJYbNnEsBwB28CzosPfSyqQYOxpD22g+6Rq3f4mE/MzA6J8sGDqWUMtSkTFDzHUY+p6xs/lL+hy27JbyUfFu5dDE7uiqKrpDu5GdjmHKclLzMrB+Z8g3Bla5iDApPR8WJ4m/Qx2lKcNdDF/d8hpohwfYRonJb8Yuv5EqN+/XRtNWcDRFPrk X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(43544003)(6486002)(50986999)(7736002)(76176999)(42186005)(76506005)(66066001)(50226002)(305945005)(6116002)(36756003)(4326008)(2906002)(48376002)(3846002)(8676002)(50466002)(81166006)(33646002)(25786008)(5009440100003)(5660300001)(47776003)(38730400002)(107886003)(2950100002)(54906002)(7416002)(6496005)(6666003)(53936002)(92566002)(5003940100001)(189998001)(6306002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR07MB2244; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR07MB2244; 23:CvnAWhdxxSgQStKuas3F9ymUvnMJ6/OleUqIU6lKW?= =?us-ascii?Q?oGrt5AaGPb+GWGI1ZkGoKJ4P83kszwZ3oWMg/6mdBOTx/LPaUDJUC9pIp8kF?= =?us-ascii?Q?Fl7Cz7wL30p7qf9zkMzglg+qv239X+78I3HRShNwobnl98TePLRtFknS1Iku?= =?us-ascii?Q?khky4PPmvkySQkfi3nvTGIZ4+4XCUcT8H12ySteH+WRYPhwjzupz9YcoKFIj?= =?us-ascii?Q?7CrSSFNgmqCsVwGvC/rf/WVg4JJDblPSaiJvtlcab9mLuE3gIZzEkTItfFX1?= =?us-ascii?Q?cUIwzwvsRHyTB4A9UW9dgBdY44epPcXADhx9KPCsxx+QvWfPcKdpOGOiJZbh?= =?us-ascii?Q?4jfhvvoYlpXPNu/6clTaod2LossYERd49igt9/3IgLtJMYGfZhD4R5DdvZ5W?= =?us-ascii?Q?ZacZlaXD9QgKHHWC4TxkDL+ungDUMa+Op8SDTa4H7ePzXq6RM4tgZB35Eeiu?= =?us-ascii?Q?tEf50zJGXsXos48xt2624gL4Qr0DuOep1lSPZ7d2nRJt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S21IFCBLw8hmx+8ZgI8q34Ge5qW5g==; 5:+43ZO7w5UsCY3mJaScjDsjSnvqtujnkS0ppxrZXtPJ8bi7AiouxYw7FxypaJ4scxaKRq/QYPtjTeJrVyiRDjm+6TUWTVJz8x1q/tD9IQ4WTZLlQFgr8IDfUlTFQFhiMeR0XKePzUCWkGTNnVCWyq8N5cO9KLPJ4Z489yzR+g70w=; 24:/o0bSP+30MPnqwfZ8+lzv4Ty7wzI2nkZe44HS0mF13BZpxI+WbOQ5JQIAwB4eLMdb3J9Ya6ToKKUlcMUJjBkniMcf7utVpBubPfmH0EZDEU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2244; 7:rkaPEIQZy+7nvBRe9oIAIapuPt/iPDq07QI4H0TR+4vZrwKlnP3drUp6nnw63rRoJb8EpVaBRrYEe5lZcLbXjG0VXpwTWeiU6ZE9BnDlwSvkkEqRMxP0Tvk7uNAXsJ9FdNYEKTWVP06fxUfidTkbgBVWzPAYZ+6Lym4N/V1HLvuhHLpOa1AsjYCqkqSCg9yH9HIT5neQR+oFBpV1W09/9t7AUOTI8KAh/59oRF3mfXnRRRbz5GGMjbPV0x37F/JMjwN0dD22yTeLDoR64yA4UbNI7OdaNr1O8Uptsrc/Roe6bNLCY2rvVRdkcp2+O4jUO77EqUmapORqSyfcJly0WA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 19:22:57.9143 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2244 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170301_112321_310907_823A3BC2 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Pinski , Heiko Carstens , Chris Metcalf , Yury Norov , philipp.tomsich@theobroma-systems.com, Joseph Myers , zhouchengming1@huawei.com, Steve Ellcey , Prasun.Kapoor@caviumnetworks.com, Andreas Schwab , agraf@suse.de, szabolcs.nagy@arm.com, geert@linux-m68k.org, Adam Borowski , manuel.montezelo@gmail.com, Chris Metcalf , Andrew Pinski , linyongting@huawei.com, klimov.linux@gmail.com, broonie@kernel.org, Bamvor Zhangjian , Maxim Kuvyrkov , Florian Weimer , Nathan_Lynch@mentor.com, Andrew Pinski , Ramana Radhakrishnan , 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 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 0000000..3c6d737 --- /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 9463af5..d6089e5 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 0000000..a8bb94b --- /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 9f2ea60..b78f4c2 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 0000000..b9a3372 --- /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; +}