Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754430AbcCZWqj (ORCPT ); Sat, 26 Mar 2016 18:46:39 -0400 Received: from mail-bn1on0071.outbound.protection.outlook.com ([157.56.110.71]:30976 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753393AbcCZWqf (ORCPT ); Sat, 26 Mar 2016 18:46:35 -0400 Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=caviumnetworks.com; Date: Sun, 27 Mar 2016 01:46:16 +0300 From: Yury Norov To: "Zhangjian (Bamvor)" CC: Andreas Schwab , , , , , , , , , , , , , , , , Bamvor Zhang Jian , "jijun (D)" , , , Ding Tianhong Subject: Re: [RFC5 PATCH v6 00/21] ILP32 for ARM64 Message-ID: <20160326224616.GA11603@yury-N73SV> References: <20160129170929.GA3543@yury-N73SV> <56AC38F1.2030608@huawei.com> <20160218223506.GA7816@yury-N73SV> <20160225202855.GD16123@yury-N73SV> <56EBD84D.2060009@huawei.com> <20160318154918.GA1595@yury-N73SV> <20160321184012.GA26563@yury-N73SV> <56F69291.4050205@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <56F69291.4050205@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: VI1PR02CA0009.eurprd02.prod.outlook.com (25.162.7.147) To BLUPR07MB611.namprd07.prod.outlook.com (10.141.207.16) X-MS-Office365-Filtering-Correlation-Id: 8b559f26-3836-4f5e-4e4b-08d355c87a13 X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;2:1ZwbxCWng2deZTuwTRlPUG+QRFmK8vxsFgxUpX2aiJY/Rst/kTWuTjrmJLfvV4yHQcMpZ9St0UytqT1HPRo5q3t1MYntjqn1pxd0Lw468OA7wv6EqSa2MENzQwsv4vgLv5xKGY3GzSZdsRwSOL3TJhJErOB1cLv7TPePbmIk3gvxmsbN022az664+L+2xmi9;3:ybpYBrvDJYl8x0k87Xgd2MkjkNLhbketvSDcM+WNIBTB+tiVa9e2njTMrQQDiWIozscnKXLBFRqXkxaObU7U9TrKWif4obLqTev6dYBqgHjBpDGvaBq6L3/yQpPb5pwV X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB611; X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;25:4uvQGouyWLmNlKWaHadxIwOkJbLPTgKJY1YB3Xm87CapgZx07Z8ONQ11d6H7U5e/O2eu3PafDMCsVcN8u2mcNesfcWp7gq0Ygs9UJFH+R/wgJ541UDgyB9uEVMEvJJndTu3KkxGqpvnastcqkY9RIZVShubFuZbpCY/fv4ZxROdaBd+bVpV0irKKgtSb1p6adxeQ0zjrcO7uG4cQ61XKal+wL2unyiCwrl+SkC1Ohw5WTch/4Szm0ahOazclap837zG9t4YdRUQ40rwo1n6asDxXtHGgrcAqwS7AjDBeASAdDo9P1Du487d7EtHHgSjmw/wT3Uel7kWwv+v/60dJsnPl/hFRKeLrqRkaZmAH5BOncPEnpMPNc97bn6bLYV0nzR2BgRY7qA0T61CZCYutqHzWzhXyVu/g8yUB7hdcTacRqYZb4gj3qAvjpw12R/W6TFoAHreA2CG+6n3/yPp7YJDnAHimnSOlUVAvrSg0dlXxDDxMa6MtMxDAr8A6S425qkhMkp8R+jiY/H5Dt97pIIC1OpfwedD2f9E0by8lPup/zvnsQcIpE4zjGmeYy6sshrVWqdNMDspvD8p/6HqRBbrmwkoGj/lCKEasRjwbN9IU3zhEhbRGJ1zOtLUEoTYb5zvRvaglsC18G0uwxkUK4DxKqthcjfRLViPG5sMD19zBxtuqlPKJjTZdODAbhrpnHa4QigHqpZ3eP0ultdC1Eg== X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;20:rumyWiQaxwaGR94GYENY8PyxrI6VmFPI+G0U0EVindgOdPHMBTtcSsYuwX7D2BN7BNF2+OcKI8fS0qeaY+BGr3fws0RI8H03LD03pym5kmFgFGmNhiTcPOSmjCCBoeXND9OGF+YcRPpetGaI00DgxYyyBmBLWXnlmSb+XCRyehZv72G5lK/Um7y1gOZhDTHy0E+kk+dIUoTdsJRWcZmKgIQoBIqk2Dtzu1aLPiiEyiQhtkmZarISZmKGmJMhgaOFLblfMoRRfuYysPxsUhMxtAWLDh++0qI/7m0ahLwvKapQRowO2QHuxoB2c6RyYOL//JRaWnKOku9eIPi1eaqB07n+7BrKD4Qc8tR65CSq+3oBHOoqpJEOKgSqyvMDd9DtXdaVLPNSv+dAZKq5XppjBuju9OAlFnwNFkclR3ztIaWmWYVk3YeGf0d5iByLk1s43YPLLgVIRVu1H3nPU+FSkP5NI4Mm52qm2Dtc3/60DtihwyCeyKQtwYfzJEsylFGJoIwzmNZLSExOTgOhWBcfadJu7cqxLWhYgNOPyjhIZlBTLvNCAV2VCO8Z9viCSskfRZlSLtiOJY/mtfC/R3o+YDcjf6Yc++QhG+yOdjQYkFw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:BLUPR07MB611;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB611; X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;4:KmXA4oxaA+kqBQOh+EcjZqzljMDHHfDQZjYzdrSlyHIOwDKuaL79njpIXTJYtMHbWi7ba1X7j7tIqnKCbsJYG8DNNYbban+pKHNOtepnnJiOPcaoBDafiVh87W/Ls9/AwJ3mb4yY87ZY2ZWCba43cd3AaT9OeAq3eRkERYegWAoGuzXk24qJSwVvu9lX8HDkhi2qipmJhN0h2tqzPXLDqlD1Y1jVNfZNjBi6EfFWe3NGZ+GdZq7j3YJo6Ni3Hw92edYkWnKKGpMyH6U1S8fzx58fgT7ftt7jFYMag8xnF46t2+zYSonGjvEMoykWxGyf1Eoo7G1uAiTk/p1A8clI2iLOqL2ihhOSvKkrygBFPIU1ir1uz7wTTuycorzcFRNC X-Forefront-PRVS: 0893636978 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(24454002)(47776003)(575784001)(110136002)(33716001)(50466002)(77096005)(15975445007)(5008740100001)(19580395003)(189998001)(19580405001)(4001350100001)(81166005)(66066001)(33656002)(345774005)(50986999)(92566002)(54356999)(83506001)(76176999)(586003)(6116002)(3846002)(76506005)(42186005)(4326007)(46406003)(1076002)(23726003)(5004730100002)(93886004)(2950100001)(97756001);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR07MB611;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR07MB611;23:5jHEX3o3DyNglkUupOtSymh9N4Rl2fNRfttoIWSwGN?= =?us-ascii?Q?pTR15mdkv7DszgL0AfiRC+r+AkBL+UAQw2UMiUnknaweHeLS2qtCpQ7torGv?= =?us-ascii?Q?YPu4UQhxzPXd2/BNbX7tYNZ1xCVZVU3hQgNlxUTbjhELTN0sL5zJcpYVIvbk?= =?us-ascii?Q?dlGr26ROq2nsUPBJOgQmAY1qEHYVP0J/C+kS0Vzl4mLPi+d+WmvphWWVPMDV?= =?us-ascii?Q?cqRPjK2V4jUB4oKo5jqzE52ysTRXlQvrE0Rd1rMl+93U2DpocHnSlrotLKpI?= =?us-ascii?Q?HTVPTW+S22K8P9U7tMeutZnDv1n5R487zvzIcLizZuJ/JmX5+xMZN5xc5l1N?= =?us-ascii?Q?7CRHl9TL+Ns5q5Zhu1nvnfiG0LAtzHRCh4lFBuMHYmJIDIgxHeMqB4Wpzd1O?= =?us-ascii?Q?h0v5xw40ZwGKZxxztkjzlrpx7HVD2wstHfDV2tYsB3eWhQWxUbjNWUikWvHZ?= =?us-ascii?Q?upIb1/KosnAbmD1uy45TRSUVltTsVy7hOduYB1rW8auYuU9cooVVJ1XTWfbA?= =?us-ascii?Q?exvL91OXGcuN3NSAW9rNkNir0QkGFmZpH4hnrv++zbFuxej9OqOPncjrTgRo?= =?us-ascii?Q?UACnII6U3yH+0ye36lDaX/SgyhWMbz1bOP06cu8f3BScMb1g0OWeLjeL3L+L?= =?us-ascii?Q?Kz0H9SGxSeqzoyV23p0i8ceZoWKr7uafwWBtCFn+L6x2apFhRA0rMfdgeSZr?= =?us-ascii?Q?Jm3d4yj/aZ/WLCuKiho0FL1aYgTfURSUxkLIssVw48ViUTGz8Brq/rtCXNc/?= =?us-ascii?Q?QuwUuNBEay5Xsjq0YDE6RhQ9eNoiLpgY0O/LN9zlSaSMhZL8S1umo7pdQcp4?= =?us-ascii?Q?x3fB+5EL/wxmvj7cy0XZLtzx6FZqq2Y6WnVtl+16pE34EZyuSdjmgWrhY6UI?= =?us-ascii?Q?HSh5pvqufuthy3SzBCjKr1JhOW2DoCuC+veaDrnIqX5xFFTh21LywT1QgujK?= =?us-ascii?Q?cRuCXvwLPdu/aRd/9779Pw1yFybvvhHtOhIuE272s78OnVc6G+Ogucdylv8g?= =?us-ascii?Q?wnr25H4+Q2L5qzbzJ16+1w?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR07MB611;5:Kqp7YwYK9A/YOzxk/v6wEIhzxBl5a6oJq45saYaOc1fQTEIDjlKxX5TgbvihZaZ2OzqXej5Auqd6risF+CA67D1ENLS/h1faR8FJGq8NS07MZWFArtoJkl4yNgBoSYQ03nrFUlTo3NPqYiA5Nbh3JA==;24:y8WZqTeGvucEjzYs/Ex73PxM2TvHZuUniUXDaWOPw2x8daJ9KeM419EoMpwxIqWOnCjvKLCHrz9GEl0DXsR5VutLGwbEcoWpR+70JsWHEdY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2016 22:46:31.5574 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB611 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10160 Lines: 315 On Sat, Mar 26, 2016 at 09:45:53PM +0800, Zhangjian (Bamvor) wrote: > Hi, guys Hi, > > Does any body test the bigendian? We found lots of failures in be in > our arm64 hardware. E.g. the signal issue. I'm afraid, nobody yet. Thank you for work on it. > > IIUC, the signal of struct in ILP32 is align with the aarch32. If so, > we need to revert the following patch wrote by Andrew in 2014 which > align the kernel_sigaction of ilp32 to lp64: > Revert "[AARCH64] Add kernel_sigaction.h for AARCH64 ILP32" > > And we also need to handle the uc_stack properly in kernel. After > apply these two patches, we could fix lots of failure in bigendian. > > Regards > > Bamvor Andrew sent me similar patches yesterday. See https://github.com/apinski-cavium/linux (branch pin1) https://github.com/norov/glibc.git (branch new-api) There are also some other fixes, so my fail list is like this: [Float tests skipped but fail too] pipeio_1 FAIL 5 pipeio_6 FAIL 1 abort01 FAIL 2 clone02 FAIL 4 execve03 FAIL 4 fcntl17 FAIL 4 fcntl21 FAIL 4 kill11 FAIL 2 mmap16 FAIL 6 open12 FAIL 2 rename11 FAIL 2 rmdir02 FAIL 2 umount2_01 FAIL 2 umount2_02 FAIL 2 umount2_03 FAIL 2 utime06 FAIL 2 mtest06 FAIL 11 Some tests fail both on lp64 and ilp32, so it seems, it's not a problem of ilp32 itself. Some tests fail only when run in scenario, so I cannot reproduce it. I suspect it's because core dump fails. Also, Andrew told, there's an issue in unwind, and it is caused by GCC bug, not kernel or glibc. To reproduce, run unwind from signal handler (trigo does it). I think, at least float tests fail due to it. Andrew is in vacation now, so he may answer longer than usual. See Andrew's kernel signal patch: >From b95c5250c5c869d8852886ed49e34fa11c29663e Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Thu, 24 Mar 2016 23:10:08 -0700 Subject: [PATCH] Fix signals Signed-off-by: Andrew Pinski Signed-off-by: Yury Norov --- arch/arm64/include/asm/signal_common.h | 10 +---- arch/arm64/kernel/signal.c | 59 +++++++++++++++++-------- arch/arm64/kernel/signal_ilp32.c | 78 +++++++++++++++++++++++++++++++--- 3 files changed, 115 insertions(+), 32 deletions(-) diff --git a/arch/arm64/include/asm/signal_common.h b/arch/arm64/include/asm/signal_common.h index faa82c0..402e0c4 100644 --- a/arch/arm64/include/asm/signal_common.h +++ b/arch/arm64/include/asm/signal_common.h @@ -23,16 +23,10 @@ #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); +int setup_sigcontex(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); diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 0648aa5..5f2faf2 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -37,6 +37,12 @@ #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. */ @@ -92,23 +98,31 @@ int restore_fpsimd_context(struct fpsimd_context __user *ctx) return err ? -EFAULT : 0; } -int restore_sigframe(struct pt_regs *regs, +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; - + 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. @@ -162,27 +176,36 @@ badframe: return 0; } -int setup_sigframe(struct 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_sigcontex (&sf->uc.uc_mcontext, regs); + + return err; +} + +int setup_sigcontex(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 = diff --git a/arch/arm64/kernel/signal_ilp32.c b/arch/arm64/kernel/signal_ilp32.c index 1bb0ea8..d399ed0 100644 --- a/arch/arm64/kernel/signal_ilp32.c +++ b/arch/arm64/kernel/signal_ilp32.c @@ -32,11 +32,76 @@ #include #include + +struct ilp32_ucontext { + u32 uc_flags; + u32 uc_link; + compat_stack_t uc_stack; + compat_sigset_t uc_sigmask; + /* glibc uses a 1024-bit sigset_t */ + __u8 __unused[1024 / 8 - sizeof(compat_sigset_t)]; + /* last for future expansion */ + struct sigcontext uc_mcontext; +}; + +struct ilp32_sigframe { + struct ilp32_ucontext uc; + u64 fp; + u64 lr; +}; + struct ilp32_rt_sigframe { struct compat_siginfo info; - struct sigframe sig; + struct ilp32_sigframe sig; }; +static inline int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set) +{ + compat_sigset_t cset; + + cset.sig[0] = set->sig[0] & 0xffffffffull; + cset.sig[1] = set->sig[0] >> 32; + + return copy_to_user(uset, &cset, sizeof(*uset)); +} + +static inline int get_sigset_t(sigset_t *set, + const compat_sigset_t __user *uset) +{ + compat_sigset_t s32; + + if (copy_from_user(&s32, uset, sizeof(*uset))) + return -EFAULT; + + set->sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32); + return 0; +} + +static int restore_ilp32_sigframe(struct pt_regs *regs, + struct ilp32_sigframe __user *sf) +{ + sigset_t set; + int err; + err = get_sigset_t(&set, &sf->uc.uc_sigmask); + if (err == 0) + set_current_blocked(&set); + err |= restore_sigcontext(regs, &sf->uc.uc_mcontext); + return err; +} + +static int setup_ilp32_sigframe(struct ilp32_sigframe __user *sf, + struct pt_regs *regs, sigset_t *set) +{ + 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 |= put_sigset_t(&sf->uc.uc_sigmask, set); + err |= setup_sigcontex (&sf->uc.uc_mcontext, regs); + return err; +} + asmlinkage long ilp32_sys_rt_sigreturn(struct pt_regs *regs) { struct ilp32_rt_sigframe __user *frame; @@ -57,10 +122,10 @@ asmlinkage long ilp32_sys_rt_sigreturn(struct pt_regs *regs) if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) goto badframe; - if (restore_sigframe(regs, &frame->sig)) + if (restore_ilp32_sigframe(regs, &frame->sig)) goto badframe; - if (restore_altstack(&frame->sig.uc.uc_stack)) + if (compat_restore_altstack(&frame->sig.uc.uc_stack)) goto badframe; return regs->regs[0]; @@ -107,13 +172,14 @@ int ilp32_setup_rt_frame(int usig, struct ksignal *ksig, if (!frame) return 1; + err |= copy_siginfo_to_user32(&frame->info, &ksig->info); __put_user_error(0, &frame->sig.uc.uc_flags, err); - __put_user_error(NULL, &frame->sig.uc.uc_link, err); + __put_user_error(0, &frame->sig.uc.uc_link, err); - err |= __save_altstack(&frame->sig.uc.uc_stack, regs->sp); - err |= setup_sigframe(&frame->sig, regs, set); + err |= __compat_save_altstack(&frame->sig.uc.uc_stack, regs->sp); + err |= setup_ilp32_sigframe(&frame->sig, regs, set); if (err == 0) { setup_return(regs, &ksig->ka, frame, offsetof(struct ilp32_rt_sigframe, sig), usig); -- 2.5.0