Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252AbdCATYZ (ORCPT ); Wed, 1 Mar 2017 14:24:25 -0500 Received: from mail-dm3nam03on0086.outbound.protection.outlook.com ([104.47.41.86]:18645 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752303AbdCATYT (ORCPT ); Wed, 1 Mar 2017 14:24:19 -0500 Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann , Catalin Marinas Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com Subject: [PATCH 11/20] arm64: introduce binfmt_elf32.c Date: Thu, 2 Mar 2017 00:49:19 +0530 Message-Id: <1488395968-14313-12-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> References: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [27.97.135.110] X-ClientProxiedBy: AM4PR02CA0006.eurprd02.prod.outlook.com (10.165.239.144) To SN1PR07MB2254.namprd07.prod.outlook.com (10.164.47.148) X-MS-Office365-Filtering-Correlation-Id: 729a6682-1c69-4e01-84d6-08d460d834cb X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2254; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2254;3:vnyKzOB0xyVgJmAyfMlmSMhHlikKc/W0PvFh2sMhVwZ1Nc7IUSdsyIwpTwEOE3zn5WkoXl5MnB3emggxWLJF/NT3s3+xA3IcjpgI8JLYiJZi7ewW6voC2VV10zmYui+Wc3I9Q6JxPCN+9YsdJMjE1D20JHZ/aty2ngxrCqAZW1U+lPWB+rYd1D50mT8eDP7tDCy9Xj/K0NVY037r80zwsRuFZlVeS2eaEROy5dOUtr+9DvWRCsKl4f5Q+Tpet5cqYynyrq+alNPuU8PplHZbGA==;25:KslCciL57Q71rS4G449o61egUfEMgiOwd9V7pVZgRqJVumzaeH1QQO1wonPKKK/sWUUxpBGu+AnqJUsUB2cE8lwtfMPglKrsXTsroCOQLXRid3gx5SaOfenOQM02v0agdfKf1NmU6spsrdwDDN910TPyT+W8ZmJ1+SvBHmxQLVMbOwWxbt9Vs35GpuXBeuwbXGKICpjzssC+py4RFUQpZXwczfUWoJbkpy7iZJYig79+Kr5MwWRu22Pf9UeEhRtJAlsdATRIGhfny+mMzNiiqO9+8+0sEEWWJET92w6kQFgNAe+DMBBq7tHCocajeWkZvgAv6EOYx6KTrjz+TDNAjysZBINbIgp1uRhPZNzTTI5Bmpu5pL1nroBXTGoJZew1wRmgrpoPKFCWqqqAOl2w3zVZN8Tq0y1I4ESZOGnTq8pXaBTQ5O1PBLH2GQpuSiAe5r0Hm5os5rAdp966YeAx4Q== X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2254;31:YOtH7O6uXipXr8tQ1EX5yvZcofSa/UD+bkPNuVdGONwzaU+z6FbaKgzcSSLtNWg8jc/+9OQIPDETKAJbbpgEkMG+Vb/1Itm5HOLl9NcUQYHJ8BybaL5yPQqHCDNWKW4H47+C9kQTr0dxrij3z8LXHRd75m4nLhDMps0NPSQzkxfNnfJ0DBSdpFH83hrZwgcOSBNzsO1T/ecpwx9/CNVq1t68JbmRlDLHnzz7qZC6Hpk=;20:3BdNn3g8ibdysHEkV72Yh7fskMOEtystXtApaRyMIV2mCstLD+USu9vpGfLo7/qoRJulvWTZ2uFAYiZyJJv5MF+/oiWmi5MLr5ZPEGVApdVvIZf9/ZrDh6fHtPUmcXFITMWxZgglQo9/cTmTyorZLqT/RHOVyNh2AyF4maUvJdsYik7Qn+ibsPPMNqn0q9BmpTLOP7MireRrrb8aSg+h6v8BxNWaEgVtfLu0xo89VsiGbSl7WQDvrlqHSMBFMLFref4qnJzLc3CKKe1X558pvTsiHJdMLPJrtvbnXAYyJCp7/E/VO1mGeGJBzKmm76pGaZyUASOjUuj9t4QbJq4/5ifSIYiSHBSjFdBvLOPXftNjEmVwb/ZS0XRXKh9xDTr+EDWUzA6VDusggA3lpLJpUOJ6zMX003cHj51o04LhZjPI35XCkPpj2p4m3z+7jEkA05Z6SG/fqPkVdI0Hz95MAaa1HaqWbhXyUhlIEPAalm8nBmyUjLqtX5h1+2JIlQKwxnTIBmGNBsuU0PR8yJWDFcHs5n3YaKBqWgwxJ1rMxeh8CmB2EeGh6w5Lh4mbTwLh4NwZLnKldmAEN/FAHQJ1dnCC3MBznmd87WIaRxT0q34= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123558025)(20161123562025)(20161123560025)(6072148);SRVR:SN1PR07MB2254;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB2254; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2254;4:CXPrPDwVj36UYP03JNdjJf/40hwkPSIgElccLj9/1uhdFJvMBr2rLiArp6EddUc8bS+cI7auBsMghROCyDJn4hOIRW5eKbAhApney0lDfs3rVR/5JyIrRm7Gfh6JeZtA2ESHvFOP6e0zoS1T+KZv5zYVg/WC9yYRQmcaY0S/56nI+rMxMxQcD0QnS1LMSS/WNzwK5BXQ2IOVEiD6miMQTBekfKrtpHcbfW3axQEkzbGdRgH9RuOE02y+bA8NMaaCKhpFzOttOvIu+JFuKOpmivGMNHyigCaqctVv2Ipb2qkQssxTB4bSzsrc9lN6bfLyVqGCugpj+JlKjteOTg//Zf3426Q4GI+FtpEXzkTSifaqo8+yT6izHFZDgGTCVzX0YALpkvN3rQdVDbRLNipGxXCNU7VRlw2Oj5RkL6GPxIX3N4EhP21CKMLNzCPsrKTjd17Eng0YYXfwbcJh7Q+I5HoCcGXNfWQQihcXSHCq+AdTM37N00y6TMqY7GHqqCYfwIMGi5LX56Xo7hx2Xk6QXyMV/iNciWv7cAR+AuQeNVbVw24RUm19bMxcNyxaq8YjRQquEifqpl0K4niTrKIyhnBNaV25lxlP7p6TA9sfM5E= X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(66066001)(2906002)(54906002)(5009440100003)(36756003)(7416002)(4326008)(305945005)(7736002)(2950100002)(6666003)(5660300001)(92566002)(38730400002)(53936002)(76176999)(76506005)(575784001)(6116002)(3846002)(50986999)(33646002)(6496005)(81166006)(189998001)(8676002)(50226002)(48376002)(25786008)(42186005)(50466002)(5003940100001)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB2254;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR07MB2254;23:xNQCNC28OovJqyvN98NkAdDSv9PcB77i05ZPaST1I?= =?us-ascii?Q?qRKypgQ4tV+WRqWH2pylPW+z5be7/yTmTNJMw9B+GMKDzM/M+Fn00yQcl0lD?= =?us-ascii?Q?zUR5DEtCZ6+EiMc0f5PRunrIY2r/96AfCKPYKMQF/4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HruFlwKUJWi8fNo5y+2GZEsTaFrSfK62fFe4J4Q== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 19:21:47.2756 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2254 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4376 Lines: 129 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 | 22 ++-------------------- arch/arm64/include/asm/hwcap.h | 2 -- arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/binfmt_elf32.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 arch/arm64/kernel/binfmt_elf32.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index d35cea4..d059063 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1049,7 +1049,6 @@ config AARCH32_EL0 bool "Kernel support for 32-bit EL0" def_bool y depends on ARM64_4K_PAGES || EXPERT - select COMPAT_BINFMT_ELF if BINFMT_ELF select COMPAT select HAVE_UID16 select OLD_SIGSUSPEND3 diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index a0188e2..453e0da 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -176,30 +176,12 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) +#ifdef CONFIG_AARCH32_EL0 /* AArch32 registers. */ #define COMPAT_ELF_NGREG 18 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) (system_supports_32bit_el0() && \ - ((x)->e_machine == EM_ARM) && \ - ((x)->e_flags & EF_ARM_EABI_MASK)) - -#define compat_start_thread compat_start_thread -#define COMPAT_SET_PERSONALITY(ex) \ -({ \ - set_bit(TIF_32BIT, ¤t->mm->context.flags); \ - clear_thread_flag(TIF_32BIT_AARCH64); \ - set_thread_flag(TIF_32BIT); \ - }) -#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_AARCH32_EL0 */ #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 b688bcd..aeaf474 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -28,7 +28,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE $(call if_changed,objcopy) arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ - sys_compat.o entry32.o + sys_compat.o entry32.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..7c38a22 --- /dev/null +++ b/arch/arm64/kernel/binfmt_elf32.c @@ -0,0 +1,32 @@ +/* + * Support for AArch32 Linux ELF binaries. + */ + +/* AArch32 EABI. */ +#define EF_ARM_EABI_MASK 0xff000000 + +#define compat_start_thread compat_start_thread +#define COMPAT_SET_PERSONALITY(ex) \ +({ \ + set_bit(TIF_32BIT, ¤t->mm->context.flags); \ + clear_thread_flag(TIF_32BIT_AARCH64); \ + set_thread_flag(TIF_32BIT); \ + }) + +#define COMPAT_ARCH_DLINFO +#define COMPAT_ELF_HWCAP (compat_elf_hwcap) +#define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) + +#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); + +/* AArch32 EABI. */ +#define compat_elf_check_arch(x) (system_supports_32bit_el0() && \ + ((x)->e_machine == EM_ARM) && \ + ((x)->e_flags & EF_ARM_EABI_MASK)) + + +#include "../../../fs/compat_binfmt_elf.c" -- 2.7.4