From patchwork Tue May 24 00:04:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9132545 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 3889F607D3 for ; Tue, 24 May 2016 00:09:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D5B62824F for ; Tue, 24 May 2016 00:09:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 217EF2825E; Tue, 24 May 2016 00:09:26 +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=ham 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 7FB5A2824F for ; Tue, 24 May 2016 00:09:25 +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 1b4zt4-0007ai-Nq; Tue, 24 May 2016 00:07:54 +0000 Received: from mail-bl2on0095.outbound.protection.outlook.com ([65.55.169.95] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b4zrb-0005hC-OH for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2016 00:06:38 +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=aDQaeG/hl+/3Cu9NKV0zzktvu2zh0tgJ0krzxGltUI8=; b=DU/V1rZmUxgjnmfIl1n/iusz3DPKni2DpdLJlRwtODgyZsxMijX0/7y1Lp3VTe89KxXnU5CvGu55eIr/LuQCGadbnwe0JvVw9g4cPPcaYYP0bltffhNokFe9nrGJTfY8+kV/f6qnQ87GYWytM4bn0AckWTZTqVjPN3vy4XDdaxw= 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 CY1PR07MB2230.namprd07.prod.outlook.com (10.164.112.144) with Microsoft SMTP Server (TLS) id 15.1.497.12; Tue, 24 May 2016 00:06:01 +0000 From: Yury Norov To: , , , , , , , Subject: [PATCH 15/23] arm64: introduce binfmt_elf32.c Date: Tue, 24 May 2016 03:04:44 +0300 Message-ID: <1464048292-30136-16-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: DM2PR0501CA0031.namprd05.prod.outlook.com (10.162.29.169) To CY1PR07MB2230.namprd07.prod.outlook.com (10.164.112.144) X-MS-Office365-Filtering-Correlation-Id: 69ebb572-6d3e-4ee2-0d08-08d3836730eb X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2230; 2:r6HURbw+qLzFz+vk/k/JYKAvs/7x96pjOd9J2P/6kQgvDen8ZjfWfvpoJVLcundNyWQu1FbQvzNtSFf6yD/91hziopI6649wcLELw33flmEe7wQuPUhyRl9ol3KgXSf/7hkrObK5OW+G8WYPPDoI64mKniwz8f877GJuEBRZ/OQEnrDXBetWsqyPYw59hu3j; 3:CTzhdMetzbVFfMYGS0Q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vOrE1Xp1Cyt1ro+QQjG+SmuXRcp9Fxb1ZckNSoqdTODWxS/0o3VG+19sLx9JgKOr6GBM+UoCO1sbwdhliy7pc3EHlsbg+2cU6qIKZVVHOAp8aCmSVg8pVyGaRLBNVyopZRbYZGUsdNKLonFfMELl5yKEiyDv9dkiGLX0c/NKE6JzE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:CY1PR07MB2230; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2230; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2230; 4:SLKS+TeWe/a/22TpnIOcW2Rmi5S6qn55/7iUFBtDYsOrd314Pyj0cx7nxPMNYLOV+OOtVi3iKCjdywq6H6CU33fjy84Y1zH5/lS1UqMs434XGZRAsCawJ/1483uXLRdD6TFSl5TVsawzesndtuQKzxhoFMjLfBjybtTvcRz/JQQiQ3ixx+xmqRm5toVlgp2ZCV0HdwNt/uyePFVuHSoW0CHu+BzdUA+dgvUNXjHRZlErwDmmDrWUVE3wK9zxqE6rhfAApwfYB/7hlyKIfZAjmBCWWOqNz33VGvesS5lVte+kLRtq635u03JvppQtdEprO//kOb1sZ66odqnoZWpqjqSe69i1bQCKoCRj6Gt33BFvGavYBiiMZJB5kMrbqS/Q X-Forefront-PRVS: 09525C61DB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(19580395003)(36756003)(5004730100002)(19580405001)(5008740100001)(2906002)(229853001)(2201001)(586003)(47776003)(33646002)(4326007)(66066001)(6116002)(76506005)(42186005)(92566002)(77096005)(2950100001)(189998001)(5001770100001)(81166006)(5003940100001)(76176999)(50986999)(50226002)(50466002)(48376002)(8676002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2230; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Micro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4HfM0UveQW0j4BA3C9+/F2NPa/m0h52N3iy+C7IBRgmVyYWz986opLHS6vLAM+Ui9dmB1sA==; 24:eVzRckQerBp6E3C5jnA8Tbw+PMcdYHiWaDNqwkfRNEl7CDj74TYH9ea58z2u2Iq6ivr7ufD50rgS1kWRF0eUOzkkRV/ep6bsrAZ1K/OHzFE=; 7:rtHGgDe0BjhieSIrVXUOeXn59CpbsbbqE370UGfmI1NX+DjW0/dn+tCVciagVJ9fmu+tHePd3AJHvsouOCSw5dnRUOEkYyfY/JcmuJGAUfsw2NeAuEbMsj2apipDAR/MW4iU3InS5U4r3HfKTQoWor0VkbOIEBvh6Dql9zkBBXtEkomHLakKazBMhDwSJyIS SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2016 00:06:01.2921 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2230 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160523_170624_390559_5CEAEFF5 X-CRM114-Status: GOOD ( 10.77 ) 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 As we support more than one compat formats, it looks more reasonable to not use fs/compat_binfmt.c. Custom binfmt_elf32.c allows to move aarch32 specific definitions there and make code more maintainable and readable. Signed-off-by: Yury Norov --- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/elf.h | 24 ------------------------ arch/arm64/include/asm/hwcap.h | 2 -- arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/binfmt_elf32.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 arch/arm64/kernel/binfmt_elf32.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index ede9b2e..0bb7adc 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -932,7 +932,6 @@ config AARCH32_EL0 bool "Kernel support for 32-bit EL0" def_bool y depends on ARM64_4K_PAGES || EXPERT - select COMPAT_BINFMT_ELF select HAVE_UID16 select OLD_SIGSUSPEND3 select COMPAT_OLD_SIGACTION diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index e18bb8a..7a39683 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -166,12 +166,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #ifdef CONFIG_COMPAT -#ifdef __AARCH64EB__ -#define COMPAT_ELF_PLATFORM ("v8b") -#else -#define COMPAT_ELF_PLATFORM ("v8l") -#endif - #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) /* AArch32 registers. */ @@ -179,24 +173,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, typedef unsigned int compat_elf_greg_t; typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; -/* AArch32 EABI. */ -#define EF_ARM_EABI_MASK 0xff000000 -#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ - ((x)->e_flags & EF_ARM_EABI_MASK)) - -#define compat_start_thread compat_start_thread -#define COMPAT_SET_PERSONALITY(ex) \ -do { \ - clear_thread_flag(TIF_32BIT_AARCH64); \ - set_thread_flag(TIF_32BIT); \ -} while (0) - -#define COMPAT_ARCH_DLINFO -extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, - int uses_interp); -#define compat_arch_setup_additional_pages \ - aarch32_setup_vectors_page - #endif /* CONFIG_COMPAT */ #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index 2c7fc5d..99dfd92 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -47,8 +47,6 @@ #define ELF_HWCAP (elf_hwcap) #ifdef CONFIG_AARCH32_EL0 -#define COMPAT_ELF_HWCAP (compat_elf_hwcap) -#define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) extern unsigned int compat_elf_hwcap, compat_elf_hwcap2; #endif diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 75dd250..6bc9738 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -27,7 +27,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 + ../../arm/kernel/opcodes.o binfmt_elf32.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_elf32.c b/arch/arm64/kernel/binfmt_elf32.c new file mode 100644 index 0000000..5487872 --- /dev/null +++ b/arch/arm64/kernel/binfmt_elf32.c @@ -0,0 +1,33 @@ +/* + * Support for AArch32 Linux ELF binaries. + */ + +/* AArch32 EABI. */ +#define EF_ARM_EABI_MASK 0xff000000 +#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ + ((x)->e_flags & EF_ARM_EABI_MASK)) + +#define compat_start_thread compat_start_thread +#define COMPAT_SET_PERSONALITY(ex) \ +do { \ + clear_thread_flag(TIF_32BIT_AARCH64); \ + set_thread_flag(TIF_32BIT); \ +} while (0) + +#define COMPAT_ARCH_DLINFO +#define COMPAT_ELF_HWCAP (compat_elf_hwcap) +#define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) + +#ifdef __AARCH64EB__ +#define COMPAT_ELF_PLATFORM ("v8b") +#else +#define COMPAT_ELF_PLATFORM ("v8l") +#endif + +#define compat_arch_setup_additional_pages \ + aarch32_setup_vectors_page +struct linux_binprm; +extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, + int uses_interp); + +#include "../../../fs/compat_binfmt_elf.c"