From patchwork Tue Apr 9 13:52:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Gault X-Patchwork-Id: 10891329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C00B61390 for ; Tue, 9 Apr 2019 13:53:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A879028673 for ; Tue, 9 Apr 2019 13:53:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C0AB28841; Tue, 9 Apr 2019 13:53:35 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 009AE286A1 for ; Tue, 9 Apr 2019 13:53:34 +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: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:In-Reply-To: References:List-Owner; bh=Ys0vpf8Z1+P62IrX1zJjw13VJG+r0PN6iXRJjVfebwY=; b=dGb v0i+MTQK8ql1Af0hrdA8vhDGMaunuwxH3rOctyAOayi0fjzHvMS3H02Sp1S06WrwK/3tIrn5nZHUt tcNlkOOfwsNMnySfvzfmHgNi6uaBlihuFAsYcCkjYyFFCI8OgVA71bcX28j+tnVHvka2+aP/SPZYg wTOqSvdlH9x9t127yPyE3WOksPcPWz7IAcH2Q5/lgDnAQfMCr531DVViaw1V81jZCg0VgXLLv/E9j wy8MawFGrPfMVSmy5Q1hq9ZZb3malQbYnj8cLz7pwcC4cKZIiyUusUlPC6AwZJBmsS7jgEh9ykTEZ Ci6zOlqY5UP0hrGlfFkb1vNHNVAARdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDrBq-00038H-FQ; Tue, 09 Apr 2019 13:53:30 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDrBn-00037j-Df for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2019 13:53:28 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 60954A78; Tue, 9 Apr 2019 06:53:25 -0700 (PDT) Received: from e121650-lin.cambridge.arm.com (e121650-lin.cambridge.arm.com [10.1.196.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D91D43F68F; Tue, 9 Apr 2019 06:53:23 -0700 (PDT) From: Raphael Gault To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/6] objtool: Add support for Arm64 Date: Tue, 9 Apr 2019 14:52:37 +0100 Message-Id: <20190409135243.12424-1-raphael.gault@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190409_065327_477374_8AE879DC X-CRM114-Status: GOOD ( 17.16 ) 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: julien.thierry@arm.com, peterz@infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, Raphael Gault , jpoimboe@redhat.com 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 Hi, As of now, objtool only supports the x86_64 architecture but the groundwork has already been done in order to add support for other architecture without too much effort. This series of patches adds support for the arm64 architecture based on the Armv8.5 Architecture Reference Manual. * Patch 1 adapts the existing code to be able to add support for other architecture. * Patch 2 provide implementation of the required function for the arm64 architecture. * Patch 3 adapts the checking of the stack state for the arm64 architecture. * Patch 4 & 5 fix some warning objtool raised in some particular functions of ~/arch/arm64/kernel/sleep.S. Patch 4 add a macro to signal that some function should be ignored by objtool. * Patch 6 enables stack validation for arm64. Theses patches should provide support for the main cases and behaviour. However a few corner cases are not yet handled by objtool: * In the `~/arch/arm64/crypto/` directory, I noticed that some plain data are sometimes stored in the `.text` section causing objtool to mistake this for instructions and trying (and failing) to interprete them. If someone could explain to me why we store data directly in the .text section I would appreciate it. * In the support for arm32 architecture such as in `~/arch/arm64/kernel/kuser32.S` some A32 instructions are used but such instructions are not understood by objtool causing a warning. I also have a few unclear points I would like to bring to your attention: * For x86_64, when looking for a symbol relocation with explicit addend, objtool systematically adds a +4 offset to the addend. I don't understand why even if I have a feeling it is related to the type of relacation. * I currently don't have a clear understanding about how switch-tables are generated on arm64 and how to retrieve them (based on relocations). Please provide me with any feedback and comments as well on the content than the style of these patches. Thanks, Raphael -> Raphael Gault (6): objtool: Refactor code to make it more suitable for multiple architecture support objtool: arm64: Add required implementation for supporting the aarch64 architecture in objtool. objtool: arm64: Adapt the stack frame checks and the section analysis for the arm architecture arm64: assembler: Add macro to annotate asm function having non standard stack-frame. arm64: sleep: Add stack frame setup for __cpu_supsend_enter objtool: arm64: Enable stack validation for arm64 arch/arm64/Kconfig | 1 + arch/arm64/include/asm/assembler.h | 18 + arch/arm64/kernel/sleep.S | 4 + tools/objtool/Build | 1 - tools/objtool/arch.h | 11 + tools/objtool/arch/arm64/Build | 6 + tools/objtool/arch/arm64/bit_operations.c | 65 + tools/objtool/arch/arm64/decode.c | 2870 +++++++++++++++++ .../objtool/arch/arm64/include/arch_special.h | 44 + .../arch/arm64/include/asm/orc_types.h | 109 + .../arch/arm64/include/bit_operations.h | 22 + tools/objtool/arch/arm64/include/cfi.h | 76 + .../objtool/arch/arm64/include/insn_decode.h | 219 ++ tools/objtool/arch/arm64/orc_gen.c | 40 + tools/objtool/arch/x86/Build | 1 + tools/objtool/arch/x86/decode.c | 111 + tools/objtool/arch/x86/include/arch_special.h | 35 + tools/objtool/{ => arch/x86/include}/cfi.h | 0 tools/objtool/{ => arch/x86}/orc_gen.c | 10 +- tools/objtool/check.c | 209 +- tools/objtool/check.h | 1 + tools/objtool/elf.c | 3 +- tools/objtool/orc.h | 4 +- tools/objtool/special.c | 18 +- 24 files changed, 3740 insertions(+), 138 deletions(-) create mode 100644 tools/objtool/arch/arm64/Build create mode 100644 tools/objtool/arch/arm64/bit_operations.c create mode 100644 tools/objtool/arch/arm64/decode.c create mode 100644 tools/objtool/arch/arm64/include/arch_special.h create mode 100644 tools/objtool/arch/arm64/include/asm/orc_types.h create mode 100644 tools/objtool/arch/arm64/include/bit_operations.h create mode 100644 tools/objtool/arch/arm64/include/cfi.h create mode 100644 tools/objtool/arch/arm64/include/insn_decode.h create mode 100644 tools/objtool/arch/arm64/orc_gen.c create mode 100644 tools/objtool/arch/x86/include/arch_special.h rename tools/objtool/{ => arch/x86/include}/cfi.h (100%) rename tools/objtool/{ => arch/x86}/orc_gen.c (96%)