Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935604AbcJUVIR (ORCPT ); Fri, 21 Oct 2016 17:08:17 -0400 Received: from mail-by2nam01on0057.outbound.protection.outlook.com ([104.47.34.57]:30240 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934892AbcJUVIJ (ORCPT ); Fri, 21 Oct 2016 17:08:09 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , Andrew Pinski , Andrew Pinski Subject: [PATCH 15/18] arm64: ilp32: introduce ilp32-specific handlers for sigframe and ucontext Date: Fri, 21 Oct 2016 23:33:14 +0300 Message-ID: <1477081997-4770-16-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477081997-4770-1-git-send-email-ynorov@caviumnetworks.com> References: <1477081997-4770-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM5PR0101CA0009.eurprd01.prod.exchangelabs.com (10.169.240.19) To DM3PR07MB2249.namprd07.prod.outlook.com (10.164.33.147) X-MS-Office365-Filtering-Correlation-Id: 1293dfe7-f496-4cb9-d562-08d3f9f1e319 X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;2:4XDxJJOS/2T7EEGJZ8pJMMFEr22vmpYLeFeiNxNSMVkxbMbx26auy+MyYQb00wFZfgSq0/E7vOD4ZnaUg6kGH59W1RAQT8UDaRGUYSvkxHZRY0qiA7/uTs71KdP6k6tx0nKC6WNkydRJr8jLYqFI2eD0PAZXYlfRs8NJYfZWWPwlDCIGvxHE0dQ/GCPNF0QVBEj18jzms0Be3hY2vt97/A==;3:EB5EhCJJwuwBNGFzCaQFc+vI557ir18YLZR0IRnZ+SfoCxq1RFs6ks80fRMr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h8YclLjyqKfEfj41FFOh+GKV96VfIsxQXZYyNCNhZl3Ykn7tpUPKwlpF4IZzcS6PxDVrMLriqBb919Bj6hP/XDoScAWFj1XwLux0ekB3ZXzkgP/O9ij2a0Hyd0NWVn5xeUaZ2Li/3/p5Mj8gyuf6P/eiUUIMd/dhoWwj5+UveCVAluLxbHxq8GIb90JqiAKb552X6Mp1R7H3F/xYeW3DlAdng6tR+sNi17V00Xp+7uGNquB9/uyWLIRUxmcDKA76yEQbCRGWR1QKxWxKFx47Nz582bD6W+7+TrvXGWh5wahL3kj3W/z9ZWZOTkwYx5ajy/DBq3JnPR6Jt2+1ch9dKwibgME6mANjFdIvsYb9jsCjqaCPI64aUa/8/ux9KQQSakM30KPuwQ2ppWmiRqAtmhCuBOpzVjLCFTW+V7UgMoWZa2knPOQ6oVVNyM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:DM3PR07MB2249;BCL:0;PCL:0;RULEID:;SRVR:DM3PR07MB2249; X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2249;4:+1TfhfvKJGzs/5FpBWP6qG+NID1iqiit+WVztIQlgxiJrWlGwPkhMTVXp1j+Tzc0vscfvrFjHi4O7RCXFpB4XSy8bbFK0RxUWC+YrFxXd5y7xhUxqV/Ts10fTXE9Lv2tB2ivg6HD6Lih9yXT4hMxQIegsExAVaJHwUZzsRnlBJ1pYPJj5i4A7dLgSGZa6owGDTP7QrP9+SUjQsT/315UQIzPPLZ7mk+r7zo/8BAZalWsD+YRhFM3KgnVfhVU/TtLutaaIIuawRx0mKgChDfc3OLSpUOnsX4JDNj5ZPj2YV8W67+7JLPegg0grsX08vDP4J8HFf3UAnn/MxLIe1Ep7eatPQxvVE9EqtgEEjosWlthF+ujMXETuUvdRaIEJf4tVtWoT6WcNth4hmHrr9B6iIR5hZASs9ZWLTwMCnkm9+eVOq7rupEBsnyOYuZZtDmiUjBf3jSemGqm7n8N/ef3AADX2bSwxCQg7Gq6mn9O/v8= X-Forefront-PRVS: 01026E1310 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(43544003)(199003)(50466002)(68736007)(107886002)(4001430100002)(5001770100001)(5660300001)(106356001)(101416001)(2906002)(7736002)(48376002)(305945005)(2201001)(4326007)(7846002)(47776003)(6116002)(77096005)(15975445007)(6666003)(2950100002)(19580405001)(19580395003)(36756003)(97736004)(586003)(229853001)(5003940100001)(66066001)(76506005)(7416002)(189998001)(42186005)(3846002)(92566002)(81156014)(105586002)(33646002)(50226002)(8676002)(76176999)(50986999)(81166006)(2004002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR07MB2249;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR07MB2249;23:WEF3cgeQzhoy/BTUJID2RZ1ZjTXoJfP3lPk/tyKDD?= =?us-ascii?Q?KJikZd5lh5MdgYHoIBzK6mJv5lhtsk7xdOePzzy3On4+YZRSdr2QFP9Fwe7n?= =?us-ascii?Q?PENNyfWQvLF1lkpZ7kviVtDKitU0uISK/evA3B/iIiFlk/476JMcaX1r7QiZ?= =?us-ascii?Q?HoIIKAS4zwUr49oi+WbDDfA9MshMl5DpKW4ZsNttDZVjR2+E6WpLAI4DYjD0?= =?us-ascii?Q?/pLbJBanpBxxFSlL0/yHeW4c2WOK2bv5A9fwIo7t06CbPGNa3CL8rHTfd1rp?= =?us-ascii?Q?l28nszYHPxMYcy2h1VKdPxPtPVfT6Fcd0UFNaFKq4+BEEm+dJAJhtwGQVVIC?= =?us-ascii?Q?hzud+2AyLN5xcVkpM5dKPR/3M3NcQHeBwQhztyaNGq+ck/T6m9Gfpz58QxUj?= =?us-ascii?Q?5aQ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adata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2016 20:36:07.8274 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2249 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9493 Lines: 308 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 | 174 ++++++++++++++++++++++++++++++++++ 5 files changed, 239 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..d3210d8 --- /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 fdc0052..af400fb 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 478d6c5..1b130f4 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..6f9b7aa --- /dev/null +++ b/arch/arm64/kernel/signal_ilp32.c @@ -0,0 +1,174 @@ +/* + * Based on arch/arm/kernel/signal.c + * + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2016 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) +{ + int err; + sigset_t set; + + 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