Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751373AbdFDMCt (ORCPT ); Sun, 4 Jun 2017 08:02:49 -0400 Received: from mail-co1nam03on0078.outbound.protection.outlook.com ([104.47.40.78]:18144 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751182AbdFDMCR (ORCPT ); Sun, 4 Jun 2017 08:02:17 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com, Bamvor Jian Zhang Subject: [PATCH 09/20] arm64: introduce is_a32_task and is_a32_thread (for AArch32 compat) Date: Sun, 4 Jun 2017 14:59:58 +0300 Message-Id: <20170604120009.342-10-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: HE1PR09CA0069.eurprd09.prod.outlook.com (10.174.50.141) To BN3PR0701MB1266.namprd07.prod.outlook.com (10.160.118.140) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PR0701MB1266: X-MS-Office365-Filtering-Correlation-Id: 3728bab3-34dd-47c7-2565-08d4ab418623 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR0701MB1266; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1266;3:yZTCPFT927m1gBDwrSqpdEgguJCjygMd9d1MWvVoHKN/xiEs7Ju8AzHzNA5WD4w7OBqDeCFAm9FWOOv1klBwm4gQwR1TbpX4NiYQ98FQhjKkQSDMKtRrScnuz3OeI0FuBkkfVab5p+y2+hnIWH1LEHBNXjUwiGaB4Q+/WkhABzkb1X3Yf5KCERuUBYBksif00BHWqsZY2/E8V2IyOlVMZ5FNsuClAxUfDCwOTK4TSvgrW3f8ThDffLc8F1/bDdJ6HFERM6X7hX+15CmkcRhJnS5VAf9cmTGh6hj3wJ310OR0bI6kl/TVhPq/E4gdudsz2uFUNVVNhNhIJ/Alw48fWQ==;25:lHRfCbFAOql8r7jkg/LC4bRhC80KTzJIpTqJf7MHDhIAPA14R8Fb9g5RTyFmytT9ECplnQjTC57nJeqUe64Au+mDEqNz3BM5KvNla5ZCj5lrRRPBU5mWgFrBYssYR7pgqDcVSFg+TYLgRrodGAOxv41w99I4jfwFlxDD1AD67WyD5q26k2O3bpoqw/o1Z21WV81g9xTB3TDOC0xBf62LkMMpFMmqn4ODMKmUpVAv7k/vl4MsxVR+u2ok0Q5N/5R83adOTKsXzShgmzrqeL1TxW6NbXczuA7/N9lHY4iYp3VIa33Se6+iKPgcEIaJ8JnlL3sLfpA7E7d3u1J2oxBZDSPOQZzIj5qmlTDUctKJ1pkyJmzuo//KfQPYsbEV/UWQOvz5iJI0Wd7boIcETOnFmqhWF/QkKpDNvdU1WNBt64NrXhfSWhNyUVEpyVFR7mj/sZUuYvgWxxcj9en23ykd5z1eCCVvBE7uiDtVmoCLURw= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1266;31:QZtOlge2wmii+OXmFE685dooFq087wXMN9cH2Y4iNWeIzCimQ3ZpSGE/m45UvxiGXxPjo1bpvgWYKkuJGtJv35sS4hOOykwPVIEYU+8RZkUxwtblAxz35z4lNqp/SINFVyiQsPZnr+USS++isaf2BZJ8UhLxVS/Wjc2viW7af3jTTOpP6TvICmEuP9f35SBLXGeKxHTJbr9J1MUeA5BE+3611lIq/xmTO7BSKZC+Oxs=;20:aXLx0oiorovpDz1HV4HnTBjtbLt4MMjDPynAIDGPv8728fmeUuzzbjJRiEoNNVG8VyJ/6Q9b4wpqnwCaVNCewsVz+1dzerHvYM39dfuT6ok7Ot3lUXk0NEBSzw9fbROjDo8nvBVvrhkBOyBTHTB7iA/bZ+fU7oGwZzhLfdzaj56J3kfkqx0e7pmvelFKwMGQG3uSkO5oEdwFOno9yZQloujS/JeCcvJfHDmeXcsfjlqQuH9DqL4GnMDCnuxiyDomNXA1YriW0f17DDDgan63TIly2I+n2UOmldfobcp1jdyjGDm8rmQhiQ3TZmpyaYSyh3pWW/cpO+HvNum7e9guYSNKYqui/NBMS3rpIbF177WpNK3GafPcN7TqlCqC7483oUHnv7gy6OOPBXWz7oNph1YwsK6N3qAqVGO9+refIHUgyL/Hmjw6/f58HnBupyEgeo90LqMMqmJ5uwHnx3i7/matT3hxZCSsQTlZUQwnVPAYqY9JyBFRUCyQpH9GhM+YBdAMvUu1oyZpYJCWmCByG8kAarLvqZ2bqySr9FI0XSMq5WLnU45atU19kgZLdmYfDV7wYXqKetu77pYzmpL/jceoRSW9q7AJq0tWWBmPMHQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN3PR0701MB1266;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN3PR0701MB1266; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0701MB1266;4:N5bcrF3oHDcB6vgmHAWjBVme9kOJN6fPSrtCbKzk?= =?us-ascii?Q?EcBDVFssi0OapKK2RVI8JsRzvPk7vd5wWL8Pu8jZFJ4TNA1WMtZi+H2Qc/DH?= =?us-ascii?Q?88W+X0an6H4NhBa2A5EbHBeYRWy8CvsTLv2g1KdGiUmsuwK+e4silbmFE2iQ?= =?us-ascii?Q?A5hPnQKDQDDEqdCjSnQm22m8VnMFnWQIhGGbn1Y7hJ/PWyv0g074F7gPZ5fS?= =?us-ascii?Q?hfrkh2JFNsqqvvGWjX2gGUmi4FpP4VE9N2ZMMvZC1iAs3PqA3lRypLVXMlnO?= =?us-ascii?Q?rLQEtbJ40ijrJbzmocYYDlTJ+9m2IW4Yqw99C5D1yxHn8ND6S6QfBJ8UyDaU?= =?us-ascii?Q?5s6qA+vn2ls2CE4r95qLZLz1jWKi55M64eOiyLkujsWHrls3u199MwCrXT4+?= =?us-ascii?Q?pRW3r2gpbc+1RCiVOEeW5STBLUoeZM0h5pZA2vSA1NkcA1Un7aNdt4bdVpEp?= =?us-ascii?Q?gexE1pi8lbkXiXohuLdTeBQ+XU7MQxr5i4pesSJmvbaXm2o0+kikdqGnbmp7?= =?us-ascii?Q?kpd1ND2Wde+1/EbZ0lzqbRy0wibdoQkq0wOL22Rt3Cm5fl5TNmTZyGr1JzHE?= =?us-ascii?Q?0OpmGkwhf0T5KRP4T8a66zDGcnspBRaN5AEChHExbeArSqOyzlm8YjS+oyuJ?= =?us-ascii?Q?oAL8VDkN7oOjqSnSZgLr3/FVN9IkHxutMor9DvkeZoMn0OaosbCLAazpu969?= =?us-ascii?Q?nsCX2kyuM3UramgTVM7LOFFb3Bgv5VPI4zGIWkIZoOaATiaYCoTEMKV27uCK?= =?us-ascii?Q?Ik7MNuVpMHvQZ2aLBEh/905CDpKCyOe6UvD8SbNQ4pJcf+5onCql6P3SZ3LO?= =?us-ascii?Q?ji3PLCIevU+12Nt3G4eMuT+4sTxminSDOE71dl89bLtXpDZ+W7Uqb5G1QSe+?= =?us-ascii?Q?udo/dJ/so38Jd6THzjphD7m0MJVRWDKgmwagI62YY56dTpCZTF5gmPWZPgPo?= =?us-ascii?Q?bgLQuha3eJThgqx0eySV/n40R2189xn7yhHb92sr5Webh/j8aBkjMfSdDTK7?= =?us-ascii?Q?pwi2le7KYKKNeTM85HhkRfbfWCGdMdt/A/Z6jfLgcUyjsUS63pLM6ng206Sr?= =?us-ascii?Q?jjNXyQrXLUJXfefnnD7dQThrB/TlMCAbb4eB9IW+tk0CdVNlaZJ/yMQIQQzf?= =?us-ascii?Q?Nx7jazYpmiYqBpzCkU7NcGgIi3w9NlcR3z/jnoqJTL0zy6jbI8kpnXcTRhyB?= =?us-ascii?Q?M5SmgQ9DnEqaSS5IESmdhPCIlXYffcnK/YG+?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39850400002)(39400400002)(39410400002)(1076002)(7416002)(50986999)(76176999)(72206003)(2906002)(305945005)(189998001)(478600001)(47776003)(5003940100001)(5660300001)(6666003)(6496005)(2950100002)(42882006)(7406005)(42186005)(53936002)(6486002)(38730400002)(33646002)(6306002)(54906002)(76506005)(48376002)(4326008)(8676002)(25786009)(81166006)(36756003)(50466002)(66066001)(6116002)(3846002)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1266;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0701MB1266;23:7EDcTOMpzmWMX3DeOmwsMrKp5hRe5bmMaYROFvD?= =?us-ascii?Q?9dgqHWyA7V2okQsocNSNe4Hw+7WckQPM9l5lEzSpWSnSHcp1hOlSHZwTdZPH?= =?us-ascii?Q?lWk0e8ZTIp8wJyBcejmwwSkap465RZZPYH9Eig3yHVBTGKELbL7/ojgEyIl7?= =?us-ascii?Q?M78A2xcRJ8FbwWbdu6i/rIyKgtn2eieRTaZtEbBkSuQMRF/qImvArYwxT6UX?= =?us-ascii?Q?WHIt3J+fF9eb8W7th9J7dxzQe9eth2WBVg81k5rjsN9Z/ynyBvpz6LmC/isl?= =?us-ascii?Q?Vy6S3eyE5u5SiFvwL6LpVaasdkcZiJi7UR+iFD00U/je2FUZKLDkQ6ODD8AE?= =?us-ascii?Q?xcK9xM55ex4UefFf3x7XJ0kjr+56PGJe38VphYZTp+fTFWyuS5iLyJw6jRKD?= =?us-ascii?Q?41oaL7jxzvk3CIk5MgCJcs2UI9ehkE6UV6SupDA9I2Xpjw1GSB49BvRcW7F9?= =?us-ascii?Q?w4vLMq8uogMCdnbIst5dmnUfzr2WeQwONjY6VCFJVv9NaPCDHXom/pyPJjwn?= =?us-ascii?Q?nomhde3PkAWj0WG6YuVgncUSUmG6M3yD9K0vDQrcllZRWYx1bH2d56pP38Gd?= =?us-ascii?Q?P7NJMkLCzbzuAEXYjpo9GptayQB1wxVrUkgGBHq7Se5kr/J/hWUCVG4SAKgD?= =?us-ascii?Q?bFasVF6cINuCyj8a7Xh5eKfn6xnd7xT0B118zBr+ERgeNZhFaBYBx6JH7qsN?= =?us-ascii?Q?li0C5UG1SbUmcIspyEksCNRLkX1PDFu+A02qD3yQygEZ8e3DTMD7M9H1S2HM?= =?us-ascii?Q?VPd1Kl3t1QkVC/wI3OosKROTNgkgigupe8Ke7xqh8NprN0Nv4+GHEOUcz7IX?= =?us-ascii?Q?XWTP4aLWOoovtKovjsDazOLtXSbkRX21K0LouVbT5LIs5E0z77QTIiBzsbxX?= =?us-ascii?Q?X+0U/0MzF7NQgUUioevSt9JQ+73/SSP7dhAHu/2rBr4dI/jVMbU2bGIldntb?= =?us-ascii?Q?cjTbzy30krddjhuHRzyMEw7ivvV3Oqf/Lyeq7QTY+ByLxIvnYMT//sq4BYvk?= =?us-ascii?Q?EDrlmAv5Qn6KtzDAqR9LecRAkMY3sCvQHmTINWJDUf/PiAKac18JxU++0dRo?= =?us-ascii?Q?Mt684VVk=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1266;6:53KfPRbIFBQJxfSw0w8R8BSpgf1o61wqnsvLzQmkpWl+lTCK26E461Zj6FgmWQss/gTNV0jlRSRjzgRWc3UHg5THoLO8mqHWIgbawOWtWMmz2YlQk1GMXAo262mMDSVcDCyClahu5EROhVHA9M67YlYaIEDSW8i4pYLwatnCFM5+KX0LAlkd3YViZXGYopbWo90NuKMTW9bQHPifwc1QXDfDnl8egpm1sJcWqF9Cy8MYnNip/4AbeiG+I8q9LQ4sluwxjfT0RQDzQCtSFgOYZoKiNN665W61Rvfl49Od01xfhLJcbMMOuscyQSz0QB9FhaiJG/e4NIZqjZE1Yfr5BJ3+bMG/gazIHGptuEuqkIi0XjkA7K/Hh9/xfHPGzkPP+Hv61uwd/XE4nQDtswPZXk5UuewcOJLc51oasix3dx96RNir7QKkRaY7B5utp2OGZGqM2CsuYaUOGfnW09/OrtXS4/4Sz1ctXAJDHfB331S7j6feNUoLcdqFRgjrKJREriXAacAz6RKvhn+oSU7Wrw== X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1266;5:6YTFEWEgjfdeZ5DNNYcVii5jeNhTIqt4JQBBQWx0BlJJudeAIxti0cDYLZXUHk1Zel2S6rlrahxJILM4qSjWz7K+om+2YQfEQx0ChEkhZzW4bTWSrkLvZp3i8+6i78mI+yw0rRWgToyGN0BlP9mmUEZjTLSYUl7F+wnoj2dst8HKo2G6jJGwiTQFv3cCddBiH6/+zyn299KwWlWOP5QuB0ers3lg5L4syN6QWeD4d0sAXplBOjN67+I6mH6KBqgP/EVYZw/auO0/uWtG+vZrPfPDRrxdYxxIPWc88JvFCCtDxytcHCFSWqkCZQgKAsXXxQN3uMFV8xqIYC5xP/srK6zXy8if3MmcnWWxk8cY8rbQdec2QsGQM0DV8dO/lvZjklQWWSVUMtKbhUTOnFFbwmTxcQ7OXf1ciBnOZPanxLv3t9ibshFSg2A5zIXbaagg5cWFuyT7AtMAXQzqO118DwZCvPARThC1DJnxwBpKZy1g1R7aLHNYGPZh+YX+hkRK;24:BhKStedLCBcKeOWa1YKQdmlmriy566i8sVSAObteyLSUPPQDrLNxnFTLncKz+3ACmfSI2sC7XhXbHXTI7qcr9tUNZb5+PUq7zVZi2vqLNbA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1266;7:9os6Bb6mGD+Wnwm3sb+FzdM/sLXEI6AtJo6pyBhQozyM1fOz3NJM98SKBGM1dMqMBzC6QM4sk3ll0Mz8aDFFHtIyNJnWLe8nFDt8wrEhuY2mg60ZTy0NXbrUGoC64HUbkitfN3IHGsjqjwKzHAQ216qm66Edf1xQqp+9mRE6qwbN5DZHk5FId3OMvyoHYu0FNtKGvKvmrk9XtfU1KcNQIr525Oj4JpYvDNEWoWjhe9SgmctIliTskBFyBUrG2C4Yuog8jE0RMHoDJBidU0Yla61IWRHIAv0syLoIVhcI8eP5xUuODFcsNJDYONTTM6Q7c0iU+kviclXkwh2v09zgOw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:02:07.3225 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1266 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14209 Lines: 450 Based on patch of Andrew Pinski. This patch introduces is_a32_compat_task and is_a32_thread so it is easier to say this is a a32 specific thread or a generic compat thread/task. Corresponding functions are located in to avoid mess in headers. Some files include both and , and this is wrong because has already included. It was fixed too. Signed-off-by: Yury Norov Signed-off-by: Andrew Pinski Signed-off-by: Bamvor Jian Zhang --- arch/arm64/include/asm/compat.h | 19 ++--------- arch/arm64/include/asm/elf.h | 10 +++--- arch/arm64/include/asm/ftrace.h | 2 +- arch/arm64/include/asm/is_compat.h | 64 ++++++++++++++++++++++++++++++++++++ arch/arm64/include/asm/memory.h | 5 +-- arch/arm64/include/asm/processor.h | 5 +-- arch/arm64/include/asm/syscall.h | 2 +- arch/arm64/include/asm/thread_info.h | 2 +- arch/arm64/kernel/hw_breakpoint.c | 8 ++--- arch/arm64/kernel/perf_regs.c | 2 +- arch/arm64/kernel/process.c | 7 ++-- arch/arm64/kernel/ptrace.c | 11 +++---- arch/arm64/kernel/signal.c | 4 +-- arch/arm64/kernel/traps.c | 3 +- 14 files changed, 97 insertions(+), 47 deletions(-) create mode 100644 arch/arm64/include/asm/is_compat.h diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index e39d487bf724..463533b1ae32 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -25,6 +25,8 @@ #include #include +#include + #define COMPAT_USER_HZ 100 #ifdef __AARCH64EB__ #define COMPAT_UTS_MACHINE "armv8b\0\0" @@ -299,23 +301,6 @@ struct compat_shmid64_ds { compat_ulong_t __unused5; }; -static inline int is_compat_task(void) -{ - return test_thread_flag(TIF_32BIT); -} - -static inline int is_compat_thread(struct thread_info *thread) -{ - return test_ti_thread_flag(thread, TIF_32BIT); -} - -#else /* !CONFIG_COMPAT */ - -static inline int is_compat_thread(struct thread_info *thread) -{ - return 0; -} - #endif /* CONFIG_COMPAT */ #endif /* __KERNEL__ */ #endif /* __ASM_COMPAT_H */ diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index ac3fb7441510..6a37b6facc69 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -16,6 +16,10 @@ #ifndef __ASM_ELF_H #define __ASM_ELF_H +#ifndef __ASSEMBLY__ +#include +#endif + #include /* @@ -158,13 +162,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp); /* 1GB of VA */ -#ifdef CONFIG_COMPAT -#define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \ +#define STACK_RND_MASK (is_compat_task() ? \ 0x7ff >> (PAGE_SHIFT - 12) : \ 0x3ffff >> (PAGE_SHIFT - 12)) -#else -#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12)) -#endif #ifdef __AARCH64EB__ #define COMPAT_ELF_PLATFORM ("v8b") diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h index caa955f10e19..0feb28ad10dd 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -54,7 +54,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) { - return is_compat_task(); + return is_a32_compat_task(); } #endif /* ifndef __ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/is_compat.h b/arch/arm64/include/asm/is_compat.h new file mode 100644 index 000000000000..8dba5caaf5d1 --- /dev/null +++ b/arch/arm64/include/asm/is_compat.h @@ -0,0 +1,64 @@ +/* + * 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_IS_COMPAT_H +#define __ASM_IS_COMPAT_H +#ifndef __ASSEMBLY__ + +#include + +#ifdef CONFIG_AARCH32_EL0 + +static inline int is_a32_compat_task(void) +{ + return test_thread_flag(TIF_32BIT); +} + +static inline int is_a32_compat_thread(struct thread_info *thread) +{ + return test_ti_thread_flag(thread, TIF_32BIT); +} + +#else + +static inline int is_a32_compat_task(void) + +{ + return 0; +} + +static inline int is_a32_compat_thread(struct thread_info *thread) +{ + return 0; +} + +#endif /* CONFIG_AARCH32_EL0 */ + +#ifdef CONFIG_COMPAT + +static inline int is_compat_task(void) +{ + return is_a32_compat_task(); +} + +#endif /* CONFIG_COMPAT */ + +static inline int is_compat_thread(struct thread_info *thread) +{ + return is_a32_compat_thread(thread); +} + + +#endif /* !__ASSEMBLY__ */ +#endif /* __ASM_IS_COMPAT_H */ diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 32f82723338a..9b1835ca808f 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -26,6 +26,7 @@ #include #include #include +#include /* * Allow for constants defined here to be used from assembly code @@ -78,9 +79,9 @@ #ifdef CONFIG_COMPAT #define TASK_SIZE_32 UL(0x100000000) -#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ +#define TASK_SIZE (is_compat_task() ? \ TASK_SIZE_32 : TASK_SIZE_64) -#define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \ +#define TASK_SIZE_OF(tsk) (is_compat_thread(tsk) ? \ TASK_SIZE_32 : TASK_SIZE_64) #else #define TASK_SIZE TASK_SIZE_64 diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 2bbbd33549c0..0136a1af677d 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,7 @@ #define STACK_TOP_MAX TASK_SIZE_64 #ifdef CONFIG_COMPAT #define AARCH32_VECTORS_BASE 0xffff0000 -#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ +#define STACK_TOP (is_compat_task() ? \ AARCH32_VECTORS_BASE : STACK_TOP_MAX) #else #define STACK_TOP STACK_TOP_MAX @@ -94,7 +95,7 @@ struct thread_struct { #define task_user_tls(t) \ ({ \ unsigned long *__tls; \ - if (is_compat_thread(task_thread_info(t))) \ + if (is_a32_compat_thread(task_thread_info(t))) \ __tls = &(t)->thread.tp2_value; \ else \ __tls = &(t)->thread.tp_value; \ diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index 709a574468f0..ce09641f888d 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -113,7 +113,7 @@ static inline void syscall_set_arguments(struct task_struct *task, */ static inline int syscall_get_arch(void) { - if (is_compat_task()) + if (is_a32_compat_task()) return AUDIT_ARCH_ARM; return AUDIT_ARCH_AARCH64; diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 46c3b93cf865..a7ffea24d94d 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -95,7 +95,7 @@ struct thread_info { #define TIF_FREEZE 19 #define TIF_RESTORE_SIGMASK 20 #define TIF_SINGLESTEP 21 -#define TIF_32BIT 22 /* 32bit process */ +#define TIF_32BIT 22 /* AARCH32 process */ #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 749f81779420..49b9a29915c0 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -169,7 +169,7 @@ enum hw_breakpoint_ops { HW_BREAKPOINT_RESTORE }; -static int is_compat_bp(struct perf_event *bp) +static int is_a32_compat_bp(struct perf_event *bp) { struct task_struct *tsk = bp->hw.target; @@ -180,7 +180,7 @@ static int is_compat_bp(struct perf_event *bp) * deprecated behaviour if we use unaligned watchpoints in * AArch64 state. */ - return tsk && is_compat_thread(task_thread_info(tsk)); + return tsk && is_a32_compat_thread(task_thread_info(tsk)); } /** @@ -480,7 +480,7 @@ static int arch_build_bp_info(struct perf_event *bp) * Watchpoints can be of length 1, 2, 4 or 8 bytes. */ if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) { - if (is_compat_bp(bp)) { + if (is_a32_compat_bp(bp)) { if (info->ctrl.len != ARM_BREAKPOINT_LEN_2 && info->ctrl.len != ARM_BREAKPOINT_LEN_4) return -EINVAL; @@ -537,7 +537,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp) * AArch32 tasks expect some simple alignment fixups, so emulate * that here. */ - if (is_compat_bp(bp)) { + if (is_a32_compat_bp(bp)) { if (info->ctrl.len == ARM_BREAKPOINT_LEN_8) alignment_mask = 0x7; else diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c index bd1b74c2436f..443e42001108 100644 --- a/arch/arm64/kernel/perf_regs.c +++ b/arch/arm64/kernel/perf_regs.c @@ -46,7 +46,7 @@ int perf_reg_validate(u64 mask) u64 perf_reg_abi(struct task_struct *task) { - if (is_compat_thread(task_thread_info(task))) + if (is_a32_compat_thread(task_thread_info(task))) return PERF_SAMPLE_REGS_ABI_32; else return PERF_SAMPLE_REGS_ABI_64; diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index af1ea258c212..0fbbe7c96f69 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -51,7 +51,6 @@ #include #include -#include #include #include #include @@ -217,7 +216,7 @@ static void tls_thread_flush(void) { write_sysreg(0, tpidr_el0); - if (is_compat_task()) { + if (is_a32_compat_task()) { current->thread.tp_value = 0; /* @@ -269,7 +268,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, *task_user_tls(p) = read_sysreg(tpidr_el0); if (stack_start) { - if (is_compat_thread(task_thread_info(p))) + if (is_a32_compat_thread(task_thread_info(p))) childregs->compat_sp = stack_start; else childregs->sp = stack_start; @@ -306,7 +305,7 @@ static void tls_thread_switch(struct task_struct *next) *task_user_tls(current) = tpidr; tpidr = *task_user_tls(next); - tpidrro = is_compat_thread(task_thread_info(next)) ? + tpidrro = is_a32_compat_thread(task_thread_info(next)) ? next->thread.tp_value : 0; write_sysreg(tpidr, tpidr_el0); diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index da908f9a1e05..e2b7c040bf84 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -187,7 +186,7 @@ static void ptrace_hbptriggered(struct perf_event *bp, #ifdef CONFIG_AARCH32_EL0 int i; - if (!is_compat_task()) + if (!is_a32_compat_task()) goto send_sig; for (i = 0; i < ARM_MAX_BRP; ++i) { @@ -1312,9 +1311,9 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) * 32-bit children use an extended user_aarch32_ptrace_view to allow * access to the TLS register. */ - if (is_compat_task()) + if (is_a32_compat_task()) return &user_aarch32_view; - else if (is_compat_thread(task_thread_info(task))) + else if (is_a32_compat_thread(task_thread_info(task))) return &user_aarch32_ptrace_view; #endif return &user_aarch64_view; @@ -1341,7 +1340,7 @@ static void tracehook_report_syscall(struct pt_regs *regs, * A scratch register (ip(r12) on AArch32, x7 on AArch64) is * used to denote syscall entry/exit: */ - regno = (is_compat_task() ? 12 : 7); + regno = (is_a32_compat_task() ? 12 : 7); saved_reg = regs->regs[regno]; regs->regs[regno] = dir; @@ -1452,7 +1451,7 @@ int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task) if (!test_tsk_thread_flag(task, TIF_SINGLESTEP)) regs->pstate &= ~DBG_SPSR_SS; - if (is_compat_thread(task_thread_info(task))) + if (is_a32_compat_thread(task_thread_info(task))) return valid_compat_regs(regs); else return valid_native_regs(regs); diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index c7b6de62f9d3..5fa1b401c5d6 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -276,7 +276,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, static void setup_restart_syscall(struct pt_regs *regs) { - if (is_compat_task()) + if (is_a32_compat_task()) compat_setup_restart_syscall(regs); else regs->regs[8] = __NR_restart_syscall; @@ -295,7 +295,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) /* * Set up the stack frame */ - if (is_compat_task()) { + if (is_a32_compat_task()) { if (ksig->ka.sa.sa_flags & SA_SIGINFO) ret = compat_setup_rt_frame(usig, ksig, oldset, regs); else diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 287a21ee39b3..d1e40129afe0 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -578,7 +579,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs) { #ifdef CONFIG_AARCH32_EL0 long ret; - if (is_compat_task()) { + if (is_a32_compat_task()) { ret = compat_arm_syscall(regs); if (ret != -ENOSYS) return ret; -- 2.11.0