Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753406AbdCAT0R (ORCPT ); Wed, 1 Mar 2017 14:26:17 -0500 Received: from mail-cys01nam02on0083.outbound.protection.outlook.com ([104.47.37.83]:10364 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752154AbdCATZ4 (ORCPT ); Wed, 1 Mar 2017 14:25:56 -0500 Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann , Catalin Marinas 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: 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 Content-Type: text/plain 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/LK3tCRBNXk98z3YApztgusSlQh9MZtCtpHgXRYImLCCMHgTFYSu0CsNba2hmEY4H2hgv0wLNdu4g9qA0vRs0KV4qtOK7Mj0FPU/S1s2VyOk/XA5MI+ufMDY7Kc1u7c5MiW2vcHFHyZgg2cbBGaZzqKMHNl4LPN220SWc9wyCZagnipDkMJQEslOsQ1V+iYN1v1ipojyNBMTnB6uFsg6D8+bPzJ9jkhlNs5xZnCZa8ynKy1RUICkB4U5n1qPj1XlBOpYEV+m5B2qKFngopox8td/KRwfyeDrguNQcGvPnbXF2zkYfkLYSbJrsy3Gr5rqXyY/b4PhnpTkC/PlBCXvrCgqUWnPIbOK8fsKCXma9G32EGIleP9FMD1GRHYCDRr7vFoMhbzsjS/ekaW9tNkUrz6Yr1w== X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2244;31:EJOsPatGCSz71qXKzPE1Ss872teIVNXHPX+VhC8VeV761Q9ONp4+TUaRClVP7pL4kgPYXsJR+fXZLNnOyIDyhHuTTY20CIAIs0aF27zH3q404KAtM2zMD9BFPMfhxaqm2Pvfrp6dtR76i+jOKrGi5D43D6mH2wOVMAVllvAFXeuQPXOhGk7NEP5YewOwJSh1bmtMaun77K/C8e+dU1ZyjHpY4BbYmyR5Hq33G7wyvY9PXlgF2XzVKcTeIlmRyfG1;20:zSwF74kirYXwnZ7rtCCfcFIaLKXNlakL17Z7eii6JzeOLuru3TYsWCUWjpUWoPgfRUcDvCik4d+0eADDCeZ/lzeStub64RtKewixhfmhZM5t3JtnuXnY23PPoZSLRmwMCM9rVhn7yx9LAIoBv0FfrLa4EZgtUE/YoFokppW8VJii/JV0D9MQSLxm7Y5OkL+eWf6SwVlVcxCcKfaPpX/rl9kP2Hv1M5InmzjRNlvCCMlt0GUoBKPKeq9Y5AvbPYQk/LSbAZ+MzChBKZy6GN+nHEztOTQq4Z9G3MZrUyXSddUq+y7Yw38KOw4ztmBHFbOey9Yb6g68u4Eq1suQ+aRS5EO2N7ZAcenWzTSJR7B2uh6vJkIEGJWNKCzIRLQI8HvutM52s2D9oFtkZQvUWfFTlpFAopxbfcjkqXfhLQ4ecjU0VLjznGxkONxz8yA10v0dpvGYfkZO+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?tEf50zJGXsXos48xt2624gL4Qr0DuOep1lSPZ7d2nRJtQfIIidMB3JPVmadY?= =?us-ascii?Q?EwCIUjrbxT3ArNdFGPbrzCE+fFHHwSsmJG4O+PLvreX2wxFIYrTX1KRPkO4h?= =?us-ascii?Q?MQxMofmSqAtP2QDk1/Mn4bnPKhImvCrt6H65mQn2xOFSpDltcCNKTLkfEsuV?= =?us-ascii?Q?cnCmeUC3UfnsgObZc3+zpHfJhqrP/WR+k5SkYB3vYe9CswpZgV61baXUe7k8?= =?us-ascii?Q?qxV3nEjVFSmy0Tee+/4cpQ8Q2ilqYIRtHDeTK7B0TYP9NSBE8CSPrJTpNTVb?= =?us-ascii?Q?KJgxnwgbb9JaJDN/VhPy2GUEKMCnIQH50fnYVZ8ab++nCknwX1bWl1wbcHAj?= =?us-ascii?Q?1J17D4cC8KBDdasg0A06aTIE0JgVdfmY4ZjBXEo1RA2hVoN7MN6QGmafPExn?= =?us-ascii?Q?uiqyc3+kPi5nj4gLCMoulnZ3/zBB+wiS5tRTp1o2VIz60CNol4UL5uh53MFz?= =?us-ascii?Q?9DmISx1V7tC+d172zMJ4g92tXa9lj9MfcXz3310nNrheefq6WRXoDjyklGdx?= =?us-ascii?Q?m5QiF22PdcWE91X3SKExBW+BQV37hJ3TKIgKvfIkUGFPg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2244;6:X1dKNXZOrvj1LdQkGg3wYLnGMR51NoMnhBl4f/28xS86UuzVw+6YZLc+JG+RgA4nmGo+aktpy7wz4/mMsScJbHbPa2vMztYOLnsackw946W7e+wtR9pHJKp+qY797NBtoB1287/+y6jry8TSlYzoaANc/l+QEcwtq1ZZOK9SctF28BSxch+3b6M5x6I5gESisMWrJgRgLh/3lRM8Oh8Z2RNiJEAf0lBm1sHeDQt7OARzlhsJdcXoi54LO2gqzo+PqyY3xYm2GCVcb8H6rEvf3xrw7WICHCVXnoCJO6Clevm08wgis4Gg0OpH9ORSytzamLXfoaZIcLdi4dmyGKnEErlJ1IwwHCEkLECKjywCj3gyDrK6pef8x0iNtS21IFCBLw8hmx+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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9603 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 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; +} -- 2.7.4