From patchwork Thu Jan 14 17:23:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8034591 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 CC577BEEED for ; Thu, 14 Jan 2016 17:30:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2B5D20499 for ; Thu, 14 Jan 2016 17:30:47 +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 06D5E20497 for ; Thu, 14 Jan 2016 17:30:47 +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 1aJli6-00086V-5h; Thu, 14 Jan 2016 17:29:22 +0000 Received: from mail-bl2on0054.outbound.protection.outlook.com ([65.55.169.54] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJlfh-0005Ul-Ss for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2016 17:27:03 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by BLUPR07MB611.namprd07.prod.outlook.com (10.141.207.16) with Microsoft SMTP Server (TLS) id 15.1.365.19; Thu, 14 Jan 2016 17:26:30 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 14/21] arm64: signal: wrap struct ucontext, fp and lr with struct sigframe Date: Thu, 14 Jan 2016 20:23:11 +0300 Message-ID: <1452792198-10718-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> References: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: DB5PR02CA0034.eurprd02.prod.outlook.com (25.161.237.44) To BLUPR07MB611.namprd07.prod.outlook.com (10.141.207.16) X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 2:rx/CXKDs9B6zl9llk4C3k7rT/WK0GhTYNHrcrzp0I66afOtEiPTqrjZTuj+SF/TicX2Rh+80Bi5BVmPw1nubN5svVxlc0fON0cZg+jvmmIUy/MjHEpjrWEeZiIgXlqbrti3FR7GZA0Ogbeudg04efQ==; 3:rkpvfIdGz/HT+Bn4rvlYs4sZkcmNTfoUdZXbCDWOAoNnC6D6sDzF4vu6THqVKXaXDWzp0MnWEd+HbXKZc/meVMARghHmboXqIpKYXX8oynZtdJJy/w08Ma1BGhX8nFYQ; 25:Ec10PpFuRbVSWSSEV+EMDCJ3jFvKvdHWaDMpltn6HC+6z4a/pQrovF9SDudD3hbPXhQh29m2LVgNc6calybqRDD3RkhFZKPdD3Ot5Y0FMrJTiTlKC7JS3R7CUbDNrjbNZKDo3n6g5UtGyVOoErDh/w7cytmroHMMQTawSOsXAtODAIT6Ww4v1fpPe+zR5b+imOKXQSH7VoyxH3UQsCc+SzORLIL6DeGTMF/gZaQBVwqeXRFkJagtrX6cjD9ncuVt X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB611; X-MS-Office365-Filtering-Correlation-Id: 596190b3-8615-4952-2d09-08d31d07d777 X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 20:P4yL2ptKxYoISC9UmLhqmtDwj/k4zET05dPR9PfcSvUoFKeVkl6H/zzLgw3BfcvLpBmUO2Y2+vJMVXudgCtaBikK6O9J45rWm99wMnTy98Cy64RKi2v+ZUyYznB1Mk8VOk4wbThKkqJ9K+0BATOnVTGRlapfXF5YbvyzV3YfSmtTRzXZ+Thc9gTB8AUFPPHiWy1j4PfzjBGh9GJ7e8f9TeQrnlWUs4+zMYYSQyCI0l8yjG8sVMlbpC9aP5+iCJZ0gIH8T3yYq/LuGjimIFdtUHe0YchD8dqEi3n2iwtCBfctDLM5s0nmLbsh2OXWqcNx/l6cZFeixEdnU0+1xu2Wzkz12Z8MW2WR4utUfNTpnXPsYG5dp7WLvcPDpga3Q1SCzI8H3z06TWAOzeAm5bscGUR2xgVVPukWfPrJzZ/U7NgC78VNQZA51b5sQVz6zdXXrr9Ti3i+N+wUzjf8lidpb2A2zGwNr2RPDak496RfwNKcqJuGbhfN7bpjSK5XcaGMaXeXogQC5lHV8CSWqNXYBTAGEXe5Zxhm1ZV9JDuem9JvgWJmIJIj0cKZIJzY3uIQdlxXTcLECbFuCPgqTcVzDo7UfZFrHgGBxv8neXI52Ng= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:BLUPR07MB611; BCL:0; PCL:0; RULEID:; SRVR:BLUPR07MB611; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 4:mntk0zn79iyLI9GC/e9EyuF+xKxuPtYFYdsvB8NX4x9VvP14a7/NtB73bHvayuaz2AY7pvk2aIID09Lqe8Z74EPIAMbI7YQ6oT5MZHXy6Xci5gg3xiklmcY5Tts9d9OdXuyWGtk3jPOw/CAONZ1klMc5///aYuu/qV5NnwqGw/wE3gWUE3EZsZsccNkjiOsgDOrGs1kgFCzhNhW95geQbzedytFF97U/+DhxSC0cxGRz05p2U2d0WWstfaRbvhQTTsiWoLoG3v7xLrKGG0OypHvbk+HCqjdToe8t7AvltB0r4I1+OkYG8s5mqQg9KMgN1nDytpf5Wx9cYZJZwy8kNFexyHkOOo6tfDfdzb9Io3RmGdiPzcB/FgH6Mh9SnasM4h3FHy5qkuKvo2mc62hvsfq4LKgs5B4aY4Y11/1vKQugmau6hUbmJjo3JcU9oE7y X-Forefront-PRVS: 08213D42D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(5003940100001)(19580405001)(189998001)(2906002)(5008740100001)(42186005)(97736004)(4326007)(19580395003)(2201001)(5004730100002)(81156007)(92566002)(5001960100002)(5001770100001)(105586002)(76506005)(106356001)(122386002)(77096005)(87976001)(586003)(40100003)(33646002)(50226001)(50466002)(229853001)(2950100001)(66066001)(36756003)(50986999)(1096002)(76176999)(48376002)(101416001)(6116002)(3846002)(47776003)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR07MB611; 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; BLUPR07MB611; 23:nPaIwk7pafAQNQLC5Mg36WfDNrDVe+BB6CYglZlLUO?= =?us-ascii?Q?9H8xZaAYPyDEVCxlTCMzxEdLoZPU4npibj+WfZ+6jZmEtbDnoE4Vi7HwY1a4?= =?us-ascii?Q?IPEwCz3hkLz3usO4zlemvTUXrecFz2an7pnPm1oh2JMUfFqeWjCwtTXkp0et?= =?us-ascii?Q?+hS4L5884Covesx1TepnYQo35+JjoqsZacEvSrs0ut1ZT0zmHY19NUcpJeyI?= =?us-ascii?Q?/i7Qd0uf1RhFvX5eeOSf4VqEPLEGnje7IYiq12IMSiB2OLmOGakVaG1P+Ldq?= =?us-ascii?Q?zWf0Wse3VeELUrPFd7V2xSo507fACN5PDMOUcpbq9oeHxTBRcexe8cbnbcL7?= =?us-ascii?Q?xsFXYM1jsoQp6nFKM036cr+4GQYemA+NL+tqoDpJlk/CAqj50ituBU1gz+SJ?= =?us-ascii?Q?qYPz+46I0ddnF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BVCGVv+GDLfi+4dOPYIhkjxokQdVR8PA==; 24:6IDmmrQBVLKLGTU2AvGd7CMBAJMrIKrYCMTO2U/GzMiEMSG3Pwz5D0K5MBMfazrukH728WqapGxB7BnKBKzbXGE66udeLxH/nvhUHEwQTsg= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2016 17:26:30.2978 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160114_092654_950879_8E9BBDFD X-CRM114-Status: GOOD ( 12.34 ) 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, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, jan.dakinevich@gmail.com, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.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, 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; } }