From patchwork Tue Apr 5 22:08:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8756241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5FC4B9F39A for ; Tue, 5 Apr 2016 22:23:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69F76202BE for ; Tue, 5 Apr 2016 22:23:51 +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 26E442021F for ; Tue, 5 Apr 2016 22:23:50 +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 1anZML-0002J6-Qh; Tue, 05 Apr 2016 22:22:05 +0000 Received: from mail-by2on0094.outbound.protection.outlook.com ([207.46.100.94] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1anZDH-0007zh-FR for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2016 22:12:56 +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=pCa9y6TpvaVmLNHKRFT6KxAywkMD/vOwxYp9IX7U1Ug=; b=2AJBxmM/GfsWOC8v/k0DgWGadxW/Fd1u+N3QfLuX2lNBsMgFyEdaXVyVaKTtDFVuI57I2yF2Y25h7fpQscB0T4MSEyLwg/HpL9rf4k14ieBhXjJKNrigBC0IGEcypZEgdfGKOyDty+8ENP/YNiHVN1MrgmGtY43/XQia6w/O5JY= 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:21 +0000 From: Yury Norov To: , , , Subject: [PATCH 17/25] arm64: introduce binfmt_elf32.c Date: Wed, 6 Apr 2016 01:08:39 +0300 Message-ID: <1459894127-17698-18-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: AM2PR03CA0039.eurprd03.prod.outlook.com (10.160.207.49) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-MS-Office365-Filtering-Correlation-Id: 61016bd1-4194-4ebd-5661-08d35d9f5c35 X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:t5JH7gwUc9aoN31wcC0hNpz9asEt7SmRzpTNTVCcoOvyCZVQyvuSH+JnpoV/P4iZ5WcJiPhQ6OpBoI2JD6rYZMmxDM+378C8tkc6jknw0l3yUed2hSMVFDdsHklmyjA2wbtGr7mCqs8fzlI0NcFoKFDKL5lvnde6TzMb/OhSgghe2ct+xJX6ztxDKaXoa9aE; 3:dv9gF8riCoUe0RCs8OFgj6teuIQHJ8yMeRjiwr/8SUhxscjjLhRnO/Clq99w47OuCs3RPA2Pwu+RDnYmVB26Y1FdIw1NffKv9Cr7KTze2k9asCAu1Qf76wMRuSwtONTb; 25:+FmOzY58RZY2G4oyfzpxMlLs+YKl9aPWGp3n+i1qK/fnIZZTZS6tv6JXL6cCKpBkYKfRtWsw+9HYgwUT01ubgNgBYM6IFwsTMkXvOPMutC0AwTTtAQ0FVlWgxMn5e+x0LwIOPBK2qtPMiklSe31126ksg7RQWpMXWlORdUi6JoDyI0d9sqMRAkQYNNTY0dde40BkDLGEXRjPj+g4CpdiXfeLc/r9n09i2EkBNVM83dhSIsdBUr1PiJiAw3FLkehGdvZjVyQlTChsVeFCyJ4xZws/L4XRExEb4/+Nzb9Odh7LfnpOXVnKsuEOslSr2wQ5hqBc7DN4dIh1y1aJXH0Be6jf6IQ9cQaLoZTHEsiqXZU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 20:YUSYWIyDfx//i0+PVZbi37Q1RSh8NF3+vDSa8l6Uxty9x1OEMQm8O7Irk9BkDA52dPnsfd3FVK0XWZDLI4URUs8g8/D8ZacLWFRVwHPF+FTgwFKUh94VQwnVkbaiBi99rKVMyzBS4pfqox5Wqf0ek/CbPeJfWDP2T/Nr/Vb6fWX3NFZl6/WRpoUb75bOmXUMbvgnjOTcyXvjulGCHApc0f3wkZCRNngf3nE+LpEPeXz8E7B+/dcmBnxEJCq6EbRP23BBX3kLVX7wBQZH8Z/540lTgx4G0ij218/ftH6FD1pxx03sKdpQurBbApbvmDReCE5aZraTrqxAVaIEunr26yZInVzaxS9U3hAguTvIYZqIm8bRL3sL3krCVUVofZDjSZu19MJC705EYNcd6o5NTDeGEcsgjA04+w7XBAJuzFr/swMIdzAYoIepT7iBoIqOvPwrkL1UIqm4w1u2cBdf4ONGsXo3E3CK0TGvbXlWjAAxa9iFQ8+ywYOXFetE9Oi79bla9Uof3iEiGy+il0OebVlLo0KvMPeQdDdow/pnReCsKCp0pd23F8xipVP+kp7x9YOKVqtVtFMZusw1zA/rYEmM1pnSLJn1fTBLjg5BrA0= 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:R+9lBshAO1bJ+cOe5LsROYHCj8sy5NJDnDPn1g4i9+Co94EFdQm1Pf/BhSWK0JarZ3DNASXbHuVP5hQr+Jq8mMk8dfLjCitOqgagW3wfoVBp40x8QonwLMbvAPUXowcAhMNI1vVSy9V2zT82S5yIadG1NypK7PPvf3BnG8A9g9B9tKd01lzZ1Wh+/VCZXqKviPs68ZJZZ3dC53xa9+0EVkFe9E2zoZz2rBvRCenGrYRbpUbVTII34H2NC5WZZGoc0NGFvWwVCSbqvVdnLcqf32nlaknrkGKBgWFeJkKND+0GcVw4yiLGBg8gstAocZ6R8oNXBkFEPk4guxM4O1DhNj6DacY5x9o2bzKMJjPkThv805cCoZzl0bC2L54gSBTp 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:HqPgOb2ESeGEws03DVDkrNb7oLe3h3twHoaONn838bBlFltWInfY4cjrlgdJf/sJVDspewU0PfkBrbjMgTDe278YIvmDCmzZqJRgO9gy1bKeZK8t9X/4L1PAkV/SsEsn9T1PvuWPD0Lp6w+NSSQDPgT7QcXd77LQUPpbE8Rjz7UThjdUdysZjNckMOQ5t4qCMBty3DzjlsBKJFO+yoy1C0llOfMtdHOJloD9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riginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 22:12:21.4116 (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_151244_303101_7E211C36 X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. 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: 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 ebaf38a..46fc295 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -931,7 +931,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 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"