From patchwork Thu Jan 14 17:23:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8034691 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 C67AD9F3F6 for ; Thu, 14 Jan 2016 17:35:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC8FE2044B for ; Thu, 14 Jan 2016 17:35:45 +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 F3D7A20439 for ; Thu, 14 Jan 2016 17:35:44 +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 1aJlmq-0004Wx-TI; Thu, 14 Jan 2016 17:34:16 +0000 Received: from mail-by2on0090.outbound.protection.outlook.com ([207.46.100.90] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJlfA-0004s6-BR for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2016 17:26:24 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by CO2PR07MB620.namprd07.prod.outlook.com (10.141.228.156) with Microsoft SMTP Server (TLS) id 15.1.361.13; Thu, 14 Jan 2016 17:25:57 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 11/21] arm64: ilp32: introduce binfmt_ilp32.c Date: Thu, 14 Jan 2016 20:23:08 +0300 Message-ID: <1452792198-10718-12-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> References: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: DB5PR02CA0042.eurprd02.prod.outlook.com (25.161.237.52) To CO2PR07MB620.namprd07.prod.outlook.com (10.141.228.156) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 2:H5wMeidKzjYVQHdo28b/KOCMDvt4CmQFuwMcvxHFhhnbX6YCrLu62zjeJ2upHqeQypah8z23qEkVg+2t/9x0fOJaynezCN8pXsEEQM9ya/dJ6/LGKR/Pf0MR+XXOwOv2B92Gf9HzUqcInFKnK1hxig==; 3:InjjHBquexVCDF4CE1+sMuUsy03sjjoJHPg0CGT/2jssD7jKBTgbJ36+kEQkeoZ/jGMByjeC0Tqw4oHDXhlavbHNtPS3fNMDtMyT1WJj90hJGCHRZncLjiCkVvR69SKI; 25:7jvdZpB284E9i0OmwXwZO9R4GHIElaADBkdxc7Stj6VCXCpAv6J40iHAZpQ36CZSycByAAgu4Hs55b8gh3etSVhslZwpO4mTW7HCGpeh2qMRhckVT6NKKwLdUurFpGskqbu/keV4tSdz7wXjokomDse7bl03Ab/hXMOLg+XpJvhnPk9OiFm6mh+1e6U7LYrnrpLX9YzJ3Jru6hgQBq1m36TaC7B1x2N/cJ1ZFb2nkNmyCU88r8tb73N6F7/rKpy6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB620; X-MS-Office365-Filtering-Correlation-Id: 6b2ee26d-1250-4678-71ae-08d31d07c403 X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 20:zSNL0OqqJU/BlKYE+J9IYs7iips/xsY1tGno5jzFWXO1OVdxSG1sXSU6w3qhyWuQ4xbxTL/1ToIKmpI2LKCJUSq8spaNwqKvdi2LqDHUsLm51LAcmfQCnN30sEYfKxfcSFzH/yfsKLUVaUYyTbAKlo0FmGNatvowGNz+yK5SwufIrsOPrFv5R0pv3kpMcpr/U5mLWC+jwTyA5LvMrOpKMbLGphznCbyRMWF9NNf+2BRZOhaXhh+zpTlrAFUSsIcF+4ralRYTomV/SXevXFYck+cSxF9Wb7GtKCtGJid0fuapuXc+CtlurvlAATsY+bm1embGNiLD2WGKNRLxDQvbz+O9if7p7lJf6CktYJV2/P7oVbUjuG3TeTOuCodCT0awFthHd9Vh4bwm4doqb9WnK0XaTlkKdqAIso1nuSnudj3D3LII9+M/phWVwAMcgc9IGyu5G9LjgEHbBMlnORobFBQg4Wgend3kMOn2gVnTbuKulsXBdyD/Kbr/Bk37NA1G8v5xPcECJfZY8T15nvDzO9ZO7ini9lL8YTch8FwdPeFrmU9tvv4noSECU1e10qhEbf5BYCHSopc2N+dp1cM0owAR0sE5DqSnW8UdX+CJ+68= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:CO2PR07MB620; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 4:vQVOqIXXRP59Gg7g3miks0fZ7iCELNpskT8mqOFNtVmlHaKZxJcUG3VfcjAo28I39enjBBjU0yhyxvBMetDjnT1n7a0xf3n/l6q35CqwIIM3qL5uFTBgWZTbZN8tZjEUmu2Fv+/42zO89CAZdXj9ZEV4SO84jDZ/egnMV+jWiY7j2JFk95OpismvOW3dGJyP9MLl0CT5GN56GyYDL5tTRC+x7ZyQguIxKMJI5jt4mb4fzkHX7fknLFyAPWfIPmwAP3Y/s9964ekg/VP7k5CfJQup1y3nG8l1eTaGeXO0YDOgEEmz7lBr+T858x3JdwWTQi5MyOkB5XFSXMP7CccFRIgreMeQgyuwAvbwl7RgMX2zNwQgeL6bFm0VDMKtzX0DSd5+50Ha/r/pIiVCsOLsUlxA55hkUoDdK3bB9LOfnxFVrZ7aumacgYoFIyqE62To X-Forefront-PRVS: 08213D42D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(189002)(199003)(105586002)(4326007)(122386002)(42186005)(92566002)(50986999)(5003940100001)(40100003)(106356001)(48376002)(19580405001)(19580395003)(66066001)(5008740100001)(101416001)(50466002)(5001960100002)(47776003)(5001770100001)(229853001)(189998001)(81156007)(76176999)(586003)(2201001)(77096005)(6116002)(97736004)(3846002)(5004730100002)(36756003)(1096002)(87976001)(76506005)(2950100001)(2906002)(50226001)(33646002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB620; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB620; 23:OJivZFZEglpUySivr+TdXRKCuj4wCLAJOb6YUMNJpl?= =?us-ascii?Q?8d/ZjlLkhcilDGC5a/vqKLxl3BCJ+sDxMbGmjt4s3Kla7JzB0ZSguQY5yU8m?= =?us-ascii?Q?F05HlPwQL93fAFOUxPkqzsfw4LzMk0XcSmNx0N96fVOx80yz5UVoInmuFMrx?= =?us-ascii?Q?UBZt7O5L6IycPtNGGxOkudNeXWdaMT1DgJEkUtSAakpMQLGXXUMh/aFKVRRs?= =?us-ascii?Q?j8l2br5REmN1gEATApNi+JfoneWAN7tzjZUw/kADyRpYEl4UcI4DsQj/nyIK?= =?us-ascii?Q?VVolYa2F9IMtmgL5eJNoifVs8iEjIZpLaxf0VLgGK9D1ULXJQr4SFBBHTYh6?= =?us-ascii?Q?RTfaaRW0nuXjmhm2/wdMhD8yrc1Woa8zEqigzHx5HJk0vO5fvW2ZqzePfeaR?= =?us-ascii?Q?maP1EYjynw6TwBBeAWAP/w3/e1diuO1R5AdM7MYcwFFiK8LTf/hlNKlO4xf7?= =?us-ascii?Q?5G4Tt9bv7sgY5lIycyEQbWode5Gaq64pDsrk82zT23okZ/lB0+xAXC/t6+nt?= =?us-ascii?Q?SR06InN1k1p6lKNRP+nnLzM2kKXnSdsPk0Ddh28VSrHQd+x+UWJzq7wAMuyL?= =?us-ascii?Q?Ol312IJ+szFkn3SXyIEtUCFQ/TBWqSuw9PNZETgTxpL3XKK/AGDwLsE0Uc0y?= =?us-ascii?Q?6prwZOT03oYSS62Z79BqEBqLx2Bee8lvabIrns4B94GfR/utZgU2N4NutcQC?= =?us-ascii?Q?NJWApgx2/1MTGD4gktpxpHD5jNG8QbC49/O7I6DOEff+JSc3KRauMu677rxQ?= =?us-ascii?Q?OSzqclJDEUsvYOxJNgFar5+pCy/orh4U7pFPg0xCnz2w3nfACRt+Tmnq8uxA?= =?us-ascii?Q?nNrfcb5spsWqaL67jCWeecSKTdgnvibUp4tIZKaI7u/esnj1Mvcap4m5MU6b?= =?us-ascii?Q?5u913nJSnXNbhGT5W+aUX2Ddudv+YFh7CIfN/ONMzEBvvwTeedRERESnmJzs?= =?us-ascii?Q?VeDyvraBk9Qlc0rcy1m282p8s1DT5s3YNe+2PQ3uyJjgbpACm9NaM9dj93ij?= =?us-ascii?Q?6qA/4f/5+EZrP6KLaL14I2A/FBjjSlMED1XHMoCLAzciDhftvIHmFYbVO61u?= =?us-ascii?Q?6zR+RuF6RUlnGHU15fQ1uphaKcaQKq6cneARaXYa3BR7oEAT5e0jLid69oi1?= =?us-ascii?Q?8GpQi+kR8=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB620; 5:3D4/T9bQ/ucCm3rD3q/C3pGWyM1TUvLsSfndt47YY5eZ//aqFG5NjSXmPPuSd+kBX7RCRVjz/hw8lDGk8+9eVyPVBuYMXYGfaaxy7EC3MbkQmaDDXZ/ipX0Zp7BKFx6drJ/ktFm3z7fhEEuL3T1mAg==; 24:PEef/LAVY9CgXcM+MTyQIWaneaiNOh2h3iWiqRtFeZ9tW4ghCoqYwedE4T0ymSFixUtWT8NPkPD583VV9TCd6QkE00DzQDxQjQlah/0EKqs= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2016 17:25:57.4283 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB620 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160114_092620_891281_2856B58E X-CRM114-Status: GOOD ( 11.24 ) 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: pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, jan.dakinevich@gmail.com, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, joseph@codesourcery.com, christoph.muellner@theobroma-systems.com 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 to handle ILP32 binaries Signed-off-by: Yury Norov --- arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/binfmt_ilp32.c | 91 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 arch/arm64/kernel/binfmt_ilp32.c diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f1b798a..ad7158c 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -28,6 +28,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o \ ../../arm/kernel/opcodes.o binfmt_elf32.o +arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o diff --git a/arch/arm64/kernel/binfmt_ilp32.c b/arch/arm64/kernel/binfmt_ilp32.c new file mode 100644 index 0000000..a934fd4 --- /dev/null +++ b/arch/arm64/kernel/binfmt_ilp32.c @@ -0,0 +1,91 @@ +/* + * Support for ILP32 Linux/aarch64 ELF binaries. + */ + +#include +#include + +#undef ELF_CLASS +#define ELF_CLASS ELFCLASS32 + +#undef elfhdr +#undef elf_phdr +#undef elf_shdr +#undef elf_note +#undef elf_addr_t +#define elfhdr elf32_hdr +#define elf_phdr elf32_phdr +#define elf_shdr elf32_shdr +#define elf_note elf32_note +#define elf_addr_t Elf32_Addr + +/* + * Some data types as stored in coredump. + */ +#define user_long_t compat_long_t +#define user_siginfo_t compat_siginfo_t +#define copy_siginfo_to_user copy_siginfo_to_user32 + +/* + * The machine-dependent core note format types are defined in elfcore-compat.h, + * which requires asm/elf.h to define compat_elf_gregset_t et al. + */ +#define elf_prstatus compat_elf_prstatus +#define elf_prpsinfo compat_elf_prpsinfo + +/* + * Compat version of cputime_to_compat_timeval, perhaps this + * should be an inline in . + */ +static void cputime_to_compat_timeval(const cputime_t cputime, + struct compat_timeval *value) +{ + struct timeval tv; + cputime_to_timeval(cputime, &tv); + value->tv_sec = tv.tv_sec; + value->tv_usec = tv.tv_usec; +} + +#undef cputime_to_timeval +#define cputime_to_timeval cputime_to_compat_timeval + +/* AARCH64 ILP32 EABI. */ +#undef elf_check_arch +#define elf_check_arch(x) (((x)->e_machine == EM_AARCH64) \ + && (x)->e_ident[EI_CLASS] == ELFCLASS32) + +#undef SET_PERSONALITY +#define SET_PERSONALITY(ex) \ +do { \ + set_thread_flag(TIF_32BIT_AARCH64); \ + clear_thread_flag(TIF_32BIT); \ +} while (0) + +#undef ARCH_DLINFO +#define ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, \ + (elf_addr_t)(long)current->mm->context.vdso); \ +} while (0) + +#ifdef __AARCH64EB__ +#define COMPAT_ELF_PLATFORM ("aarch64_be:ilp32") +#else +#define COMPAT_ELF_PLATFORM ("aarch64:ilp32") +#endif + +#undef ELF_HWCAP +#undef ELF_HWCAP2 +#define ELF_HWCAP ((u32) elf_hwcap) +#define ELF_HWCAP2 ((u32) (elf_hwcap >> 32)) + +/* + * Rename a few of the symbols that binfmt_elf.c will define. + * These are all local so the names don't really matter, but it + * might make some debugging less confusing not to duplicate them. + */ +#define elf_format compat_elf_format +#define init_elf_binfmt init_compat_elf_binfmt +#define exit_elf_binfmt exit_compat_elf_binfmt + +#include "../../../fs/binfmt_elf.c"