Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964883AbcDEW1u (ORCPT ); Tue, 5 Apr 2016 18:27:50 -0400 Received: from mail-bl2on0077.outbound.protection.outlook.com ([65.55.169.77]:3789 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964852AbcDEW1r (ORCPT ); Tue, 5 Apr 2016 18:27:47 -0400 Authentication-Results: arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: , , , CC: , , , , , , , , , , , , , , , 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 Content-Type: text/plain 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+qk31AUX915WjYunXZcZ97vYDcKfHFhFs7v/AUu7W3DLFYyu3rk2o9AgiRV5GSdOM/4BRFoRXUCoIi4vSSW;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-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+3P9f0A36NeAqb7nVB8ICbcceiMyISKRsVAbBmA6stQCe5kCL8dlqg6ft1nu2+JmVhExHQ29gBSzW5eT5CePWL8VFY08RTtT9UnKVmZ+7YTuUh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wpuRe/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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3511 Lines: 120 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" -- 2.5.0