From patchwork Thu Aug 17 07:23:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 9905143 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 6F55060386 for ; Thu, 17 Aug 2017 07:25:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DAA528A9E for ; Thu, 17 Aug 2017 07:25:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11E4128ABE; Thu, 17 Aug 2017 07:25:22 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47DDE28A9E for ; Thu, 17 Aug 2017 07:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SKd4IUpYSs2G0oh3hIc2YNGlInlZWgeSzEDkkgKlJj8=; b=kzJ3C/R5cWg7O9HNu8nNlBIeIz Q3K0tu5B7WEU8s857mSytVK4+ixfudqgGU0/tQz1bqtdO7G79xqxaGoSDhjAGR5pdi8woG8xOglNp 5OVOW57+LnTcdMcLr5Mtl78IVMLKC7qZosOa/CyG/ur7/g0VQzPa2fJYoCslY9tUYnxtRErKsbq0u 5HqFNUMfhmgS6T7FU7uS8urPYlTCMrfnEkSBl4fGToXg1gdF3KbatFFclr/0/EE+GREJ2y+Bwbkkc 3zJKMVUSf9+OeGIgmzidz6Gjs++DewgYGxovpnyiIn5ntLaukgEKoDzIpFL52T9GOD9jahcA8KVWV td5JTJiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diFB3-0006ca-Ol; Thu, 17 Aug 2017 07:25:13 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diFAU-0005OB-Qb for linux-arm-kernel@bombadil.infradead.org; Thu, 17 Aug 2017 07:24:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vc1CoARzmCvIZYhsEntM1UNUggOoijzQdA+p5RLXua0=; b=0AtutAypGqX5gKY0yORutEh0r 3Lt3HgySpOwepBAf3zN4zM9dmOx/cy1JWbNXmO7LlUCT7+u2pjHzjPCm9DPaQyfn3xWsHuaWyMnbp DH9BUR84C2WvhbZVVpy9ZSesAz+DOm6GSNNuAAV92TbilVm7gxMtzREOqPrXz/yKU+X05JtFTNqpF LW8+Yoze5ukGk2sZRvfbo9VJ/tbIunRqVE78FiFEzhlloZFKv/EVunjSvQgvrweFoz5rfcFRv2Kpq OncFBaXVPg5bivCtPU6hdLbKzZf70VYqlLrUrMs/AtiwaOUIiiTHvcwRk9mOXIHKsJ/aTeecT4Vtf Ig0a5Ex7Q==; Received: from pb-smtp2.pobox.com ([64.147.108.71] helo=sasl.smtp.pobox.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diFAQ-0003FJ-TC for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2017 07:24:37 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id DAFA69789C; Thu, 17 Aug 2017 03:24:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=G7Ws mCZn2BWyjOIUmtOnVS3p5G8=; b=vnWPGb8ouYgmhQnCn7YHHyDfVfV84NSdYrxj XqhMqPZEDb9Rum+/0EybGW+Crk17aI0ly2ZmB2K/6tvVVTTjdBAVsfYPxwD1hiU8 zyEae7miTv49FUu7iyaJJQDjBxKVktzkwzqO84H6b/slHdV48hhXgLqYUTdf+3PB jDGqp/I= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id D2D0A9789B; Thu, 17 Aug 2017 03:24:10 -0400 (EDT) Received: from yoda.home (unknown [70.80.200.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 5329F97897; Thu, 17 Aug 2017 03:24:10 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 0727F2DA06DA; Thu, 17 Aug 2017 03:24:09 -0400 (EDT) From: Nicolas Pitre To: Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/8] ARM: add ELF_FDPIC support Date: Thu, 17 Aug 2017 03:23:44 -0400 Message-Id: <20170817072347.19990-6-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170817072347.19990-1-nicolas.pitre@linaro.org> References: <20170817072347.19990-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: 0FFBFB56-831D-11E7-8A1F-9D2B0D78B957-78420484!pb-smtp2.pobox.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Mickael Guene ." , Alexandre Torgue MIME-Version: 1.0 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 This includes the necessary code to recognise the FDPIC format on ARM and the ptrace command definitions used by the common ptrace code. Based on patches originally from Mickael Guene . Signed-off-by: Nicolas Pitre Tested-by: Vincent Abriou --- arch/arm/include/asm/elf.h | 12 ++++++++++++ arch/arm/include/asm/mmu.h | 4 ++++ arch/arm/include/uapi/asm/ptrace.h | 4 ++++ fs/Kconfig.binfmt | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h index e2786acf82..ad0ca4f2ba 100644 --- a/arch/arm/include/asm/elf.h +++ b/arch/arm/include/asm/elf.h @@ -100,6 +100,11 @@ struct elf32_hdr; extern int elf_check_arch(const struct elf32_hdr *); #define elf_check_arch elf_check_arch +#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC platform */ +#define elf_check_fdpic(x) ((x)->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC) +#define elf_check_const_displacement(x) ((x)->e_flags & EF_ARM_PIC) +#define ELF_FDPIC_CORE_EFLAGS 0 + #define vmcore_elf64_check_arch(x) (0) extern int arm_elf_read_implies_exec(int); @@ -120,6 +125,13 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs); have no such handler. */ #define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0 +#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_addr) \ + do { \ + (_r)->ARM_r7 = _exec_map_addr; \ + (_r)->ARM_r8 = _interp_map_addr; \ + (_r)->ARM_r9 = dynamic_addr; \ + } while(0) + extern void elf_set_personality(const struct elf32_hdr *); #define SET_PERSONALITY(ex) elf_set_personality(&(ex)) diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h index a5b4742105..e0eb16680a 100644 --- a/arch/arm/include/asm/mmu.h +++ b/arch/arm/include/asm/mmu.h @@ -33,6 +33,10 @@ typedef struct { */ typedef struct { unsigned long end_brk; +#ifdef CONFIG_BINFMT_ELF_FDPIC + unsigned long exec_fdpic_loadmap; + unsigned long interp_fdpic_loadmap; +#endif } mm_context_t; #endif diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h index 5af0ed1b82..3173eb9751 100644 --- a/arch/arm/include/uapi/asm/ptrace.h +++ b/arch/arm/include/uapi/asm/ptrace.h @@ -31,6 +31,10 @@ #define PTRACE_SETVFPREGS 28 #define PTRACE_GETHBPREGS 29 #define PTRACE_SETHBPREGS 30 +#define PTRACE_GETFDPIC 31 + +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 /* * PSR bits diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index b2f82cf6bf..6ef70ce8e9 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -35,7 +35,7 @@ config ARCH_BINFMT_ELF_STATE config BINFMT_ELF_FDPIC bool "Kernel support for FDPIC ELF binaries" default y - depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X) + depends on ((ARM && !MMU) || FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X) select ELFCORE help ELF FDPIC binaries are based on ELF, but allow the individual load