From patchwork Tue Apr 5 22:08:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 102524 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp718911lbc; Tue, 5 Apr 2016 15:19:52 -0700 (PDT) X-Received: by 10.66.227.229 with SMTP id sd5mr18118542pac.115.1459894792856; Tue, 05 Apr 2016 15:19:52 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id g15si8055920pfg.40.2016.04.05.15.19.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2016 15:19:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@CAVIUMNETWORKS.onmicrosoft.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1anZJ8-0006lW-5U; Tue, 05 Apr 2016 22:18:46 +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 1anZDp-0000B9-JS for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2016 22:13:34 +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=RbH29cB27yUOHWPrrkWz/VuMKJXPl+2V0o4jDhgs2Q8fms4vKWhYOVq0SiHzUM+U42hZgARTndOs0p1BiAu3u3cBOQiPtf934mNSfBRbEzMAR3GrExaurNbuiggzFh8WRILn7605NB7vMI7I0HbmFDHYGk5+gdasFErBWD9tSHI= 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 (95.143.213.121) by DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) with Microsoft SMTP Server (TLS) id 15.1.447.15; Tue, 5 Apr 2016 22:12:26 +0000 From: Yury Norov To: , , , Subject: [PATCH 18/25] arm64: ilp32: introduce binfmt_ilp32.c Date: Wed, 6 Apr 2016 01:08:40 +0300 Message-ID: <1459894127-17698-19-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> References: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM2PR03CA0034.eurprd03.prod.outlook.com (10.160.207.44) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-MS-Office365-Filtering-Correlation-Id: 868cf131-0960-4dd2-8230-08d35d9f5f69 X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:NGPmRf8SqaYu/bd9FjVtBC1gio2hHROAXA2ZVhNjrw7Q/IwFR0qydCXy5f1TtN8ihno34DtceuZl8j2TWbrLoEOYvLua2v3Rm+N/nxUntQ8KfANpeeRkJMblcrbiyzVFVjD+FU935c6nnoL1hqeRyakTTdOAABHtPuH+PYF9jfJLx0rSu1a7ss+hLOBasajk; 3:+Poim14Gw5MknuBXgaJQHNWF4hiCii0XY2N+XVhbN0naJ+qk31AUX915Wj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0VulEzlbVBRlXJceIXB/ulQNY5i47rlzRMkySU8QwiO/UFsc+0f+fIqEy+ODGE/Ozzm6ODZLg= 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:DM2PR07MB624; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 4:pWykX5qxewZUT8x2bbhKIgbDUWQXh1Ta3JL+L+obO5PaA7q7QHdf590cE1390nX35P60ceSPEt7PZm8AmWNuuTlIaH8chk344xUuUa3PYJ6P+DCdtgBwVda3qvP4tCP5NEE/HCVI4h/vbv5qM9omxzXnqjWW3n721CECcrksusyXZv6NyIc2ByYVO2qo9nXePQC1CjeUkdPAqjkyBwJ0J3HWR8B5OhddFlGKURAMup6AV779G0mR2rMlTPWEKkip3/9BwzABsi0tyFQ5BU37Oe7CFrIfEGsJ86gYlFsIkX79Fk5wMxHfZLlaq7kRMmQBH15wm7hwTucM2I+j3QNsT5XYog80io4Ydn4Nf4KGvJwj8riHBx9x2hLVS1Caa02o X-Forefront-PRVS: 0903DD1D85 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(66066001)(5008740100001)(42186005)(229853001)(48376002)(33646002)(1096002)(77096005)(2950100001)(50466002)(2906002)(4326007)(76506005)(47776003)(189998001)(5004730100002)(36756003)(2201001)(76176999)(50226001)(92566002)(5001770100001)(5003940100001)(3846002)(6116002)(586003)(50986999)(19580405001)(19580395003)(81166005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB624; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 23:uR+0wIe6jLj+SBAksQ22/lTEu1TZJ9OPF+3P9f0A36NeAqb7nVB8ICbcceiMyISKRs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A==; 24:UWbw2x76qoE+iMDtyBw2085WT6MGROWUFDtmDqOKa0wY+PXU1O1jR3pHVMZvK/2hcyxVpEd0OYwpuRe/6BfY1MJ30IWQlLPbpKn7KjMqU1w= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 22:12:26.7555 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_151318_502439_AF74C10B X-CRM114-Status: GOOD ( 10.24 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [207.46.100.90 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.46.100.90 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, linux-doc@vger.kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, bamvor.zhangjian@huawei.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+patch=linaro.org@lists.infradead.org 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 -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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"