Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbdFSPyF (ORCPT ); Mon, 19 Jun 2017 11:54:05 -0400 Received: from mail-by2nam03on0069.outbound.protection.outlook.com ([104.47.42.69]:39971 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752049AbdFSPxu (ORCPT ); Mon, 19 Jun 2017 11:53:50 -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, Andrew Pinski , Andrew Pinski Subject: [PATCH 17/20] arm64: ilp32: introduce ilp32-specific handlers for sigframe and ucontext Date: Mon, 19 Jun 2017 18:50:00 +0300 Message-Id: <20170619155003.13218-18-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: VI1P190CA0002.EURP190.PROD.OUTLOOK.COM (10.165.188.143) To BY1PR0701MB1864.namprd07.prod.outlook.com (10.162.143.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ea5e8f0-f335-4938-8fe6-08d4b72b588c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1864; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1864;3:4OEwSglhv2zWTdX/0VYY98ATWKenpVvw4vrzecqMBSXX6wOsg10xQpt5pKE66umt7cJYgfXsswT1eSLuysdnCm3c7CrCmL2KOkCm4L95eo/vcPvIOdvABhBtbKP0W0fcI32jhSMsiDqc1su1jAYVd9xJEiOyj58fYrxOmf6nIP81hYTLdqRMsRhKis+tTJIZaCkKONJfFmOOfA4S1Bi1lTWNp1lCLzL7hb2zyK7rFuOnXPLVP8i+IDieYVsgR+DD96oAyfOTZYQDAeduv33H+7+rWQzg+s/0AZXpgKbEouXzG4lOkHxwf6wujn0fDYe9874i+BAmgrqIFcZEYo+2zQ==;25:IDocRZYiu4F8hWdW3HX/a9zt2aMMy0rzKBYMoSJh9Sc4p7TzBKuXMAWrBa/F/4ANKnaZ3i6CBT61z7iyGiMFhV5WEW37ReNbX4bs6LO2gy9CekoARtnlAnsOX1z1Olx0AFs41meAXz/ANilPyxJ17Lt0rGGS3WfBZJ84Ex5k35ygkwDbPd3WM2tDZsCb2F1D5XOIJ9o+D4TEDMbGGg8X0DBFRKAyl5oJa3icWvLhFxIe7wa3QrvFlv+rwfaIc5djgS4Q0mV6a/iD+dFaSOpP9eEFkycmJMz1wNnPUX09QxX4f3h1R2dZaVhYM57Lpz2tz/VorR4/5dGfiZBDoXluV89Ep79JxOIqNQEk8w0vxBS2WOh4h3SXqhLgYCP1Lg1WVa7NkO/TXy7EImwRdI1CyX9tWYS/WDqVJYx31JOBMEGCcqATYX3wY+0aaD59zme8LIbjg/8kcj8g0odPXnmLPdwC3sCb4jyBcMLxwLooYVg= X-MS-TrafficTypeDiagnostic: BY1PR0701MB1864: X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1864;31:OD+iNmLlMFjyTs0d+m7p5x6gOP+cibngM3+6KtXLE+ol8rlidyB/l3x7sr1SthMngb+hlZkUyX/0WhVn84zuIzs4DbDQsJj/pfZ7xnZhk80GJ/Vp/vtqfuoW8ufe2R2Uz5ZfBYOuv/67WvcS0LpsMN1ckN6qnMnZjbFv2k+PdjQC1uPQVtK306wdBdxbVrsul9rmyuLO/OFlGP9wFh3uS5pSa3zz6ft9F+gO8pfqs+8=;20:AqGbbl8y+F4t0Xp/ObnZ2Jxfy7DpRH7DnVNch/L4t2E/9LYg/Tvj9RNzdx1hsDHv4xFydGlkKLsU/dQC2IQOrPel7YpXKTYNQHHeBjNyvD41JZaO/zXI6puRn8/ja3P87if7QOJypGdL8OqDkt33UwjqEuSz5TG4RtmeAGrO8yyW16ZQaO3qIXgKgsv+26zY8wFNcAlcuNlfq1FtB9TjHLVH2DlEobGw9zvo8Z/aIu2sIrbeCeQ6Jl7WfLZw7Hm0xU4AEFftWXoS6WJtVxW2VdgFGvNuaoieJnjhH9avUm5NthxhVNC9beKl0WhhGCjMtKxq+1UDcM3PpFKgglpiZFlWVfo+4So6JLb34c50DBfSzR7OFZ+0y4XgAgvC/duuCS6Iz4cNr5hr3pim3nJKbuiQswf0Picv2hOLQ4A97RX7UpvrJw4Dco/U2OVDJY052TY1PV3Q7TYBYmGjE4JFujkZhBaONqXQhhcOp/Nqfz9qPCqU70KEs1J2p8xmc/uTWYCZKkFk6F2bjSEv362mn1JMsOKcLzIAnhSseOuBTTTdkD17sEFWkTIe0oMfcsSutaCkVsfnDcU/VaZcxEhduWkHWkuvkHQhkAtLhVd+FXM= 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:GYCphQWg5HrdoRiNEastPyToS9f1P3tYjDnJB+II?= =?us-ascii?Q?zd34+s0L4r+oRYl6x1YHvWaVTHgoHTIBY3nkVxhU1QvDQBWJuC0cPAEVw1W3?= =?us-ascii?Q?US5EmC6oTXPLEl+XvMwgS0ym4BWlYZGDciggDbLHworzqmZaMwFGARNtYuYF?= =?us-ascii?Q?rVJCTiFWmz1vJH2gGz10qMdPcFvHw4MJ9UsaNdMF+1DhmPiPpkPGZvy3xw0g?= =?us-ascii?Q?hVPHJadl5C8/QW9RgL3WC5bobZtuj9JsEazshan/Y5RYexE9UbEHc7o5Z5yp?= =?us-ascii?Q?bVbiu3B+Uh4j07uBcsglE8D0bVWxZKef7tCuUc92M/K7A4TQNWjCubtMVaC2?= =?us-ascii?Q?h/IXJg6AqfqFWhR3UKMahPdm7BYau9c6IXhmxayGp/dZa7CClH9DuJ29ENjo?= =?us-ascii?Q?qovLoxGMjW93H+mz8L8Rap+7fU+S7T7XTb1SF0wS38ARYsGpx3fKCBeGGlbt?= =?us-ascii?Q?S7GpSHWX1bI29h73cAbXWQ779FqVdFUaRrIg9GQhy5egogtb6U8bOYPVRcKd?= =?us-ascii?Q?v7SFrg48cHybtOwtSoZT0FG1Wvs0IpX3bAREU72747zSP2yvBplqH+T31lGr?= =?us-ascii?Q?scNbUEM8XAOZ9GLhUlOlys0VRFeIiHez+Agg1h6MZIxCIXCecMRaEMLTFcRg?= =?us-ascii?Q?m2zaM4Cw320NzyhH+nqLNOVcqCdTVRzX/5RHeOmUU5b71N9sVIDgsOfizY/a?= =?us-ascii?Q?EmkBe/Spksdf5pOXJRHH0RfIVnEbz7tk83/cw3qI1cRvI2WmleVWQgM5OIC2?= =?us-ascii?Q?gH2w4aedp5kmVKwVIBOWinPkDlUHx6CdDbceeox7Lxxu0R2YvJgRZBybioF3?= =?us-ascii?Q?YyI7wDLnjEep1AXE1Lx0hUJIo/xGd9RzInQIAeRFGvj4eb/8dAVDh9P09Ai+?= =?us-ascii?Q?nsJ7e52ZsSCvw/Fd4+zVX8cnyk62XymMOzt41gbRmpZEHSoys0/AQP0bgvA/?= =?us-ascii?Q?OKi5PmcOQ38oiTJh0cklYQK4l7Zy3xiN3NbM6F7/SbyLxSdkbxdHbKIzhjVz?= =?us-ascii?Q?5YyTKVeleGI3syBuNxrsxC65CD86mPKOkp/IGxA3SUohTdarTa7rtMw/cdOV?= =?us-ascii?Q?grIOtusoBOiBK6+1mFuSnhGkXdQyaH1ganxs5t6+uzxhYdvNEXarFPB7PTbZ?= =?us-ascii?Q?Gfs4m6yLl+ekVToKOSG/Qdzp9jdYq7usjPfgu05xaW5EeftTGSNvuXdCtOrz?= =?us-ascii?Q?ZAuSDD0Qh5lOOqnp7SyJEczI/wqdy4kpUOuQ?= X-Forefront-PRVS: 0343AC1D30 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39840400002)(39450400003)(39850400002)(39410400002)(39400400002)(43544003)(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)(107886003)(38730400002)(53936002)(2906002)(6496005);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1864;H:localhost;FPR:;SPF:None;MLV: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ynw9ke0De3KS5F1kPvlk= X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2017 15:53:35.7697 (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: 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 9c7912936049..a228aa7abc03 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