From patchwork Tue May 24 00:04:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9132547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 34020607D3 for ; Tue, 24 May 2016 00:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28F3F2824F for ; Tue, 24 May 2016 00:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D5572825E; Tue, 24 May 2016 00:09:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id BF9E12824F for ; Tue, 24 May 2016 00:09:27 +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 1b4ztG-0007mg-4X; Tue, 24 May 2016 00:08:06 +0000 Received: from mail-bl2on0078.outbound.protection.outlook.com ([65.55.169.78] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b4zrh-0005lY-9j for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2016 00:06:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=HUp9nFOIyXAGeCjFAx9YGjzfZpPiJlQK6l49T6OoXMI=; b=WMjHvzghTjV6yCNVwvEXvQCT14MLHYfLPb6Tlx6YtoqYDfqXK8jOYZeESsElKcnJOvmNKl7G24jt9ndmQUI3VFptDK2/HuNchtO8WdHACUWIqhibfzcnSWQZyVLaBM8eZiwOAE94TN6eFkdy1Y1tLO6secSVBKZf3+BAzL783/c= Authentication-Results: arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (50.233.148.158) by DM3PR07MB2234.namprd07.prod.outlook.com (10.164.33.144) with Microsoft SMTP Server (TLS) id 15.1.501.7; Tue, 24 May 2016 00:06:05 +0000 From: Yury Norov To: , , , , , , , Subject: [PATCH 16/23] arm64: ilp32: introduce binfmt_ilp32.c Date: Tue, 24 May 2016 03:04:45 +0300 Message-ID: <1464048292-30136-17-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1464048292-30136-1-git-send-email-ynorov@caviumnetworks.com> References: <1464048292-30136-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.158] X-ClientProxiedBy: DM3PR13CA0025.namprd13.prod.outlook.com (10.164.193.35) To DM3PR07MB2234.namprd07.prod.outlook.com (10.164.33.144) X-MS-Office365-Filtering-Correlation-Id: 876b8c23-4f0c-407e-7d7c-08d3836733b6 X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2234; 2:+IvZXrBYgpFztu8OhUjGaOTWlpQjg1P5710yyYjJWAayyvF9Jf/x/E3Q9rvtqPoRjVohe29hVZNfVqNQKaUGHSoSmFt3W4iUthD1AjEDn64b8Ef3elmI+CPEC8o5Kf3VsPciZCqtKFWxlhK6Zq6mO6fM6tajOrf8mfLjuzN01169LObA+2HpvGfAIhR1MJLs; 3:ft57KB7u4/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zQRbYxWdeuUUqDszQkUv8NSFf8QzImGbHitp6YburtwMbe873BqKW4thmAoiS8p6aoA5xBnWNoH03FqkShyrRwSxSLLykrqhqUnP7tUiKBKyn7DPOu5sJLr4QRU0vTAnfvbSFY+2tW3iMj4FML/gA7LymgH6q+Teqhj7xLjFnfzAp3atkSrkVEDTCtCPA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:DM3PR07MB2234; BCL:0; PCL:0; RULEID:; SRVR:DM3PR07MB2234; X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2234; 4:EsBBckrVBz7V1L2lsZ4yllwGquoOLp9BK2H9cj7F4S2lUL3TGs8sUCv4JyTRB9ZakMHd1r9E+u4BWrESeeX/etv6jpUKlhv1r+vBUNHvv3O2tq66W6tSSXx1IsY+PdEYxfI+y5iJo77UhvquEl+hTuHOkGwLFoHUSFL3S58X5Uby9Bi47z7/4IwYd1v3KqEtdx084kYzN/m5SYuw88XNAqxw830xLXSfKrv7ycyJoQfYWBL68dcAMf4nhp4WnlErDP1Qdtg5PRnDSlQyk8Xu1Bnaz8UlpAuDK5A1wi+3aJ5X5eBopEgyMAIDc9Thqdu8BF/bzSQoGiHsY/QbCJoWrmbDeWkSoPqnqo9AOOSaXDWX/XNTiTDjR3xSaFlJcuvi X-Forefront-PRVS: 09525C61DB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(5004730100002)(48376002)(50466002)(76506005)(4326007)(189998001)(229853001)(2906002)(66066001)(42186005)(2201001)(47776003)(33646002)(2950100001)(5003940100001)(6116002)(50986999)(586003)(5008740100001)(36756003)(19580395003)(81166006)(92566002)(19580405001)(5001770100001)(76176999)(8676002)(50226002)(77096005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR07MB2234; H:localhost; FPR:; SPF:None;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RvQvTt0OVNrjnCZ0wdBfIvq9zSjQTc83WEbOiLrJky1wMu+HgN/TS+o+b6tavtOAMQCULb8JyxsGi03vA==; 24:OSInjG8bbr9EscYhMnzUqr06LU0W+K/UTorB2Px2cwgzeLUSfIUp1SX5RGSRR7TnafdiFcJIABCzKyC5dcB4T4h5BLHv5V9XHexwzk2UYqs=; 7:EV1ikKgl0YEuYXzznGsz0cWwaSwwbORbSP5vop77o29oS0DDNbCWpLmz365kSroZ2EBKCnciOx2mrTb8eaJq0jy+AH97Bk4GPoiyPNanRzMe7nIByI++x60rJJ7ElzSTEuX+p4La3R05VCi37fH5gqqwIWWq5PhmWkX85XrabYQU9mQL6pp9yzcg56QIwq5T SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2016 00:06:05.9808 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2234 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160523_170629_905487_E6E7A9C1 X-CRM114-Status: GOOD ( 11.25 ) 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: kilobyte@angband.pl, pinskia@gmail.com, szabolcs.nagy@arm.com, Nathan_Lynch@mentor.com, heiko.carstens@de.ibm.com, agraf@suse.de, geert@linux-m68k.org, Prasun.Kapoor@caviumnetworks.com, klimov.linux@gmail.com, broonie@kernel.org, ynorov@caviumnetworks.com, schwidefsky@de.ibm.com, bamvor.zhangjian@huawei.com, philipp.tomsich@theobroma-systems.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-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 6bc9738..9dfdf86 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_ARM64_MODULE_PLTS) += module-plts.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"