From patchwork Thu Jan 14 17:23:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8034681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DF33BEEE5 for ; Thu, 14 Jan 2016 17:35:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1765120497 for ; Thu, 14 Jan 2016 17:35:15 +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 2D9FD2049C for ; Thu, 14 Jan 2016 17:35:14 +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-0004EC-64; Thu, 14 Jan 2016 17:33:50 +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 1aJlez-0004hg-Bv for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2016 17:26:16 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by BLUPR07MB611.namprd07.prod.outlook.com (10.141.207.16) with Microsoft SMTP Server (TLS) id 15.1.365.19; Thu, 14 Jan 2016 17:25:46 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 10/21] arm64: introduce binfmt_elf32.c Date: Thu, 14 Jan 2016 20:23:07 +0300 Message-ID: <1452792198-10718-11-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: DB5PR02CA0032.eurprd02.prod.outlook.com (25.161.237.42) To BLUPR07MB611.namprd07.prod.outlook.com (10.141.207.16) X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 2:H9m7M91ubLkICwu2gHzVmkTxldpT7cL2THgdqWeyckbJX+AUUVbEOiFB+igrGT3OzExN5azJEkAWdHjc/zsK747z5a0VRTmmv9X6HNxzEyZXhWNt8PBeDlxuUzexF0Tu+eM1DTUvZb95KskhZZKoFA==; 3:V8/FjgXsW9GR41gdbaRI0dc4raGskwQoxFXJ9onw9VfD/PamQUMCelPgYLC44asOJgmiDiMdW5QhPnH6/4iXHIIjDHnXSNsspYvc/gNgjVhFFGNCLRERPR5mtCkp5gTc; 25:AHNWwsIo8Czx2XtG2gPRD1mTWeFIyiiBuCSALpZXZSnG9Nrjjypvaag8S9K8HAyGHzg7+UJMGrpb5AtQdBtKZaRd1u1g6CMS879oZo55iGVFxP7QPPAU6RATC+9cLHYbwkZMdOuA4C65jFBxhMXE9o218ESOZMa7uFK+G3WOHVFZj16fL3gxLDWHA7rmuRsPfz/CKT8AYrkucloa68lxqfCa9aZ08VztbTKQLMV5Lxj+W3Gb8Aup67hhVDiJVcXK X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB611; X-MS-Office365-Filtering-Correlation-Id: b5928465-abf3-4436-a6fb-08d31d07bd20 X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 20:0LyfRyDxfdaevt0cA3rq5xOfS96t4YPJ2Awc0ab8exTXHD133HRJ9J+RcBZACsw+fZUkXKCPwXufwusBhWwP6wedlVKkZhVGWXLC/scVq6L2pJWqxsD9sGT01734HT+4joaiIFl6akfKGw6MtRQvYGzhyNjTOT2Hw4rnRYURO9igvuuCbMA72WmAJ+q3ZYMdzxkOtA5d1CTA4/SRHyD5buIq7Ij9C8HmVmxyozC2agbkb8gUN6qsKrhO7XqNv1/5XBE1JEZZLhF+bLmjBtWnGccsw0221pFOtlB83XhS+0pSJImrNlvDVNftAmGrJRhzakK27ViawB6bqHULy3EvEAXVLlSfY5GTtR8KapWfJl09eyhYlxIKmwgO8Vs3qmNvP0Au4LDv3lJyTU3AccexcoWslvpGE9O37lKdgaDZB3H3Fr0VPIbjbQRlct4rO0CsFCQxo2H8VOIaOED7Qco8+LTNCk2PmV4R/jWvGuiW4bFL5KlgZ6hWfoW8vqM3UrbQolelkIqg/a906fD/y2kxKweiCSxMOoMNyUwaJso2NK6ca0HwLTMd9SCGZKwPU53KKSUNc5A7p+BtyzXl4pUHN+tzFeDGMgR36hWN3Y/shyM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:BLUPR07MB611; BCL:0; PCL:0; RULEID:; SRVR:BLUPR07MB611; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 4:cXU3vnIu7Fhx4zPdEoLoxDsAwWUGdVSOsLupoVCCmJc+34jANKHZcYvtPPjPXeyaQZvVUuN6NUNaHsZ3uYp4k0nIt2AQ8CW5gxMt7306qQION2qnukYgNvW/sx8EvmibgLYdeMS/e+xk+U0YFkmUbAxhSeFwEA1vafarTGlXodj/7ZQd9gFqfARo/bpW5j0LZM6vCBSfFxCz4g8pgipY3PLYvtvOxFEUvAM0E4KXSUW/ECiG+iY6hoRea7Fbg2eGkhaUq0L2fkoZg+y2DE1zHZlVDwqTMO+oip9FdsSCH6lZm3b4nc5r1j6Zb1cnmXxwaFwalV4Dj5VR6KsFLsJv4BuAmN+fynTZnys1ZtqWD7G9EHsYUBFT9cYdIKy9ilJ3oEfl3IACMOjnzekjxCM6T7cuCLm+sJzjxpFE7nIlqqRPM2pvPSaft9NvulyFz3c6 X-Forefront-PRVS: 08213D42D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(5003940100001)(19580405001)(189998001)(2906002)(5008740100001)(42186005)(97736004)(4326007)(19580395003)(2201001)(5004730100002)(81156007)(92566002)(5001960100002)(5001770100001)(105586002)(76506005)(106356001)(122386002)(77096005)(87976001)(586003)(40100003)(33646002)(50226001)(50466002)(229853001)(2950100001)(66066001)(36756003)(50986999)(1096002)(76176999)(48376002)(101416001)(6116002)(3846002)(47776003)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR07MB611; 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; BLUPR07MB611; 23:6rr2v2kTaXhH3Er8+wMX0UmGVa3bTfK7Pz9NtAx0Cd?= =?us-ascii?Q?orVasFJ/hk86n/8ihim3DUNHqYTbrejekh6VOga5oaCABQsbDUQG85vYT1XT?= =?us-ascii?Q?6sTviPi5r/otjE8zJYB/WAu67ieJY7LpV3Y4BmnfqS/V0ZgvxRsQ9xHwDTmB?= =?us-ascii?Q?qU+zt2vsyM40zz6XVj0vroSWZYEwUgjySmjZfEi61CjX0Lpruh9ZkUJPX+FJ?= =?us-ascii?Q?2TSqsOeKZOIJT/NAK2rS4INrI7TkSE5GpZjGILchYT1BDIvVZHi+AcEmOcET?= =?us-ascii?Q?Bf6iw13inxrG3G+wE2gURHtGd+ag+4CIk+UfD4VX/XyOrjCdOzj8QaWUkQ3t?= =?us-ascii?Q?hLGzNFgcwyCApPJf3+ASwORd8rbQAKVP5l4aCbfQnBWPRnPEu4UriOJxS0X4?= =?us-ascii?Q?rFNbMnAkMlB/YvKSouXdO+mr+G89qTow5GFOSTVoDCf6EeIVqNbMZZASWYll?= =?us-ascii?Q?MJEH2L7tLTaJzbg++0DgGbdEZFcFqlBLPSCeklhY3fmCWaHMh6ARoO0+4sfq?= =?us-ascii?Q?sz8InwEnoaJVioemh3emD8VIceRU+cEWiGXNzBL5HUJ9UNOaLttzUT2ic7Me?= =?us-ascii?Q?P8F+W5PHjTHCcyqb5D0WIshB6561zRhZNvKyoZprI3VyXERFzdln9ve8MxGw?= =?us-ascii?Q?sjraj75TE43SlT6su6DxQHTQvqOcOdxvcm7+QRvGKfC3wpmX96+6aFfWfzmc?= =?us-ascii?Q?FeA/1B+mNtw2lAQ8S/CGAmuBIab846fJDMlKfVz5Loo3p1ZePGKAmoJcOipm?= =?us-ascii?Q?1zyHZtz5niff9N6iZaMIFBpR7YkgSyTsVAVs1XJD0SPZvLPmgBLqABUPMKgb?= =?us-ascii?Q?zguq8C5m0d6BcDG/WiSTyfbUU34NUTIbZtgDrHyVWWULJfWShGbIo1RdPXPS?= =?us-ascii?Q?8MyDdR90NPLvJFlSrUzxM1WvbhDK290LNslLpqO/NpbPQzUaPQqkEmpybgWS?= =?us-ascii?Q?BANyaXx20OpQh89Ldmm2NYqS9OSeS2FrRyJihvNxnytJ50K/SRuAebya2HF5?= =?us-ascii?Q?+a5Hk60owG8BLPbEFj03P+6MR04RAVuopkiY0BiUr3i28LMXu/INDthAld9g?= =?us-ascii?Q?kTlg2LyMIFGEoYwYrdp8DJnsNTaeQDmF+/oK6VKPrHm9qw62/GUem7gMtGIl?= =?us-ascii?Q?M7MDFhym0=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB611; 5:0DvDwKxZwjhJaCJMp6ZLkke9LECnP9hfEoS03xWZTZ6zRGdjxtOVp88pxl4mgAbWHwGNwxWVNsFNY0Ns3PCJdxbSo9cc26rA7HJ/rbXn4H32yhFqDdOaiDaVJJFn1qX0fjqRFwQwojnVR8G2UwZdVw==; 24:2DvyuYnAr0HoRvkzSmI/eIGnDmp84COnpkYkMasvag+ikRR/cFc1JyfoBOB0jkua6r2wCUyDQZAz8j5hiDBQlGEnKK7CSARMHlZrX3aliZM= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2016 17:25:46.0788 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160114_092610_605938_B34AB1E6 X-CRM114-Status: GOOD ( 11.62 ) 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 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 aeddddd..2c205a4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -768,7 +768,6 @@ config COMPAT config AARCH32_EL0 bool "Kernel support for 32-bit EL0" 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 5e27a64..d33ca62 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -159,12 +159,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. */ @@ -172,24 +166,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 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 bf75a7f..f1b798a 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_PERF_EVENTS) += perf_regs.o perf_callchain.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"