From patchwork Mon Jan 4 19:34:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 7950771 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 3C2099F1C0 for ; Mon, 4 Jan 2016 19:37:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6290B202F2 for ; Mon, 4 Jan 2016 19:37:44 +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 79195202E9 for ; Mon, 4 Jan 2016 19:37:43 +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 1aGAvH-0000hO-CF; Mon, 04 Jan 2016 19:36:07 +0000 Received: from mail-db3on0094.outbound.protection.outlook.com ([157.55.234.94] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGAvD-0000c3-6l for linux-arm-kernel@lists.infradead.org; Mon, 04 Jan 2016 19:36:04 +0000 Received: from VI1PR02CA0001.eurprd02.prod.outlook.com (10.162.7.139) by DB3PR02MB0426.eurprd02.prod.outlook.com (10.160.50.142) with Microsoft SMTP Server (TLS) id 15.1.361.13; Mon, 4 Jan 2016 19:35:38 +0000 Received: from DB3FFO11FD022.protection.gbl (2a01:111:f400:7e04::102) by VI1PR02CA0001.outlook.office365.com (2a01:111:e400:581f::11) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Mon, 4 Jan 2016 19:35:38 +0000 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none; ezchip.com; dmarc=none action=none header.from=ezchip.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 12.216.194.146 as permitted sender) receiver=protection.outlook.com; client-ip=12.216.194.146; helo=ld-1.internal.tilera.com; Received: from ld-1.internal.tilera.com (12.216.194.146) by DB3FFO11FD022.mail.protection.outlook.com (10.47.217.53) with Microsoft SMTP Server (TLS) id 15.1.355.15 via Frontend Transport; Mon, 4 Jan 2016 19:35:37 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id u04JZZFF029331; Mon, 4 Jan 2016 14:35:35 -0500 From: Chris Metcalf To: Gilad Ben Yossef , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , "Rik van Riel" , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , Catalin Marinas , Will Deacon , Andy Lutomirski , , Subject: [PATCH v9 08/13] arch/arm64: adopt prepare_exit_to_usermode() model from x86 Date: Mon, 4 Jan 2016 14:34:46 -0500 Message-ID: <1451936091-29247-9-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1451936091-29247-1-git-send-email-cmetcalf@ezchip.com> References: <1451936091-29247-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD022; 1:5Q+6QVoiH2UNxaT4Z/Lj7McudpoBymw9wxVD1Wx4ZC8fIEGbnM2nvqNcZhfH4GUIH9L0vEoxmCJvUl14bpM3anQAiclyBdxfkidFnu1UxvSZRB9fk2yAIbhbyA+R35eeo1n8SIw3WXDmMMakXN/ZhFfivJxH/9lGJqKb9TEy5hJ8/LsbYCZ+/fVESFtyUodTyRjwlNDthrIyrrxEodvPB37Y9A82OYesRlbTCVPeYzDdoM2C6cFqeg4ndEHF2khT2OIy2EjSS9mpS3IB7n83xTFYF7J1XHAAyqmJOkPB7rMEyinxc6rekX4AX3GJZvd/CyaeaKaLdc2AZiVmAyunr2P3806ERY19Y4NesKV3uCIkY4kZkinYcxoQQiJOjtRn X-Forefront-Antispam-Report: CIP:12.216.194.146; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(47776003)(4001430100002)(2950100001)(1096002)(33646002)(42186005)(11100500001)(104016004)(48376002)(5008740100001)(6806005)(1220700001)(4326007)(50226001)(19580395003)(189998001)(50466002)(229853001)(106466001)(85426001)(107886002)(586003)(36756003)(92566002)(19580405001)(87936001)(2201001)(105606002)(50986999)(86362001)(5003940100001)(76176999)(5001970100001)(5001770100001)(921003)(83996005)(1121003)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR02MB0426; H:ld-1.internal.tilera.com; FPR:; SPF:Fail; PTR:wb-fw1.tilera.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB0426; 2:oM6J4zzuQq2xoJOjIuTkY6pLJwPnO+dqurIyXg/r6gkw/9jyobvicconpLdaxCyoIoGAxeBhFMAosFOqBjxd1YNIsilH6/ltMyqc5OB/jp5Kp1wRvzeAEWWgsIRPudWYrsbLzMitz7SWbBGHayuQdg==; 3:PNYJP6ClFhJ3j5gAXVO0EftS7ByMpszrC+/r32p/qRuyXM//hKldsJpg6FklEgHo95O9E7eKD/cfyg2pczYKFTPYTBFiVPKNTMwM1WBG3OE7Ln3a3KEZfot+G4jc4LDG0qyHS8FeuEIRD5BKviznoujBuxziBEWw4Ax1VZvLczI5nGQpz4iHmWJqJ0EttDpIAIzg05a8NxeS6VULr+XyceOauw15RhAYzL+YsrzFVZc=; 25:+wjKUpDR8xUYJooowGPNR19ZYDgzIcWBvBmT82IFuNcBZVrTc+6fx9czs2f/G7oWQXNEYgzRv0G5DuZfOHee5ufhhA7eLt1i+IhtE51J/rKCvSqtdduEipoUdvhEAj2BY7/WfOwVQ0s1zlEr7g5GaMpM9whceQ1D3NBZx6ydnxx7t+MrdkXupqT7J6T/Qn+mNbZGWhUap2In9ZLhMyFDREOKrY0ZsaNXTWl8ZFZc3zav1l23ehTsRSPgsbqlMiLY6x88YfrXg07+9z48Ia7Wvw==; 20:rn/nwcQg96VnA++OYU2JBhwhuvhCrZjGlP2M5it7bKpRCpo0i0m6OXcEWke3JbgAWtGSlR0mCrfx9D2emwPg8+vP/c4T+uOZtmNipzO3hc5HbVpqy45YlrYXHghfyL2WcOtgl+MD9JodElCeT14//Y51o+rXik7HtosDRlqszeU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB0426; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:DB3PR02MB0426; BCL:0; PCL:0; RULEID:; SRVR:DB3PR02MB0426; X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB0426; 4:QfhyVCbeOeTZyR9AbUscFyjH+UMUTkXAXQOrRWJaW836yqF26CgYXGQnc5JlINa6so/Zvtt1jfec6g10TOtIzPnf+rxeOBlmLCbSt609Ie4sCLXXiIkuxeVhbLAuBfkAIRv7MIGk6biRUoEpD1Jglm87CGs34vU1ILQDsjCyKkBNJevQ38HcRlfIRdC9ijPu8fK20OBUoCqidSzoM63RieQBFFzj2Mw1C5QjN64cpnWjUoOoHScYvv0gwQ4g85Om0rufWeeIMdiRMdEp7IQ8div2kKybMMgW3d8ArrstjLiHbRvPdAYLCR7gGN/rnYODBq8u076DzXLYLyymZH62RLFKp986G0+gk+8cfFLBqMh2Us1Xb51rHSvhnShCM+crym6Wdh/V0kW+0gTqrIyGYbjY8uI6zZKRAxyJ5vEkt0+kPy61bW/nuYsjZ+kRdaQB X-Forefront-PRVS: 08118EFC2B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB3PR02MB0426; 23:7Z1zF1iy2fxxKxEEuglpW1ZxHKHWqVgaq+VXS5cM9?= =?us-ascii?Q?jzNOmNXisAjylLqq4SxEr9zzQmhf1tD+wjqLOwDxfpl1yrUWjGziCTBaaE9s?= =?us-ascii?Q?6xgJmshv94tu3kzZ3aFz/rKGzrdW5BpEmNTRLHcuhDeaC46D8k4wZ/r7iNfn?= =?us-ascii?Q?krpaoHyoLjFpNperddRsr5nqBNZ+2cOHdMEn/rS3gVxleVWKoB58DGvpw3GN?= =?us-ascii?Q?niF2jdKdW4h982giBOeCFng4YiQ4BOYXQnHrNakSJxul81QHrp9eVpH+HyDE?= =?us-ascii?Q?cy08HuRs+lpSYHOXHyP3czda44noCO42yUN0jZdgjHo6SlAkSGgKjAf15dRm?= =?us-ascii?Q?8t0vzeOcFtBE6dmqjROrgNmiQoZaEEqhFss3IpJM4bHxC/SmfZ4H5hZ8VvsX?= =?us-ascii?Q?3myJga2ILm9IaOPp5q8kISzSeBqm9ZU9Z4bTMxl0A/k9sYOnZ43vD4axuElm?= =?us-ascii?Q?otoMDpOaceB7dsuMe4q2tOPIdayP1ahMlMPRvB9IHyYr/4wBgvFzwbv0ph+2?= =?us-ascii?Q?kqYwHTdZj/gPLjLmyCVhILlBeqwXvu3OCfMcRv4DqitTyW4RV9GDLbCYN7QJ?= =?us-ascii?Q?2A1lJVCT+2mKO6XNVe+vJ9GYJLaEhrSUetlmkDEyH0rAwgxeJ5ADrqZvp9tZ?= =?us-ascii?Q?LOs78Zea4vXzCkj1WITqLCe33hqAyaD2FnTzIWTEsyNIikOZeYvUM5Xrk99z?= =?us-ascii?Q?Vj5A3nGsYxcWEZEE+40+bafOTWDieyCcJtJMtWkEI1fT8OdV0j6AQZxXd0Is?= =?us-ascii?Q?PvqPFJb05bhj5wutwJZL0iCTaNyQMP2/omE+OlIwn7uaNXvZ59Wvu6KdB27B?= =?us-ascii?Q?ekFikejQItyPkw4yaA7kyxtMh7YJewh0LfWZweH7zj+3jNWbleGWYgLqpBRs?= =?us-ascii?Q?0EtItwKWz3wE8nXk+ILFzQYitc3HSDl2l/a2h2zv8iZTZ8ZolrMUIeSUoj2Q?= =?us-ascii?Q?BhLCCh3G4Go7ysHsAt666POoTgc9/M060f619Mv6yHUIffv0N5a/Uc//pCxk?= =?us-ascii?Q?yRNSt1BJBMAl6AgNPmgu/vI8zJyABTk0moR6bh4o/ZeniTquVglyKFlD1Zh6?= =?us-ascii?Q?Yty9uI/y+VXCX4EH9WLSYpSZLAio4nX93/1lYXZBWPDnKujKcXvHEv5ky01v?= =?us-ascii?Q?vsdaRxYOLPXMvih12wFOhF8jAWI7G85dDI7vFu83ova7f12NgsC9S/q65aIJ?= =?us-ascii?Q?t4rWJXR0ZYcfL0=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB0426; 5:TX9WammlnXM2asPDvA114QWSBgX7cf8FmVLUNeONRu/z4HtKPe3GfzRgtfE33i618yrJA0mFGTrZFxyu+frXfjXhze045KagGn3Fyn2ZNkN1pM1Vnr0AFy3GKD/dI9inBUDU5Vm03RfcY9xWMpU2cw==; 24:XefTUFslS2fxAjkZNq0Zm3vOsTWKMsry37nZZdwO0Xo4cHE7CBhvEmLQLuaxm0lKzdQr9ieVtedGkN9qa7+voHVa6uXiytMCqt22Jxe1Ml8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2016 19:35:37.0619 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[12.216.194.146]; Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR02MB0426 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160104_113603_734795_D7D122AD X-CRM114-Status: GOOD ( 13.01 ) 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: Chris Metcalf 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 This change is a prerequisite change for TASK_ISOLATION but also stands on its own for readability and maintainability. The existing arm64 do_notify_resume() is called in a loop from assembly on the slow path; this change moves the loop into C code as well. For the x86 version see commit c5c46f59e4e7 ("x86/entry: Add new, comprehensible entry and exit handlers written in C"). Signed-off-by: Chris Metcalf --- arch/arm64/kernel/entry.S | 6 +++--- arch/arm64/kernel/signal.c | 32 ++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 7ed3d75f6304..04eff4c4ac6e 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -630,9 +630,8 @@ work_pending: mov x0, sp // 'regs' tst x2, #PSR_MODE_MASK // user mode regs? b.ne no_work_pending // returning to kernel - enable_irq // enable interrupts for do_notify_resume() - bl do_notify_resume - b ret_to_user + bl prepare_exit_to_usermode + b no_user_work_pending work_resched: bl schedule @@ -644,6 +643,7 @@ ret_to_user: ldr x1, [tsk, #TI_FLAGS] and x2, x1, #_TIF_WORK_MASK cbnz x2, work_pending +no_user_work_pending: enable_step_tsk x1, x2 no_work_pending: kernel_exit 0 diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index e18c48cb6db1..fde59c1139a9 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -399,18 +399,30 @@ static void do_signal(struct pt_regs *regs) restore_saved_sigmask(); } -asmlinkage void do_notify_resume(struct pt_regs *regs, - unsigned int thread_flags) +asmlinkage void prepare_exit_to_usermode(struct pt_regs *regs, + unsigned int thread_flags) { - if (thread_flags & _TIF_SIGPENDING) - do_signal(regs); + do { + local_irq_enable(); - if (thread_flags & _TIF_NOTIFY_RESUME) { - clear_thread_flag(TIF_NOTIFY_RESUME); - tracehook_notify_resume(regs); - } + if (thread_flags & _TIF_NEED_RESCHED) + schedule(); + + if (thread_flags & _TIF_SIGPENDING) + do_signal(regs); + + if (thread_flags & _TIF_NOTIFY_RESUME) { + clear_thread_flag(TIF_NOTIFY_RESUME); + tracehook_notify_resume(regs); + } + + if (thread_flags & _TIF_FOREIGN_FPSTATE) + fpsimd_restore_current_state(); + + local_irq_disable(); - if (thread_flags & _TIF_FOREIGN_FPSTATE) - fpsimd_restore_current_state(); + thread_flags = READ_ONCE(current_thread_info()->flags) & + _TIF_WORK_MASK; + } while (thread_flags); }