From patchwork Tue Oct 20 20:36:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 7450451 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 E47D49F302 for ; Tue, 20 Oct 2015 20:39:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1259320866 for ; Tue, 20 Oct 2015 20:39:32 +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 1A52420867 for ; Tue, 20 Oct 2015 20:39:31 +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 1Zodf8-0000rF-EZ; Tue, 20 Oct 2015 20:37:38 +0000 Received: from mail-am1on0083.outbound.protection.outlook.com ([157.56.112.83] helo=emea01-am1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zodf4-0000nt-Ph for linux-arm-kernel@lists.infradead.org; Tue, 20 Oct 2015 20:37:36 +0000 Received: from DB3PR02CA0028.eurprd02.prod.outlook.com (10.242.134.38) by DB4PR02MB0429.eurprd02.prod.outlook.com (10.141.43.23) with Microsoft SMTP Server (TLS) id 15.1.300.14; Tue, 20 Oct 2015 20:37:10 +0000 Received: from DB3FFO11FD005.protection.gbl (2a01:111:f400:7e04::143) by DB3PR02CA0028.outlook.office365.com (2a01:111:e400:9814::38) with Microsoft SMTP Server (TLS) id 15.1.300.14 via Frontend Transport; Tue, 20 Oct 2015 20:37: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 DB3FFO11FD005.mail.protection.outlook.com (10.47.216.94) with Microsoft SMTP Server (TLS) id 15.1.300.4 via Frontend Transport; Tue, 20 Oct 2015 20:37:09 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id t9KKb8Zp006642; Tue, 20 Oct 2015 16:37:08 -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 v8 10/14] arch/arm64: adopt prepare_exit_to_usermode() model from x86 Date: Tue, 20 Oct 2015 16:36:08 -0400 Message-ID: <1445373372-6567-11-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1445373372-6567-1-git-send-email-cmetcalf@ezchip.com> References: <1445373372-6567-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD005; 1:e9IAiQJg/28YQ0mC4f48IF2r7c96YLYkrM9PUzejPK695ZZHpwrEyUf0VUwURg6wKMPjoJRjFceavbPTj86ltOmdUWqWq095t0l5Xuaj7dRVUnAhmVDYf8ykU57onJhR4VqgsD7EF1RtEufvcc8/wFfGhdUtdsUlboWQWypnX3EZ0bLAigXrZGGe3lmlaVTpkilYWLX2wgzmMHclNlU1JIED5cDWhNxHLN/3WkBB7ajVP9jL6JY9hhGkT7ELk0an6vTzZAh8fnEMFNQxgwuO8/V39wuGJfENQJIPdZQ5CjvuYJiWIftyJKJs6z/zK58a2Tsk84VMrS9jSab//+3gJ3gzbj8SwlZX/ZyLbYr/5ng= 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)(189998001)(5008740100001)(107886002)(86362001)(50226001)(48376002)(64706001)(46102003)(47776003)(33646002)(76176999)(5007970100001)(50466002)(6806005)(81156007)(36756003)(5001770100001)(2950100001)(97736004)(5003940100001)(19580405001)(105606002)(106466001)(106476002)(87936001)(92566002)(106356001)(42186005)(85426001)(2201001)(104016004)(11100500001)(5001960100002)(19580395003)(50986999)(229853001)(9376005)(921003)(1121003)(4001430100001)(2101003)(83996005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR02MB0429; 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; DB4PR02MB0429; 2:Y/0AQ22Ig8sP+SEHaA7A//M3MTkpA6tK9E41a13vKHr13FpqgvTxyafk0qtNAfeoiscsXCvkh1Jpiz+Occ+zx6DXDnB5bZAV4dmTjX4T/YJmy5685rqyPqzsputr1Bu+aB9lY38L231gvyeW8O3bx70P2WZji7vee7zqcPQJILQ=; 3:feXNGmktMZMJePz+uWLZ5400oPe3CRQSuQkUZd36doy8w0xhqj2U4IGNP8MedeFN1QojZLj4ofwrZfEl4MPmIZjwB9mYnauhorLg0lknXf5ZMIu3V+6Q0Oc4dvvPaNEUtPdSv2WOMFWknPvpyl6/Y61EX6aX1+42UC9cQInrzX+rZz9GZniWKDk8mQ8womXL8GUGbR754WiCRqM11/4sQPv0/3DtGSHSLoOWtjkiHTTn+4yw06Uio+mIEPhDx5qj; 25:FJBmss0w+QQLV8Uyy+4TdUs4kEvz+IaI1beik2/xMsmP9EpsMd7txHgoH1WMy1gu9hzLb9qr0WeUDLLW9H6cx5e8qQ91zHnoziyAvHb8XGFewP06Hp+ooSaHdWD8dsR05KWTtasKOnRg58vH9L040VuYns3B0Kq8N7GZCPwtIHOunjmaCSCUFxTZHHvCe4qaPuGswL4aGhnQzwqOpEykWVZ+plc+WvzJD8Gne5CMx80E+Cpbs7un4Zk3umMaOEXDvTqMr3Oj0PC0iXBrt4nBog==; 20:/Zzq9ODXbP1Y5kIzPIy8DZaf16lBezUqDgPFT2duf729lyNZQlPsUTawEgDcZ2RlyGl4FLYmlQH7BnrsHs1fEDFcRkvYzCabqpEwXXahtKLle3U/O398eNTSQ+w0EZF2RmZ925DV3wc9kFdYHH+Wn83/x0HGW1puDrc7VcZmrtk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR02MB0429; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001); SRVR:DB4PR02MB0429; BCL:0; PCL:0; RULEID:; SRVR:DB4PR02MB0429; X-Microsoft-Exchange-Diagnostics: 1; DB4PR02MB0429; 4:JT0CQFwpzJhfs4Icj0bwAmFXBeSWKx6ERvrVlsvFyaCpD4tptekWCUqOa6SCIhtYW/sJYDrMWdF/Ldex4kZg3+ocj/3nnSSP2qlC12DKhJasitJvorP/RKZtdFs4VL5AM20lMIQCmdgDKNSkc5M3L2uVD2Myv02ekdOD3futrH3CSBuk72WISi/rxjgSXto/u8A0HLvf789PF7Ne3hpGKCeXIuOPUxwfIsIhVyZF/IjSUKiYRr+MG5Px6fX93eYnG4I9tB+gmZBKYoc1PKKCtx/trfTqihzHLEDCjK8U8woiW7fBhYqh7WM4Dtjf4JiX2N0Pi+9CATzsMlXcL6A+Bs/oH3GWSCjItWuSbQu48aY= X-Forefront-PRVS: 073515755F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB4PR02MB0429; 23:+/ToNUKMBbeaHRPZtr9XqlCK14qEqfX2+udxAK3mU?= =?us-ascii?Q?7JMwJzPTYeL28x+MWwiCXWY1/g5bvodKIv3/bDaXWOrUAEPkFzMd3vGPxHq/?= =?us-ascii?Q?vCyg0I/3oUvYYzFnN2QUuIdGFWARiJMLJFUlMGx9MDcmUh2n6zQDvq2rHMCK?= =?us-ascii?Q?ZsKMyb33NGRRQnp1wILEhxuFuPSJc1Hp4lIYkadNM/sIBRcIJ69aPUh0HWgM?= =?us-ascii?Q?J1GGMUFP+It90/rT2NlNCHy69VHZ3hdoUAN4oOlks+rsKitD7lfyACaYZC9R?= =?us-ascii?Q?qAeI1KpLAgNa3c5nKCqvfWP3/T5KoYjJME7Bh1aVGxxFDCKWXHPqEt04FUif?= =?us-ascii?Q?JB8/Im0xUHXCj+dTuFjoRW4JszCN8s1YXINCVXSQp5HjLCRpCfCs/7Ycgf6i?= =?us-ascii?Q?NW2+cUJekapSFWAuMT7GRDXnhtt6BN6exxLabg+Gdkx7mpHoBSwXuhB7JGmX?= =?us-ascii?Q?xSDWuGo0uJYTW9FkK4rwwFq5PCTwiMbppoADeqhIZDFjIcuwWzcfiee2Shsr?= =?us-ascii?Q?RBma7lMrgF+SsU9xkr3tUO7Pi0UFHdVNkf1ZUK22susAulhBetUc1k9DE541?= =?us-ascii?Q?ZX9ng1URW1SS8SNxgvXWTGHS5HUPI/kzDH63cGVob6tGbIvCdkAbbFKtpukr?= =?us-ascii?Q?MsaX0zpjoSR+TZBkbx4EQ3jvy1JOMzncKHF20HRvu4iE326IxcoEysxuDz0F?= =?us-ascii?Q?wN3qMZRVWCYkzhT340mxOpPjkvFCQpV8AR0RL5M8tEPw4jjSCIvWv0hhP6XM?= =?us-ascii?Q?dCTSNsU1y1ce4nTfuf8g/u8CDZJtZBU7FaIZBH9gFATiJWvnnHILcQ0MsTIc?= =?us-ascii?Q?jTkQKpA4E8kEc6DU1C1KE0Ck+4r/a3FnQJRiKAu9ycJow3vmE2OuAg9a9D4/?= =?us-ascii?Q?ko6gwwJLWFcTaZgASs+V5HF6tGiP4x09fNPop5wr8IktIpZYy5GvFV4cxtQU?= =?us-ascii?Q?lLG0A9Nrg1vvNVYwbB0Asc2I2sM5SraUZtVhOmws4Z5mnirkoc6A/G78sLT6?= =?us-ascii?Q?3hPcsao6YrfeILX2RH1XzMSgoLqeJTHAiZCuXbl2jxnpOrwkoFXenXFh0Uii?= =?us-ascii?Q?DL3KHqPJfKhCc3REoVQSYF3MWeY1llklUcbcj21M6W8zCSTidxY2Nh1JTxdc?= =?us-ascii?Q?CGi+XDWjPig6ZC7GmAWp+KHgovkMBmWzQ60InDQP/URDhHighjO2+52Z5qv0?= =?us-ascii?Q?KegWU+DXAjoYV3HSs3+7p/p9TZKj2QMvtWghRssFakw+5kZjB2f1X98d+znI?= =?us-ascii?Q?mVASnWOCTIiwcse7g5pbq407A1Cyu651ZZkpI/iViklaIp4BZHsXaPRFJXGh?= =?us-ascii?B?QT09?= X-Microsoft-Exchange-Diagnostics: 1; DB4PR02MB0429; 5:sGuSHK8Ah0VllJQzDU3B5aPR0v/tTUTwvgqg3FB+E5z9MgNKRBRBAhzeW7Em0QZ5XVg9k3jZ09HIDceHe+wqGqC1z/yM9QbRtiWtM3/ipUP5po+6qDlI6ex+0fMWfSzJJVoc9C2oyODVBJLNUSa6Pg==; 24:p1N5ZJJxVnXO5BkWhYdBY4veUCMAMVzjCCsxpjmvxS7Uvf0l8zKZlsL/SHiUlHrjmOD4W9WZbnzgtJnk3T6oApfPYYTvECRuwjU6M/zmq5c=; 20:TSUbhB+s4w9xroqlZoD6R+ahUFG2muQ+Flp33JVdvQ3rEqjSdUltGLqgOir61dwOFYIb7CZISt2N8huno7kVVQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2015 20:37:09.7052 (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: DB4PR02MB0429 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151020_133735_333508_EAAB086F X-CRM114-Status: GOOD ( 13.14 ) 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 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); }