From patchwork Mon Sep 28 15:17:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 7278551 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 2DE61BEEA4 for ; Mon, 28 Sep 2015 15:21:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 33F4A2073D for ; Mon, 28 Sep 2015 15:21:21 +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 3172E2073C for ; Mon, 28 Sep 2015 15:21:20 +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 1ZgaD1-0004YI-3c; Mon, 28 Sep 2015 15:19:19 +0000 Received: from mail-db3on0084.outbound.protection.outlook.com ([157.55.234.84] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZgaCJ-0004OR-K9 for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2015 15:18:36 +0000 Received: from HE1PR02CA0048.eurprd02.prod.outlook.com (10.163.170.16) by VI1PR02MB0784.eurprd02.prod.outlook.com (10.162.14.146) with Microsoft SMTP Server (TLS) id 15.1.280.20; Mon, 28 Sep 2015 15:18:10 +0000 Received: from DB3FFO11FD023.protection.gbl (2a01:111:f400:7e04::154) by HE1PR02CA0048.outlook.office365.com (2a01:111:e400:5350::16) with Microsoft SMTP Server (TLS) id 15.1.280.20 via Frontend Transport; Mon, 28 Sep 2015 15:18:10 +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 DB3FFO11FD023.mail.protection.outlook.com (10.47.217.54) with Microsoft SMTP Server (TLS) id 15.1.274.4 via Frontend Transport; Mon, 28 Sep 2015 15:18:08 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id t8SFI7ux007896; Mon, 28 Sep 2015 11:18:07 -0400 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 v7 08/11] arch/arm64: adopt prepare_exit_to_usermode() model from x86 Date: Mon, 28 Sep 2015 11:17:23 -0400 Message-ID: <1443453446-7827-9-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1443453446-7827-1-git-send-email-cmetcalf@ezchip.com> References: <1443453446-7827-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD023; 1:Hp6pZA2GeLB29srbBkQlpogzuQklQ1yHLx6EwTvIbRT5+WrYK4pJtTWHwrBvyZj4qRhLcTVytOTIVDx910akh8I1hSDk87JJEYkhgeWGxv3KxmEOk66G/dZLr/RB2MpAKFtMU6k9D+BFQaV8vXXFtvbay7E2xgC1xqUOKw7iCPb8yCyx6OPaA82tvmsDiOPdkiaNGj5j79pqoO9rPrVz3MD79nsaP53d7GSygpk7SX0bC0NL8ZHwstgK2wxsQgPmMpyfg6eKfdKzHVpU4jEVPpdMu2XThkrbE3HfoLxlMEyqTLdYOQf+MCmwwESxl96rSQHoNoqfDe2kFrL32yNk7BV4eqcuH7ftGEj4YAzskxU= 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)(107886002)(2201001)(47776003)(189998001)(97736004)(68736005)(2950100001)(5001960100002)(5007970100001)(5001770100001)(77156002)(4001540100001)(81156007)(62966003)(5001860100001)(85426001)(50226001)(5003940100001)(92566002)(5001830100001)(229853001)(11100500001)(86362001)(42186005)(87936001)(64706001)(19580405001)(46102003)(106356001)(106466001)(50986999)(106476002)(105606002)(104016004)(6806005)(19580395003)(76176999)(50466002)(33646002)(36756003)(48376002)(9376005)(921003)(83996005)(1121003)(4001430100001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR02MB0784; H:ld-1.internal.tilera.com; FPR:; SPF:Fail; PTR:InfoNoRecords; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB0784; 2:t5gH4Q5XPdgS+BOI5y1ppC/2OxG/6I8NwSjaJQ1wFuE159EISLDaeY9oDRP1kjoiINovf8TS9YYSe7f8ZXBa5UiOgjK9vXEk5RFA2snFZXFUXacRlMWLwDwC1t0o1Ida0nOJ+7JZ2eYiAKE4YXa/fniT9GRhBn5g5r/mpuh2qec=; 3:W9WRgITPXdUSK3E4GAXiR6FOxCjRWIxBRc1lk4tJq8PiYcrYLrqzH4lRXnGVRWxUQftN971gW52i8qH2E2cMdFTrjmuoV8y+0ItXwGWQJPit+La2A3djWbdo6eN7iipL6kqJOi3KUYuHGAI+ktGy6h6a8M+0ufSXy1pgZFOf6t85kM3/Nmmr23Ho9Yii82fgYxIEwKZXNvu8u6wTsU/ztA3NfM+vIr6jK6qw5R/cTkYGN4wE3UPpBQGA8qBQOrEu; 25:mShetDwHWNLY2jjlyh0QVTHQu4jU30odxcZCtmm1Ztcox42lenfa2LM3N6ykeHVHFxFgvIyyBxLYTFV4L41KeZSJK53dNiN9q8BDNr3TEInDGUYpAxywokIhOS+21Eo9RNd77oVJxoR92hT9CatPhaIg1EnpjC2Bz5/oa/bAI2hbwwG5wec9mPu+i5tW0imw3dR81czyngAQAZZxFwAhTYoyWIq9Ix/1pnstcBTXiBSAbfGxYd4oNGxgZCFYPW38aBXn9y8G3sFrHuzOLhszsg==; 20:LxEMJqBseqSY6DoLkYP0NCDdixunmjjjUEQSi1TQpMNLKA5bI1Vi7JGKrjRvlMNHFZRQc/BQ4q9eESBWgFVTDOKp/jjsgii+e+dOXQwWF752Fy9qlN7LX8M9ZzSHHFsloGi7omQe4+5Usuo6uwtxSn/iZEBQ4QfWxOC0v+v/UMQ= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0784; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001); SRVR:VI1PR02MB0784; BCL:0; PCL:0; RULEID:; SRVR:VI1PR02MB0784; X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB0784; 4:4MEyzoktk7vbz5d/xNQv9BdOsWJmwyUZ9FhqwC2bOMQJKQkuEP4lyYDbkjqtQ7kbi71/VDmzwAjaJTm5E41a1yzQm7OmqU1EBsXA48sNMnxVAiTR+TheTQCEu5Jg1cZHer66rLZ2y5WN0NZmOkQJUiiBa+DSb1OqGL6vIv8w3Y/+5SSExdXS/0CGMwo/CZSmi5eFQ/AoGF6iMSlJ+22wJeMj6CrcQX928k6KGXxRZBklECaTd19a4Sv7vxnxj33BLd4lY5ePGs2VnCIDwUE07rIOkwIDOjxfF6x8yce8BtuCW3O9rhv0DU3T3WoRn3CY+aOAeSJtGxmPsvVInadLE5RfhVhMViU/9xGv9Y7NviY= X-Forefront-PRVS: 0713BC207F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR02MB0784; 23:yqeHtxsHZZc9JlQkv3KGA5RBTpyg1YZzA69Jvv0a8?= =?us-ascii?Q?svKyccbtMQqoErziQvP4hPLmZB5mPbEYC1OVHpsPcrMh7KagZWcUEDqKtHLK?= =?us-ascii?Q?LR6/Nk3JDtUnaViQPTgQcfAT9D1/8nNqOlsiarDtVDu5ct+cgdaShoSZVPx9?= =?us-ascii?Q?zFYHHocdWfM9yLtLKNfhkN5hJBvfbhHJB5Di3gW7v0yH+/H+4yU6YiMHZLDV?= =?us-ascii?Q?zZSR8DLyue7rL+QPmMMRS++gD9tOrGo7LYHQd1u5UFZ1JMjud+N8lO1wzNk8?= =?us-ascii?Q?jBFgp/Gx8NgeRFdfCrDECKM9z+MiuTHV9HIVapUjkpKaHFgTJW/A0Zi7Z476?= =?us-ascii?Q?+g8vBU89gphDOglJSdKzSpiWYZq2RVB+BiG2tVVnbRbewSszZ1H0j0gEpOly?= =?us-ascii?Q?1t4M50oKzBtvXiaSjgkc4u69pu0ki8khtzfs6xrX4GVhFuqN0/6D4NIYbbgb?= =?us-ascii?Q?o6WD77J2AVwM5bX2NpOXv9lnpsshUSuT6J2IKLgAKuJlQpdT58v+ZQbFJa+c?= =?us-ascii?Q?94vn2tOeGn5DvRMJh2aLJFNnX0iBoa4jhzEWktinPAtWob2JfucQoMm2Bn/g?= =?us-ascii?Q?lcTp7vrnGCRqioNk+NZJOqWNcgkOr8Tc8i8O3JgEjkmTntXUirAGN0yz4t3I?= =?us-ascii?Q?yTXulPT1kTeN7s5vGEGzSxZOrgQn7AOu3w+UxrhQNOtkjuyY83/sw86XODNX?= =?us-ascii?Q?2R8VPSoTBNULCtSw/HiFaJ36L+f2O6LYFFalNVnpJW6WPETCPAC8Zjb/gRQe?= =?us-ascii?Q?H8GRviPQyM+6GGUdhp11WiypY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NKDeMrSBCjm3lrhdh9XgZ+XoE=; 20:kol53neXSiHhSXMz7Bv24EbbijLLm2JptBq91SQR7FeiE5dYBAaPdPErawn4SirUIYcAfxOow2B59RPq4rIjlQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2015 15:18:08.9851 (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: VI1PR02MB0784 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150928_081836_209458_3F3FCE2E X-CRM114-Status: GOOD ( 13.29 ) 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, T_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 4306c937b1ff..6fcbf8ea307b 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -628,9 +628,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 @@ -642,6 +641,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); }