Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754336AbbLOVtw (ORCPT ); Tue, 15 Dec 2015 16:49:52 -0500 Received: from mail-bn1bon0081.outbound.protection.outlook.com ([157.56.111.81]:23840 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933609AbbLOVtt (ORCPT ); Tue, 15 Dec 2015 16:49:49 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH v6 15/20] arm64: signal: move ilp32 and lp64 common code to separated file Date: Wed, 16 Dec 2015 00:42:41 +0300 Message-ID: <1450215766-14765-16-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 Content-Type: text/plain X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR01CA054.eurprd01.prod.exchangelabs.com (10.141.191.44) To CO2PR07MB617.namprd07.prod.outlook.com (10.141.228.143) X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;2:qs/xdDHNqi9Us/w8f7X3FpwDT4vHiNYYhS3MDBel3JccbuyFA21B2p4Ljj3v8bPDGEykHT3yeOxBCHDSpkwP5KAlj2n2rah5YahtAhmvBqKbDW22H37uVZXx19mgSLRfFHvg99vucWxLJ/JLNIn/Sw==;3:TO1iB5jAQtU5M2MHNIJJHaCgM2BmKNPuWTqC2shXnlJdgDqSKINDNv0x3KULrmZvw2wMBpyUQbpf0Ps+Linqjyha+xDlrhEAdRlwdncizsuvndHBl3PDSz8sIhOgUYzP;25:yI1/cdNbJZcMy4F+OofgDVzeGhC0VMODwucVguyVBgkvRMt561JmyUGqcBcKNpppNTIe4dr/mjizVME1El2kuXwgKOPbn7qxaUCpXW0FD48N2yOaDWoWzzMI499VuwAxOP371zw2w+2U9wGIVnaxC/gIUh9RWy9yox71AHor5XJJklhVx09aEgVIZQgIYAImPldeI98Z9OXW4m5kgquA6BC0o4V2CBJ86UyE5QHyP2GqzfgzAFANEqlf7Mcp65Hf X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;20:/eFKCrs+k3cofmfcmX5PEcl1NYG2+nF4IGP5+3OlhHmlbTwqqVZQbOdtgyrJmOhpxhvk6LOWjSVp+SPsmhE7K8pYcYLKG/U0ydm0opOdUmAm2huT/nvGVF0AU6m6RunZ/Mn4rxPdpIWn6mRh3JG1rh/kr11qKtHGBBBRb5sl6BAASVLJ+fVqoBcxRU0+scM78nZcZwUsF24A/ATj/wAiDuGFzp3rPjT/4l6sLZD1ZrQ+AZ1qnprBVtc2niZGM+l69TcpPPln3ACu9agL298fJJOVpILcSrCP3ISWGBNXIiLsX6xcqg86kkdSBK7Bgr6K5qC71mo+A1RZuZDV3xlDvyp+/1dAhJMrcRx29n8VeLggwfoxEpb8s8eCImlO4w1/b86qo8TJmytyz9Kd7j9LYcoTbS08L/eaujM4RKAHNoHcxFxaD1d6rbQvDLjTTJ9OMC77R4h7nYUo6gnMLF2Gv9qnY5o2F82CldtwWWReWmkZr7/gwFSnhF/YEM5gDxFv8Q7/7aHGBrCwrCAQhDxBdOXqSsl5pxdhqBxgVSvBIvw0KOeOUxLQK4FQmRiYc+0taA2uRIjnfbn5O5+v43yNEdgHvLL7lVSwRJS5MceurKQ= 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)(520078)(8121501046)(3002001)(10201501046);SRVR:CO2PR07MB617;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;4:qcTxF3SlVOEW9cW2yinpYtap//kqyKchWzpMMAf6UjaSVnIfD5xdUB8ZJ6UYGdTO50WQGb3bm3lq9wKttn4dIxEpr1lLdduVkrib+rUa1lVYK5U5Q5GUUPtpdp60gsKOLEmgnXLd5S2+YVheIA7oqGP96gBJigO2uIYurodYKg9CRjFJaslwuV9rkQiN/uTSWBRt3XG/s+EvRggz8Fx5khO/Y5zb2twa6idn0KM+AYy85zrB9vPdUprbFOGl6GGg+L/rw1dUa26IYpJh8eOJoGlyF5uaTBdKBO5i/WH8zoEE9fBi4SDIXGFkgS2XpmxCmOZCnmb+izDJ5q+5+2PU/WjFXSEuu3EU3SQnIj/YyDhdlM1RwOg7EyRA28t9J4SLfs5MOnjYJMTDDqZIlV+L251lYxmdVT0+FIXFMRTeAC0= X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(199003)(189002)(229853001)(66066001)(101416001)(6116002)(3846002)(50986999)(586003)(36756003)(47776003)(189998001)(81156007)(76176999)(5001960100002)(105586002)(40100003)(87976001)(92566002)(33646002)(97736004)(5001770100001)(1096002)(122386002)(5003940100001)(50226001)(50466002)(5004730100002)(106356001)(77096005)(5008740100001)(2201001)(2950100001)(19580395003)(19580405001)(48376002)(76506005)(15975445007)(42186005)(2004002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR07MB617;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR07MB617;23:8HAyCSDBnoN3yfmEINyd4W7Nkve/yRib2SB39yC/c+?= =?us-ascii?Q?KtwuMAPIQjzEm2UXKwpYBzxzwOL9SCMdwJDwD7sLYPYKn4o7TmDkme3KSygC?= =?us-ascii?Q?UCddXdDLxxqX/7SiOht78wVr/fli1/JdJ6f6YX7kJx8ThD7DN7bVPQ02NMDu?= =?us-ascii?Q?QvS35rkyTMKmD+2pqO1k7WKuuFOTvy3OHJSDwKogidfhNVURj+QkQkuFkdVT?= =?us-ascii?Q?IEXYfayisJyTv+R2PsKQwsnSk/UjbcZ7oYW57l9G/oMQ448ZrmE4B3W69y8b?= =?us-ascii?Q?AHPtLYH1eZbD2JOoDJwMVVTbV3I1eWf6Y5abbOVUAQ4A7Zr3nQgbveXdeUef?= =?us-ascii?Q?Pa7s+NSakklGlf8F3n/oNV2y1uI7OlBDPJhB00D3meHXXhfjeJtvgplWOvb1?= =?us-ascii?Q?t7PTnD+aRm8Tz763y/MQY+ZYqIAOf3ry7zWtsaULJfn0i+GcTwQ98gsoNq6H?= =?us-ascii?Q?hl2YfxXp4XkdlCKv+siVp+2fl43NFhyrDIRoRTGoge42fjQ0oemi96nxLFhc?= =?us-ascii?Q?9oh1AdsGUWG5mnthYcGhbKfNRED99sJ9iZ/OruAqyC6qMFF2iZ2QoKXgj51a?= =?us-ascii?Q?g0wLfppamXLuHveXjhkvI+ntMm1V8mGVC9u2G+TlhdWMniS3cTK/obfd5EcJ?= =?us-ascii?Q?tUMU35E9c6+u1kvNlyW4J0QlUh2/49qV1r8C9M386HR8+xyLU/DG4+2F4JrF?= =?us-ascii?Q?fBhCDkMz9GewNOBIwsCGDmcdD6sJSb5Tq2SC0LROSfGFKPdBxkRYEP9UX5x0?= =?us-ascii?Q?J4XywiVyPFICNleh6j67c9xG/1w8CFKYfhQ4ign+IS7xX1eS0DDR4yacJwxV?= =?us-ascii?Q?jB1GbnBmCVklwtomXvGTUXZLEKHxXsGbKoznxB+lsI/A8x84q3enDCPpCfIU?= =?us-ascii?Q?H3Xbd3DWPU486qIsefVjWlBEbQvkaeivwDb2MghgKtkH02aoXAhAJIeSLMek?= =?us-ascii?Q?ZtR2dDLh6PYqcqGMs+vEi34uFx3zP33V6mmJaCKZ77D9aEMpVpuDvwHdqAQx?= =?us-ascii?Q?Ww/Xk52Im1Rb62aY1tRcod26mvyFF4vZEC2Wjq9rn4Kqlk/T9EF0rXzt8zYt?= =?us-ascii?Q?ZyHaArKxJ0Pen6mm8C/eGiK/ZWRodejcPxYwbypbZ0dkZ0T+1Bdp8m5yYzus?= =?us-ascii?Q?WNDuTdODqtfYl33Tlbnw2p9BI0nIzr?= X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB617;5:B1FnCRRYyG4ttAxIM0lRnFetZpEcp8XPotONJE4tYOrfEuc2+5rxQ7MvX1EmkkHazcjRSr1XN3AMtgY2K7aGsLotWDL8cfGiWKUyeOaUmZi6hq0Te5SeXJCk5PEDN47Fdiiipyp48lPj+2YkY0Ol7g==;24:C04VbZaY8TBbp9BkdLHGG50xPtE6UzF8bI6Bq+35wi0ODc0n3Ok7b0c2f4YmXQtkR0TRqDLnPimcwgVy7qKdI1rJ6I+cCgMyv93iN74oFhw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2015 21:49:45.7463 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB617 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13949 Lines: 444 After that, it will be possible to reuse it in ILP32. Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal_common.h | 39 ++++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/signal.c | 154 +---------------------------- arch/arm64/kernel/signal_common.c | 174 +++++++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+), 154 deletions(-) create mode 100644 arch/arm64/include/asm/signal_common.h create mode 100644 arch/arm64/kernel/signal_common.c diff --git a/arch/arm64/include/asm/signal_common.h b/arch/arm64/include/asm/signal_common.h new file mode 100644 index 0000000..2fb3997 --- /dev/null +++ b/arch/arm64/include/asm/signal_common.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2015 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 + +struct sigframe { + struct ucontext uc; + u64 fp; + u64 lr; +}; + +int preserve_fpsimd_context(struct fpsimd_context __user *ctx); +int restore_fpsimd_context(struct fpsimd_context __user *ctx); +int setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set); +int restore_sigframe(struct pt_regs *regs, struct sigframe __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/Makefile b/arch/arm64/kernel/Makefile index 837d730..94b8b84 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -18,7 +18,7 @@ arm64-obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ hyp-stub.o psci.o psci-call.o cpu_ops.o insn.o \ return_address.o cpuinfo.o cpu_errata.o \ cpufeature.o alternative.o cacheinfo.o \ - smp.o smp_spin_table.o topology.o + smp.o smp_spin_table.o topology.o signal_common.o arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o \ diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 20dca65..4b8efe5 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -33,13 +33,7 @@ #include #include #include -#include - -struct sigframe { - struct ucontext uc; - u64 fp; - u64 lr; -}; +#include /* * Do a signal return; undo the signal stack. These are aligned to 128-bit. @@ -49,87 +43,6 @@ struct rt_sigframe { struct sigframe sig; }; -static int preserve_fpsimd_context(struct fpsimd_context __user *ctx) -{ - struct fpsimd_state *fpsimd = ¤t->thread.fpsimd_state; - int err; - - /* dump the hardware registers to the fpsimd_state structure */ - fpsimd_preserve_current_state(); - - /* copy the FP and status/control registers */ - err = __copy_to_user(ctx->vregs, fpsimd->vregs, sizeof(fpsimd->vregs)); - __put_user_error(fpsimd->fpsr, &ctx->fpsr, err); - __put_user_error(fpsimd->fpcr, &ctx->fpcr, err); - - /* copy the magic/size information */ - __put_user_error(FPSIMD_MAGIC, &ctx->head.magic, err); - __put_user_error(sizeof(struct fpsimd_context), &ctx->head.size, err); - - return err ? -EFAULT : 0; -} - -static int restore_fpsimd_context(struct fpsimd_context __user *ctx) -{ - struct fpsimd_state fpsimd; - __u32 magic, size; - int err = 0; - - /* check the magic/size information */ - __get_user_error(magic, &ctx->head.magic, err); - __get_user_error(size, &ctx->head.size, err); - if (err) - return -EFAULT; - if (magic != FPSIMD_MAGIC || size != sizeof(struct fpsimd_context)) - return -EINVAL; - - /* copy the FP and status/control registers */ - err = __copy_from_user(fpsimd.vregs, ctx->vregs, - sizeof(fpsimd.vregs)); - __get_user_error(fpsimd.fpsr, &ctx->fpsr, err); - __get_user_error(fpsimd.fpcr, &ctx->fpcr, err); - - /* load the hardware registers from the fpsimd_state structure */ - if (!err) - fpsimd_update_current_state(&fpsimd); - - return err ? -EFAULT : 0; -} - -static int restore_sigframe(struct pt_regs *regs, - struct sigframe __user *sf) -{ - sigset_t set; - int i, err; - void *aux = sf->uc.uc_mcontext.__reserved; - - err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); - if (err == 0) - set_current_blocked(&set); - - for (i = 0; i < 31; i++) - __get_user_error(regs->regs[i], &sf->uc.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); - - /* - * Avoid sys_rt_sigreturn() restarting. - */ - regs->syscallno = ~0UL; - - err |= !valid_user_regs(®s->user_regs); - - if (err == 0) { - struct fpsimd_context *fpsimd_ctx = - container_of(aux, struct fpsimd_context, head); - err |= restore_fpsimd_context(fpsimd_ctx); - } - - return err; -} - asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) { struct rt_sigframe __user *frame; @@ -166,53 +79,6 @@ badframe: return 0; } -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; - - /* 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); - - for (i = 0; i < 31; i++) - __put_user_error(regs->regs[i], &sf->uc.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); - - err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); - - if (err == 0) { - struct fpsimd_context *fpsimd_ctx = - container_of(aux, struct fpsimd_context, head); - err |= preserve_fpsimd_context(fpsimd_ctx); - aux += sizeof(*fpsimd_ctx); - } - - /* fault information, if valid */ - if (current->thread.fault_code) { - struct esr_context *esr_ctx = - container_of(aux, struct esr_context, head); - __put_user_error(ESR_MAGIC, &esr_ctx->head.magic, err); - __put_user_error(sizeof(*esr_ctx), &esr_ctx->head.size, err); - __put_user_error(current->thread.fault_code, &esr_ctx->esr, err); - aux += sizeof(*esr_ctx); - } - - /* set the "end" magic */ - end = aux; - __put_user_error(0, &end->magic, err); - __put_user_error(0, &end->size, err); - - return err; -} - static struct rt_sigframe __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs) { @@ -233,24 +99,6 @@ 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, off_t sigframe_off, int usig) -{ - __sigrestore_t sigtramp; - - regs->regs[0] = usig; - regs->sp = (unsigned long)frame; - 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) - sigtramp = ka->sa.sa_restorer; - else - sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); - - regs->regs[30] = (unsigned long)sigtramp; -} - static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { diff --git a/arch/arm64/kernel/signal_common.c b/arch/arm64/kernel/signal_common.c new file mode 100644 index 0000000..7043e5c --- /dev/null +++ b/arch/arm64/kernel/signal_common.c @@ -0,0 +1,174 @@ +/* + * Copyright (C) 1995-2009 Russell King + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2015 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 . + */ + +#include +#include +#include +#include +#include + +int preserve_fpsimd_context(struct fpsimd_context __user *ctx) +{ + struct fpsimd_state *fpsimd = ¤t->thread.fpsimd_state; + int err; + + /* dump the hardware registers to the fpsimd_state structure */ + fpsimd_preserve_current_state(); + + /* copy the FP and status/control registers */ + err = __copy_to_user(ctx->vregs, fpsimd->vregs, sizeof(fpsimd->vregs)); + __put_user_error(fpsimd->fpsr, &ctx->fpsr, err); + __put_user_error(fpsimd->fpcr, &ctx->fpcr, err); + + /* copy the magic/size information */ + __put_user_error(FPSIMD_MAGIC, &ctx->head.magic, err); + __put_user_error(sizeof(struct fpsimd_context), &ctx->head.size, err); + + return err ? -EFAULT : 0; +} + +int restore_fpsimd_context(struct fpsimd_context __user *ctx) +{ + struct fpsimd_state fpsimd; + __u32 magic, size; + int err = 0; + + /* check the magic/size information */ + __get_user_error(magic, &ctx->head.magic, err); + __get_user_error(size, &ctx->head.size, err); + if (err) + return -EFAULT; + if (magic != FPSIMD_MAGIC || size != sizeof(struct fpsimd_context)) + return -EINVAL; + + /* copy the FP and status/control registers */ + err = __copy_from_user(fpsimd.vregs, ctx->vregs, + sizeof(fpsimd.vregs)); + __get_user_error(fpsimd.fpsr, &ctx->fpsr, err); + __get_user_error(fpsimd.fpcr, &ctx->fpcr, err); + + /* load the hardware registers from the fpsimd_state structure */ + if (!err) + fpsimd_update_current_state(&fpsimd); + + return err ? -EFAULT : 0; +} + +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; + + /* 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); + + for (i = 0; i < 31; i++) + __put_user_error(regs->regs[i], &sf->uc.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); + + err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); + + if (err == 0) { + struct fpsimd_context *fpsimd_ctx = + container_of(aux, struct fpsimd_context, head); + err |= preserve_fpsimd_context(fpsimd_ctx); + aux += sizeof(*fpsimd_ctx); + } + + /* fault information, if valid */ + if (current->thread.fault_code) { + struct esr_context *esr_ctx = + container_of(aux, struct esr_context, head); + __put_user_error(ESR_MAGIC, &esr_ctx->head.magic, err); + __put_user_error(sizeof(*esr_ctx), &esr_ctx->head.size, err); + __put_user_error(current->thread.fault_code, &esr_ctx->esr, err); + aux += sizeof(*esr_ctx); + } + + /* set the "end" magic */ + end = aux; + __put_user_error(0, &end->magic, err); + __put_user_error(0, &end->size, err); + + return err; +} + +int restore_sigframe(struct pt_regs *regs, + struct sigframe __user *sf) +{ + sigset_t set; + int i, err; + void *aux = sf->uc.uc_mcontext.__reserved; + + err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); + if (err == 0) + set_current_blocked(&set); + + for (i = 0; i < 31; i++) + __get_user_error(regs->regs[i], &sf->uc.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); + + /* + * Avoid sys_rt_sigreturn() restarting. + */ + regs->syscallno = ~0UL; + + err |= !valid_user_regs(®s->user_regs); + + if (err == 0) { + struct fpsimd_context *fpsimd_ctx = + container_of(aux, struct fpsimd_context, head); + err |= restore_fpsimd_context(fpsimd_ctx); + } + + return err; +} + +void setup_return(struct pt_regs *regs, struct k_sigaction *ka, + 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 + sigframe_off + offsetof(struct sigframe, fp); + regs->pc = (unsigned long)ka->sa.sa_handler; + + if (ka->sa.sa_flags & SA_RESTORER) + sigtramp = ka->sa.sa_restorer; +#ifdef CONFIG_ARM64_ILP32 + else if (is_ilp32_compat_task()) + sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp_ilp32); +#endif + else + sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); + + regs->regs[30] = (unsigned long)sigtramp; +} + -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/