From patchwork Thu Jan 7 23:34:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7980681 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 48D84BEEE5 for ; Thu, 7 Jan 2016 23:43:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 615A820149 for ; Thu, 7 Jan 2016 23:43:20 +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 7EA352010E for ; Thu, 7 Jan 2016 23:43:19 +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 1aHKBO-0005Fg-Kq; Thu, 07 Jan 2016 23:41:30 +0000 Received: from mail-by2on0100.outbound.protection.outlook.com ([207.46.100.100] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aHK9X-0001x0-1Y for linux-arm-kernel@lists.infradead.org; Thu, 07 Jan 2016 23:40:03 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@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.361.13; Thu, 7 Jan 2016 23:39:11 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 10/21] arm64: introduce binfmt_elf32.c Date: Fri, 8 Jan 2016 02:34:28 +0300 Message-ID: <1452209679-19445-11-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452209679-19445-1-git-send-email-ynorov@caviumnetworks.com> References: <1452209679-19445-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR01CA046.eurprd01.prod.exchangelabs.com (10.141.191.36) To DM2PR07MB624.namprd07.prod.outlook.com (10.141.177.154) X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 2:VysdYg7roUiXb1pVbK6cVemPI/H2qlKKBKL8dbJZG+dony2cIRLDZwOCjJucvCiFkPhhk1jO/T5gSeNMZyhye6Sboh/ARrCoqINd03NEal/aYBuLUpt58BKSxK7Q/01FVjacLLbp/Ip6SHv/U6JTfQ==; 3:gjFbzqBGIjQpMH7pLSHmE3rWOgNz815cGFP1qsR3zwIdlam1W3+2OzvemEyFp3BGACKcGXaXxO3mpsmlTKGjqWNiWOxKzmad/PvpW/BQGs0ZUgyeYzmw+uCwmcDuJRzX; 25:bv7DvSG9cXuQY/JXR+WymrQ63rvQY4Yy5VCsNcVh9LrjO3i01uE6XYaa/bF5cVUd++I2tkeP59IffGMPkF3Raaa/vBQHYlIqnW67bQliwN3u6LgLEPnm2dGXnlVCVx10oY8LGacibI0O8H9gsli3ZqrfdFbhZSMBgQWMRsMb+UcbatR+Vb/m45qtDpQHxCU/8uz2dXeEHFfQLWwH/JZUpriDW6B2tC7Bi3b/4LejwhbhdOl0MwbMBnqphKs05dFU X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR07MB624; X-MS-Office365-Filtering-Correlation-Id: 0ed3dcc1-04c6-4113-ba73-08d317bbbf12 X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 20:vEZF+2or0rguwYjOdKg9iCQMU1tbg+u4t3SQ6A255MPyg/bKe84lj95nogkrZ1iaqznLZ05QcN6cc0g9Ojo2LT3XudTs0j83cENqOAVtAqH+Tr6mPQ9NoaXUdPL2sML61O/96EcLDrtuJVfRlzpGz2hSNXsGXAl+i7PcCnjXNOOQMZ/VAxFMPrWRU6/qig+mXq5NDm5lxEzgdA8uy2zxPw721zQwxNUO6Ze2+SdNi8p5nNGFzeY+lTjljzfioLLtGitDZ2U4jxXDaazVFEElU7ganH1irwO2cEIQlU//naXxgXpGnbouumy4wdQEoFa/PzyTDw9WJuOFKbQbOiotyhIC548RtjIeMAooRAkKA/NaxgVDyA/g1GzYCQv17GypSbqT7NR979iHNZU82nWqgFDnv6/EJleoV1U32K5HoKhpB5I+AJ3n7iBNGppTpNEMAutYUPzhzdkV5rmuc0oY9D6GSaYHuewcbEgOn1gTfP3MwqTX3Bi4wLueYGHzpip/jgzXqWZlR8lHhcFUZkGg20MUoFgTu2bO+yRnFLoezny8rCXVdtT9XB34sRRU4nrzAe9wl0iEzJQccE584kyqhOGxoXV5CfP6M0/JE2k6qsU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(10201501046); SRVR:DM2PR07MB624; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB624; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB624; 4:VLLmVdqJ4x0vNuCfNpBNdwH8j4jRg2gmZMkpK1udOkIkPUfmCcm/kMXlD7nl5ssXnxZ51wpkXlzA9z8o/9uwVlyqCK8NfDmXrKjOEvMPHfA7/jPxp0K3lpukcod4DRAZguoJzlWf9uhQWda4RIKajeAa1gV0wLa3cYaGXJ3crsvAyI7Of3ADiWd/w6EcpvAP5DybLMXEFWPOdhKcx/HPSVRVD3BNSgTj204HdkrywVzcJQSrqwy0CA8tYmV9gt16kMUoEUdLRI97kirZAQwMgUsaFEeiSbjolAf6rEvOJt1sq0AfJv0YuSyoOCN3LLAj/NDYGfgMxFrPpVeOlir3wV4Hrq2vhNRzPxINQkXVja/ahE+2c3hplyhOEFa25j+rS4nIW3tMBIwqSAGlKgne/P66pa4DfF8+llRR1bDzuAQljr0IFTtmr3Kd3oK6sYQc X-Forefront-PRVS: 0814A2C7A3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(76176999)(101416001)(50986999)(47776003)(106356001)(2201001)(19580405001)(19580395003)(66066001)(2906002)(87976001)(42186005)(76506005)(105586002)(229853001)(5001960100002)(189998001)(40100003)(77096005)(5008740100001)(586003)(122386002)(1096002)(36756003)(48376002)(33646002)(81156007)(4326007)(6116002)(97736004)(5001770100001)(50226001)(50466002)(5003940100001)(3846002)(2950100001)(5004730100002)(92566002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB624; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; DM2PR07MB624; 23:GGecubI5sQI0+zd2UubdZkfsNZRrTaGartmgN5lYN2?= =?us-ascii?Q?av71sFQlM3dBTqllpxAp9cjXT9pYE23O89t5pPuQRW7Gih1mKsnwAkGXITx6?= =?us-ascii?Q?0eGaskP7NDkdNzHT0xFFpGXD4MD2SILqQTzGSi7nN1Z4dbHmpGIhcxEqqYHY?= =?us-ascii?Q?hoMtnpnvuVFoNa73mTqZr+YEG0t/nrKqerkQ/E+dzdv2W35GgGWUihxvjDg4?= =?us-ascii?Q?nEe91DHYfdF4uVaa5asaA82ti9n4fwJHX4kIkgKUa9zf4NLckOOt3VKAOsdj?= =?us-ascii?Q?po+LcPbK7Hf9aqspldsuK4EU5ZFO7pjEhrvGwGAaQlYuHD/3jyMw1iz3TuK2?= =?us-ascii?Q?v5Ul4dkd8fuqjJQIVKPBs2GxU++9tewVNBm+K+IkxUVL8n5U0UCzgUPffL0c?= =?us-ascii?Q?7nekI/8KGEft0xModWvSksG9RCyS4+g16CHfXtnI4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HH4GbyzUAOFhH7qQjAVTX2RaEaPd3/SNIN/4FdKK7Q+D6m1js+3llzvTnb12U6Q3YExHoY9/xitgjx9iVh/FRw/ccmk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2016 23:39:11.8089 (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-20160107_153935_628824_CAB09F11 X-CRM114-Status: GOOD ( 11.02 ) 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, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, jan.dakinevich@gmail.com, ddaney.cavm@gmail.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-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 | 18 ------------------ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/binfmt_elf32.c | 25 +++++++++++++++++++++++++ 4 files changed, 26 insertions(+), 20 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..a519233 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -172,24 +172,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/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..86002ec --- /dev/null +++ b/arch/arm64/kernel/binfmt_elf32.c @@ -0,0 +1,25 @@ +/* + * 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_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"