From patchwork Mon Jan 9 11:29:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9504449 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 376FD6071A for ; Mon, 9 Jan 2017 11:34:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 318EF283F3 for ; Mon, 9 Jan 2017 11:34:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25F1F2848D; Mon, 9 Jan 2017 11:34:26 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6AE70283F3 for ; Mon, 9 Jan 2017 11:34:25 +0000 (UTC) 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 1cQYDW-0005pW-Ro; Mon, 09 Jan 2017 11:34:22 +0000 Received: from mail-sn1nam01on0053.outbound.protection.outlook.com ([104.47.32.53] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQYDR-0005Kk-LX for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 11:34:19 +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=NWdsLc7EBo37cZxRk7um7eAsMK2eqahzJXgNtY2I1+0=; b=LqBQZMDAOPwrVfJApUqtx5uo/to5P2qVQibeQ4l0QOcVZjgGybu7Cj1AoWoI31wAthiiPqEabxRejxqDTbFjxzUgrIZSO5Hy2FLeXVtozN8/mmwptqus2U2VKQFWS5lq0Gv71QTru1Eq3R/hG4FQMP9784Ewe2xsp3hlKTB1UQk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (103.78.20.242) by CY1PR07MB2248.namprd07.prod.outlook.com (10.164.112.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Mon, 9 Jan 2017 11:33:54 +0000 From: Yury Norov To: , , , "linux-arch @ vger . kernel . org Arnd Bergmann" , Catalin Marinas Subject: [PATCH 15/20] arm64: signal: share lp64 signal routines to ilp32 Date: Mon, 9 Jan 2017 16:59:52 +0530 Message-ID: <1483961397-8599-16-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483961397-8599-1-git-send-email-ynorov@caviumnetworks.com> References: <1483961397-8599-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [103.78.20.242] X-ClientProxiedBy: HE1PR0802CA0009.eurprd08.prod.outlook.com (10.172.123.147) To CY1PR07MB2248.namprd07.prod.outlook.com (10.164.112.150) X-MS-Office365-Filtering-Correlation-Id: b0c9da27-44ec-41e6-e875-08d43883655f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR07MB2248; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 3:iPXw/BGmlAvD35qlXniN9Jf1FpcP7xo6Vl+YcGNE5r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q0tklIcFR+dIRXD6c4DR52+6fHPOuAGUkjwXzr9YiiuwDjkl9V8w57FCW4VPdZasY7z3k7IntxyxwbR/s1SsijTQlP6fIxlT5CkjsYOe2Nz/8VWOlreYM6auMURKKNa8c3M3DwQBoqhvmMe9DAp5LmKvMmkaF1mA/KUaQ0c7KBRuiufPCtVF6eEgsNvvpPz5tLJZ5OsFyW+9JkDJ/2AlUUiHg1jTsQTpCenfWZHVjS5zRSGdGIqqLbUMDkIU0VmwfewU/ttv+n7f2/xhdhluf1W/MJ3qby960fL3WUBssyuLMiU/Yg0xn4ifSjaIWgFR41GCcznyqAA7UnojGB8x1rT09EYcUVMTPNjDODZzLQchRtifS1yMOhFc3eH4lMGOHGw0NP3SKOkRJ7q3LppfkwrXv31Pac9I+xxcuEguAJ0RzVgWjhOOmB6bL8lMXa2gsODYmG8wNGbeDQRrUy26M/ynTGkEuHyiPWJyGFHqI04rYiA7F3/ZXoiTtBdNmsydjL024nxVstIEQC22Iy3EM9SE19KyVL4OUNRrJf45IwjC80fiYT5Bg= 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)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:CY1PR07MB2248; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2248; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 4:0wiQ1MHi8iyK/4EeIfkhfptHYDZjIM8DX2LeJ8PHpWeKw0e2NOVV4evqU/m8M8m+iK8VlPMcDgQhXvEUSibxpsw7FTELcMcl/+/4ndxAR2P/5S45OhmdMhNRDhHsTZHE/ojYd8e+clW5GiyidrMXOM0BSNAMeTRINBCf7oltW5Yoe3nn8XHqJfyVrMBSzMgyoVeKz47q5+Mtoz04ATPvSMo2P47aRS4vBdgw6A89qonSe2wyDBaneKvsneJoPHgxxGoFDKHlXY+dmBZ2XsGo7p2YWEoBUPJgH+4WFk3FyRDoulOVR/Yxm3p6Oxubl5ARkNgYUCztVArLuJJ7AnFGzUdXimyxpCzYzY4/lgYkH+ndlnWd6ez40BjEiiw4s7X7DIJZmFTTGJpFjnE+yxhHbOpMlwlCfh60mQqtmVKLEF7+aTWgbB75UkCopB0BG8OvzC8k42VFSnSrjSj2npEmO6Pm9l3+pDUR7kJ/vj8sOa4PzpYi25ZBWFfe0030TkFWoNClft/0JNpq6u2/0FCgFYe2PlMqdn7nccAagmYbu37qH4zO8mGyG9dC+Rl62cC+kBAwwcYpNdmiPY48id3oGJULK81o99EieMrcvy9Q0GuKDsmoi8JR8fKsBuK6MUKR+qFLvs6Dv78d6sbimVwqMg== X-Forefront-PRVS: 0182DBBB05 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(189002)(199003)(3846002)(6116002)(6306002)(106356001)(8676002)(81156014)(81166006)(7736002)(305945005)(5001770100001)(97736004)(5660300001)(105586002)(101416001)(33646002)(50226002)(76506005)(50986999)(54906002)(76176999)(42186005)(6496003)(47776003)(189998001)(2950100002)(5003940100001)(7416002)(6486002)(92566002)(4326007)(66066001)(36756003)(38730400001)(2201001)(25786008)(39060400001)(50466002)(48376002)(2906002)(68736007)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2248; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2248; 23:wcUAc9YYsnfiGjxtS5UgdJrYg+nB5z2UmNavxGWT+?= =?us-ascii?Q?5c8IlLvNBHzuB5lGL8Jx4OqjMmQR6Ly8Ug3WWRQ7B7cyp+xGnB+d3pvCnIcz?= =?us-ascii?Q?WQWyRWWPCCV+izJc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Lknj?= =?us-ascii?Q?YhTj+sICbS3qLte6KpK5+NKxEqX5Rpw4O3Mj2o/x0s9cvcLykdYVgkEedIto?= =?us-ascii?Q?V5+ZRwVXdUfHPXQYYPdfeNgh+NTq0Ips5qvi8fDWA7WHa2KD19Zs15VndLp4?= =?us-ascii?Q?Z2BAaIXI/odVXcD3drGvhN+GEf19itAqHxGMcsci6YLzQU8dMKy2EimF+ee2?= =?us-ascii?Q?RvKoG8i5tZkkUk=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 6:Voh8TrXGn7xpd71fcynkSdf/+XaGPuUB/NADhi184DavoiXXsNUYJGCJVhrvKyeIeiweBGpoMwJtCqucPIZvhHdY8xOTcAJBYaLE85QQW+ApNsEm1ir6oZI6XKojsexrq0nZAS8unceTMuI2oOeYyHOFTy1/BpY7VUdGtN/laMeR+xFcdPNxPEv447ThdcYk3N9vKGCBN75/O+OIrMes0eExBUtdHWZO+3k0zTQWpQ00g8ND5maim2Bd7PvGX2t228cbJmVH74jhJsxamzZsVYKoHxby4G5MqETh9FwqGu1oL74ra5Fn7uTvEWEHBozwkprYZStThxxUHsKS7hAjEUK1b3uWGw1PMP1tFIPDTTmV/jq1iUTKhovUgmaA6Qg1oXem63MmFPoh8VxEQo20djA2SnATI+OSz5l5F0iwxhg=; 5:vb5qmFhZMOK4p4G/cnZ5QUl2q+OzlCQNE4dBmxj7+6SL2ud27OXY0w8d04jqkXe00Al2knSiBQEOpA10XMWyW8VTERuFR+A8E1pxErfv1E5WfPO7YPKm+yK9hbrpFzEBRWptjQCbpqnMjq91eLvy/w==; 24:XRoIyJUTo5Jb3B/lA5pAXI5y0ECiBdYRyeBTSkY5r4BVMMZhiIz7a/NymmT6zyxXp2aunInFWht2IZqnEwjWIoWOFmnA5hLevicB+NqJ++o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 7:wm7dnhLzlbEuSrWwQhCcwgftIo97CRRMNbEbMtW0CduqyXHFOTi4wGwVxfkxwuP1nH/MM/XIJK/SICsDudxl/fvNYdUuWbUei6oBc+kx0pm+zu++JYX7TDqvwNt+vwGp4ihCDiMNpnqc1iqy3vIbcc4DZ4aUYvdFYiCmi3zYUx8RuPZxDEyUHBcLNaZUb8M5CpFM75LU0+i7CbPkF4b4FcqhbThztrojPIoPGAhrp3DTlW3F1eGAsjgFOlP0QR1/PZv0kLZ8MbCivMWYqnsGVWe8lMQya4/SHdPzP/0A/c9anafmqfgCaq1Fw21g54nMSN8ygvqWHGUaCG8NedVg4D3e1e+SJ1CUmjTtNpllCzApQw4jpxMn0SFF/2KbqNxKb23hCYPksWCq+zWsfBhRkTBJzcjcwhiD4k+Z7Wx77e57hieTp0eFCjjEC+v3NZmg5iTIUNYxQkpGFdwxKM695g== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2017 11:33:54.6968 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2248 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170109_033417_844356_C79648E3 X-CRM114-Status: GOOD ( 17.66 ) 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, 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 After that, it will be possible to reuse it in ilp32. Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal_common.h | 33 ++++++++++++ arch/arm64/kernel/signal.c | 93 +++++++++++++++++++++------------- 2 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 arch/arm64/include/asm/signal_common.h diff --git a/arch/arm64/include/asm/signal_common.h b/arch/arm64/include/asm/signal_common.h new file mode 100644 index 0000000..f682381 --- /dev/null +++ b/arch/arm64/include/asm/signal_common.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2017 Cavium Networks. + * + * 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 . + */ + +#ifndef __ASM_SIGNAL_COMMON_H +#define __ASM_SIGNAL_COMMON_H + +#include +#include +#include + +int preserve_fpsimd_context(struct fpsimd_context __user *ctx); +int restore_fpsimd_context(struct fpsimd_context __user *ctx); +int setup_sigcontext(struct sigcontext __user *uc_mcontext, struct pt_regs *regs); +int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sf); +void setup_return(struct pt_regs *regs, struct k_sigaction *ka, + void __user *frame, off_t sigframe_off, int usig); + +#endif /* __ASM_SIGNAL_COMMON_H */ diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 5fa1b40..9f2ea60 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -34,18 +34,26 @@ #include #include #include +#include + +#define RT_SIGFRAME_FP_POS (offsetof(struct rt_sigframe, sig) \ + + offsetof(struct sigframe, fp)) + +struct sigframe { + struct ucontext uc; + u64 fp; + u64 lr; +}; /* * Do a signal return; undo the signal stack. These are aligned to 128-bit. */ struct rt_sigframe { struct siginfo info; - struct ucontext uc; - u64 fp; - u64 lr; + struct sigframe sig; }; -static int preserve_fpsimd_context(struct fpsimd_context __user *ctx) +int preserve_fpsimd_context(struct fpsimd_context __user *ctx) { struct fpsimd_state *fpsimd = ¤t->thread.fpsimd_state; int err; @@ -65,7 +73,7 @@ static int preserve_fpsimd_context(struct fpsimd_context __user *ctx) return err ? -EFAULT : 0; } -static int restore_fpsimd_context(struct fpsimd_context __user *ctx) +int restore_fpsimd_context(struct fpsimd_context __user *ctx) { struct fpsimd_state fpsimd; __u32 magic, size; @@ -93,22 +101,30 @@ static int restore_fpsimd_context(struct fpsimd_context __user *ctx) } static int restore_sigframe(struct pt_regs *regs, - struct rt_sigframe __user *sf) + struct sigframe __user *sf) { sigset_t set; - int i, err; - void *aux = sf->uc.uc_mcontext.__reserved; - + int err; err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); if (err == 0) set_current_blocked(&set); + err |= restore_sigcontext(regs, &sf->uc.uc_mcontext); + return err; +} + + +int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *uc_mcontext) +{ + int i, err = 0; + void *aux = uc_mcontext->__reserved; + for (i = 0; i < 31; i++) - __get_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], + __get_user_error(regs->regs[i], &uc_mcontext->regs[i], err); - __get_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); - __get_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); - __get_user_error(regs->pstate, &sf->uc.uc_mcontext.pstate, err); + __get_user_error(regs->sp, &uc_mcontext->sp, err); + __get_user_error(regs->pc, &uc_mcontext->pc, err); + __get_user_error(regs->pstate, &uc_mcontext->pstate, err); /* * Avoid sys_rt_sigreturn() restarting. @@ -145,10 +161,10 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) goto badframe; - if (restore_sigframe(regs, frame)) + if (restore_sigframe(regs, &frame->sig)) goto badframe; - if (restore_altstack(&frame->uc.uc_stack)) + if (restore_altstack(&frame->sig.uc.uc_stack)) goto badframe; return regs->regs[0]; @@ -162,27 +178,36 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) return 0; } -static int setup_sigframe(struct rt_sigframe __user *sf, +static int setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) { - int i, err = 0; - void *aux = sf->uc.uc_mcontext.__reserved; - struct _aarch64_ctx *end; + 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 |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); + err |= setup_sigcontext(&sf->uc.uc_mcontext, regs); + + return err; +} + +int setup_sigcontext(struct sigcontext __user *uc_mcontext, + struct pt_regs *regs) +{ + void *aux = uc_mcontext->__reserved; + struct _aarch64_ctx *end; + int i, err = 0; for (i = 0; i < 31; i++) - __put_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], + __put_user_error(regs->regs[i], &uc_mcontext->regs[i], err); - __put_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); - __put_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); - __put_user_error(regs->pstate, &sf->uc.uc_mcontext.pstate, err); - __put_user_error(current->thread.fault_address, &sf->uc.uc_mcontext.fault_address, err); + __put_user_error(regs->sp, &uc_mcontext->sp, err); + __put_user_error(regs->pc, &uc_mcontext->pc, err); + __put_user_error(regs->pstate, &uc_mcontext->pstate, err); - err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); + __put_user_error(current->thread.fault_address, &uc_mcontext->fault_address, err); if (err == 0) { struct fpsimd_context *fpsimd_ctx = @@ -229,14 +254,14 @@ static struct rt_sigframe __user *get_sigframe(struct ksignal *ksig, return frame; } -static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, - void __user *frame, int usig) +void setup_return(struct pt_regs *regs, struct k_sigaction *ka, + void __user *frame, off_t fp_pos, int usig) { __sigrestore_t sigtramp; regs->regs[0] = usig; regs->sp = (unsigned long)frame; - regs->regs[29] = regs->sp + offsetof(struct rt_sigframe, fp); + regs->regs[29] = regs->sp + fp_pos; regs->pc = (unsigned long)ka->sa.sa_handler; if (ka->sa.sa_flags & SA_RESTORER) @@ -257,17 +282,17 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, if (!frame) return 1; - __put_user_error(0, &frame->uc.uc_flags, err); - __put_user_error(NULL, &frame->uc.uc_link, err); + __put_user_error(0, &frame->sig.uc.uc_flags, err); + __put_user_error(NULL, &frame->sig.uc.uc_link, err); - err |= __save_altstack(&frame->uc.uc_stack, regs->sp); - err |= setup_sigframe(frame, regs, set); + err |= __save_altstack(&frame->sig.uc.uc_stack, regs->sp); + err |= setup_sigframe(&frame->sig, regs, set); if (err == 0) { - setup_return(regs, &ksig->ka, frame, usig); + setup_return(regs, &ksig->ka, frame, RT_SIGFRAME_FP_POS, usig); if (ksig->ka.sa.sa_flags & SA_SIGINFO) { err |= copy_siginfo_to_user(&frame->info, &ksig->info); regs->regs[1] = (unsigned long)&frame->info; - regs->regs[2] = (unsigned long)&frame->uc; + regs->regs[2] = (unsigned long)&frame->sig.uc; } }