From patchwork Thu Jan 7 23:34:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7980731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B1EC9F3F6 for ; Thu, 7 Jan 2016 23:46:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8780520149 for ; Thu, 7 Jan 2016 23:46:23 +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 89F5C2010E for ; Thu, 7 Jan 2016 23:46:22 +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 1aHKEF-0008Da-Dm; Thu, 07 Jan 2016 23:44:27 +0000 Received: from mail-bn1on0097.outbound.protection.outlook.com ([157.56.110.97] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aHKAS-0003B9-Eq for linux-arm-kernel@lists.infradead.org; Thu, 07 Jan 2016 23:40:39 +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.361.13; Thu, 7 Jan 2016 23:40:10 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 15/21] arm64: signal: wrap struct ucontext, fp and lr with struct sigframe Date: Fri, 8 Jan 2016 02:34:33 +0300 Message-ID: <1452209679-19445-16-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452209679-19445-1-git-send-email-ynorov@caviumnetworks.com> References: <1452209679-19445-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR01CA053.eurprd01.prod.exchangelabs.com (10.141.191.43) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:YZup2PAEb1M2+Q3AaznK1tMflEjOyCEfTlH18ASm+t0MgYT5N6T7Kz7dgCLWcvVtnKfPMTByqpYY/5+GZ3P8F/vdnN8Pv4m9F++4ZfXCI77kN1e7hDHP5Vy/9kUH8A4Nv6Z9Tq2k6XrtTaoMHJmC/g==; 3:NcxjO9idtm6/6ip7f/AXD3A2r8UC7QVtSpO6ZBPb7FuPnobwgZDSJezXCNw4kkdyyKBcTIUpefpJ39XNwIWzPceCuI5+BKfpjyQuiWREOApfyQ+pMTZ97hjU9EhnAP5l; 25:gkZjXn5SXzmLJr6ua+PhGZHAgYOlHzdKj1CDlJYz4vlH434XxULv99TAaAWEDy8+8qQzYj+EQX0jzB8T1CsHU2KCJl/whcTu+EJzQD0Ibnw5WO2Rojksi38Ejm0/SXr9G0dV347lxHm/l3Yc9smgpxIn5BfU6O068CSHJzTJ3ffzwxFXwbbTMTJoHabMhYWb1chVMIE6YAE6B8Bm8X7X98oyAgbeDPoShOGnyHeUgHcJ0szOmfV7OzXBrWDl4eRY X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB624; X-MS-Office365-Filtering-Correlation-Id: cd268895-7af2-4be5-8e0e-08d317bbe1cd X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 20:11P6nMf0yhlofOr4lGNwjx8UWjT0IT8iC/BEaL7+bw1fvaOSJej2xm3A1Gi4/IG/3xQIdB+yA3dLXpVOPXYfDcINBEKrSZCKpOfOo3zbhGHFmjhfroW7/iTvSNRNtShNSJ86TZxxueZk4OvUw4bvRWjf1ZwVXeShSBOWbElMyt/DKJjpJoB8PJzaxZAWlsd7dEzIcu27U8TzSEqB2qebeXL1i10vYa1tjD6CcV1vMR7xIXigKJeiynBYcR+8z4bxhPMQDEDgVIln3tdiSh/iLGjaSkfnjl6KEet9FAEGuOhJZ+G+jnpEBbGIfxdU2VN2BgIOtEyXKYUnroE/14a3Z7qZ2pAXXnng8RxW15nF0bW7dXSstTIZstGt83G0kATn1FMehmYECfk7puNA1Nya6FmmDVrI8ZH7an/4mDcgU+G5gabyk34UAoIGdZ/M9F5toGFiP4IMOJ12DO0yGZx4OdPhFDKJhqy0NPj25dTm6j1jdqhEq71ICCZ4mCu/UQpRZtIcNqbeklR5bn5uYLQi2JwGKAbdDGqFGHwtVpLl09VGCx1LWavV6yp9yiIurGiy77I2ltMiyOe2mNg4k1ERHQevwvyZyG79q57/Dzd8ALI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(10201501046); SRVR:DM2PR07MB624; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 4:XkePUC3cVM6vdPp+PdAcmMGFKWY+Wm5Ar1DtVIis2OErfivJcKPSK96YxTDz4y1TumGkf9fkUYLEIWjJEHPvHJ+QDFuH0n7qaeRBN1KcYo+UPjqO3xMiPxYumw+OEB2uAOUdNwAmsRU5fV7rX5/M8hEBbl9eo3rlwW9N0WAxMM8iU+xDXoNw3H28PeG7UGS7wk+50HgQH7PepiNhX1m4xBIdGXma59NBlEzaEO+E7pNJbp6yGgW4T10PlbrqMmUD2/PV9hlzGRh8orF2Dwh2NR2gzdgbyWZR040/I/eFaPG2DFH6eC+LG7zG6praPHNo/1MWsFxl61Zvlt1ZVOX2LeozCovu1HI/DxA6ncItICHRq4AJVOSo6AYTnkvihi7zYcE8D/jKwSZezP9dGhRBtGpmtBvNGhreW5p8LG5s/J8WHlM9ObSZ37NUXLhL9swa X-Forefront-PRVS: 0814A2C7A3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(76176999)(101416001)(50986999)(47776003)(106356001)(2201001)(19580405001)(19580395003)(66066001)(2906002)(87976001)(42186005)(76506005)(105586002)(229853001)(5001960100002)(189998001)(40100003)(77096005)(5008740100001)(586003)(122386002)(1096002)(36756003)(48376002)(33646002)(81156007)(4326007)(6116002)(97736004)(5001770100001)(50226001)(50466002)(5003940100001)(3846002)(2950100001)(5004730100002)(92566002)(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:iAlZyCjg32yAvCjq56o6hn6zIMZuIuZ3kluvJvKXF1?= =?us-ascii?Q?XtLEhYWyLpfXh2RP7i3NmQjBJRMrRPkN0tprpu+df/jymfdwwAB1FFM7OOWw?= =?us-ascii?Q?NAaZu5+l8l7vmsJ49OIFRkdKE5/hKYCv+vcweSHHffwOxnCnKDLiiQOX9lqz?= =?us-ascii?Q?3F0oGLWZCWWjqALsT1rd4CeCEEcxoM++5k1/tjomIEgCEENaCbzuvUQrLcCI?= =?us-ascii?Q?i37I9f5nywec3f0wgVAXCcf26lwNom3q3falCNLQj9rjohd8DA231IRHcbRD?= =?us-ascii?Q?arPiQ3UBI9/5zsJFRgoQ0DrGNexWMjx+tF9lpXctkPw+KwAlcHMP0ymhh4yB?= =?us-ascii?Q?hSiid2aUevTxM0MYgoFRUTSUSIn+G5Q3iQXDO2fh4ULNukW5TXtHeRNi2DSo?= =?us-ascii?Q?eW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NcvslSL4K6rhQtSVw==; 24:eurtSKuhrn5ezjnJ3E5v0vX7CYtbju9H2upgFsF99j+AMbpWLQevKd1SDO/nM5Z/HZ1bVv3trjTwotlfatcmm0kQtBEVj3gsqGldKmtHLKo= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2016 23:40:10.0133 (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-20160107_154033_296780_D60E2B1A X-CRM114-Status: GOOD ( 11.48 ) 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, 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; } }