From patchwork Tue Dec 15 21:42:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7857651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1437BEEE1 for ; Tue, 15 Dec 2015 21:52:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16C8D203E3 for ; Tue, 15 Dec 2015 21:52:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 310552037F for ; Tue, 15 Dec 2015 21:52:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8xUt-00012z-8z; Tue, 15 Dec 2015 21:51:03 +0000 Received: from mail-bl2on0074.outbound.protection.outlook.com ([65.55.169.74] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8xTW-0007B0-AO for linux-arm-kernel@lists.infradead.org; Tue, 15 Dec 2015 21:49:41 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 15 Dec 2015 21:49:36 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 14/20] arm64: signal: wrap struct ucontext, fp and lr with struct sigframe Date: Wed, 16 Dec 2015 00:42:40 +0300 Message-ID: <1450215766-14765-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1450215766-14765-1-git-send-email-ynorov@caviumnetworks.com> References: <1450215766-14765-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR01CA057.eurprd01.prod.exchangelabs.com (10.141.191.47) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:zTYYxxa9qFNZPSzhoKyXB37T3csk0WuIjtBpp4cZc+96mMXFhGMHVbbP+u6mJEuMvncmyRZtcpJ3dnqt151ZWmkHqZiI9jOxaXJxq16IK0H9zQM4ts+t8HDz77R+GIXYdOyciiCdlvyFzrLtkZYidw==; 3:v3irwI9NQ8AHjJ9Xiwk2Hyp5XdlwR2EFH/WZmJUTPeZE7xEfucpF+Tg6v5VaKZXdNo5FzyiD1rgEdjGXIXrfOJPT8N//Tau7FHu3dd24oOTW3f4BKGz62xMhfuRVNT/1; 25:RIeqzkTB4FKiND98mtbgvbVAEI+hAr5wNRn+74c7qhIdJGwFJqwzG8gtslbzYVuOAvT/Det+pABGv/M5D+jtjVwuULzY2Ft755ym46zabQsvcdxXKPFgoyKmLjJ6ThsVBw3ye5HZr31g569FI0Rzi64upRJmK5nxrxN2Ww/PQ3KjbdfnAdtDPY20+igfwQFur31s8punp97L8LjCYKhekHHkIaC4rlNG0BTAsnl5nsC7VjUdLUjXqDOlL1qDw8KQTvkbTMiHZ313Z2+7cAGwKg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 20:xNn9fNJxFF4edrzO7AW62JF9sD7WqJU7Tu+R/kFxT3Ff+20KwObEzJdT23g1zsdPZfRLOvx4vXDlj4q1DM+4gRlcdehMVYwbF/13o4Q/3hGGZR8O2nOMdcN25H4VgtAX5EZdJu4TPzocG0QwQM9JozrbZFO2kEiYV2psHt4YN8YHcMkSWzv3s5ioMYutkUFWXPOXk9PbkMhtt1+88RVEF95GFppJCyHsPCLIsq18IRkTdTlO4LQ6Ozl9epNH+P+jQUbxMS1aywDSgmkDNwyStHg4SqRz0/wcNe/kRZ+c0TlotYzuPL69c7IdqInAUT1mn7M70XDH2GyJhzd4WUpXNQE1GoIzUR/wRgpJ4RI0FuNtVIrA80P1TX1BF06NRXEjku83ztN8NKd5oPtrN3nzZ+7KUpJiG2/60daMbhwxZL3xAFIGhQVUS7O29cRK4QBZwFpXg4BJ6P6FyN1zuF0Epe73EG1BYobkbwucELSdXjbd8MRPjEkFIGYqfJI0DTwnsOMCV3kvQFRgovGicbJrRb9KSq3mdG298jM9MSAjVXotdDPjszkeVMVlcBvkLKZXojI7J8oh4ACVGCVPuSWqT8VzM6yc2yO0OyFr6e6IodY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001); SRVR:DM2PR07MB624; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 4:QT7ke8l/wuJmeopTylHJksL+6qmJ8oPRnzMIK318asEmjj4IGZ09/VfdtjcZFC4nQMBjJmZU7W0AHG1ICJZ4cMvCNBSSwyePdVF8lPR91Avpo4gox7SqKvMDgjAjl41j5lwbcU6Lib1+Q9xmKiWxKNhybxEqQsHuW0FKcmTyAR65nCAg9prF1tYpaza1Dz46zpMYcrUet6qktejjVb//yAsc4a2r5hiO7+dt84TaQYzkZeeXRjvy3JjC/g2cOn1t/jh890NpkhShcqA7C2CGS6vqZF2txVKXIkAuTA+0oOekEWeyFIiESWjJhx6iXQrqiRA6rqesyIZohWqXKJkKb42A5iRoqCCJQuLH/TWUWk+6ZIK04Qr//gXutnDwUEiI9GkIwwCD2NADJZzag8QMBAA3mdoMDob6lkZ5dvTwOHOiqH4zhx2gUJcm8kjo8eLf X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(87976001)(66066001)(229853001)(77096005)(42186005)(2201001)(122386002)(5008740100001)(92566002)(105586002)(50986999)(76176999)(76506005)(40100003)(106356001)(2950100001)(5003940100001)(19580405001)(3846002)(5001770100001)(50226001)(50466002)(47776003)(5004730100002)(5001960100002)(33646002)(19580395003)(101416001)(81156007)(586003)(36756003)(6116002)(189998001)(48376002)(97736004)(1096002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB624; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; DM2PR07MB624; 23:r+yBY/haD57VpSDpqq4rprGiKS84eQNOScHdwpTKhn?= =?us-ascii?Q?UP1fQvIiiz3xAEZP/zjso/2vAD28YIp8K59gkoGqipLuz/fJ2YSCc29WszFN?= =?us-ascii?Q?P/3W2nr2sroqktZeLNWrp/0CqOlRDzMNyaCFZdYjORdHsYMpNOQdpb36yKcc?= =?us-ascii?Q?vy/oa/rhaTax95Guj9f3zVrpr8wmJYON8+KP+iXgZ0JvQpvGc+6cc/LMurZH?= =?us-ascii?Q?1FwreU97ds5qzdzVOiE8BOvW3kXLI9lsCGREJK7meW77mmthga8iK5go+4Dv?= =?us-ascii?Q?O6q5Bq0m68Ngx5xdIybJ6+usNkWr4ytPIQ19UVnY4PKYm9/n4KMSW9Nozp6A?= =?us-ascii?Q?SDtM3xJRC5UEh4iD4LBEUcZ9aV2gBjNApEEFt+JEGwP0mCjEqEUC2rkRbKKQ?= =?us-ascii?Q?7ZqVnKZFOw+pTyKh9GkgoXQzHm7yww32PDEt3rFpuOoC9Op/PiduUBqCX+ge?= =?us-ascii?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/+2Z5RdlD2ka48CFJtbw9NocHj8m8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2015 21:49:36.9642 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151215_134938_795406_CB73F6B1 X-CRM114-Status: GOOD ( 11.98 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, jan.dakinevich@gmail.com, ddaney.cavm@gmail.com, bamvor.zhangjian@huawei.com, philipp.tomsich@theobroma-systems.com, joseph@codesourcery.com, 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It helps to move common code for lp64 and ilp32 to separated header. Signed-off-by: Yury Norov --- arch/arm64/kernel/signal.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 65baaef..20dca65 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -35,14 +35,18 @@ #include #include +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) @@ -93,7 +97,7 @@ 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; @@ -145,10 +149,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,7 +166,7 @@ badframe: 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; @@ -230,13 +234,13 @@ static struct rt_sigframe __user *get_sigframe(struct ksignal *ksig, } static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, - void __user *frame, int usig) + void __user *frame, off_t sigframe_off, 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 + sigframe_off + offsetof(struct sigframe, fp); regs->pc = (unsigned long)ka->sa.sa_handler; if (ka->sa.sa_flags & SA_RESTORER) @@ -257,17 +261,18 @@ 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, + offsetof(struct rt_sigframe, sig), 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; } }