From patchwork Thu Apr 7 12:01:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Zhongjin X-Patchwork-Id: 12805137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8F242C433F5 for ; Thu, 7 Apr 2022 12:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :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=6qd1H1j4gsHCnP94fLEGLlzm4VULpihYmUpY30ciJBc=; b=aK20YACiuZlJLu JyYadMzdBxIfHL128DQFjC8CqKCDbRfoKtmS8dVoEMciKc9gDfG8xMZ199B85AJtIMnS6kMcLsf0M nmWFocNrdGpE850yK18VHck2HhQJnYXCbJAYBs9WnaC2FMFdx7GmELrGju/2J+YP/W/5ako5sbo37 2INKF8+MjPjCAYcY205LI0q8a/L+7c32WUIBvZsWkpwi93rxJsPKlgyDlcdWiihVYGyMVBYwwag6P JHhBujV2M+Y1+0fGTJ5UGeXcz69rg/kp/48hAgG2S5YBX0WzkFaKYxyBxVwzJcF8snAbsb9qnkdwP moUGriMXoUfpse9AN2qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncQrj-00Bi5g-Cr; Thu, 07 Apr 2022 12:03:55 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncQqY-00BhSn-91 for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 12:02:47 +0000 Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KZ0Lh49pyzFpZ4; Thu, 7 Apr 2022 20:00:12 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 7 Apr 2022 20:02:32 +0800 Received: from ubuntu1804.huawei.com (10.67.175.36) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 7 Apr 2022 20:02:32 +0800 From: Chen Zhongjin To: , CC: , , , , , , , , Subject: [RFC PATCH v3 00/13] objtool: add base support for arm64 Date: Thu, 7 Apr 2022 20:01:28 +0800 Message-ID: <20220407120141.43801-1-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_050242_654142_F3C76CBB X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, This series enables objtool to start doing stack validation on arm64 kernel builds. The work for objtool has been stopped for a while. Julien and Raphael worked for this [1] but it seems now nobody is carrying it on. To re-bring it to people's vision, this v3 update just makes some simply changes including rebasing to mainline, code cleanning and one bug fix. Previous patch had finished the decoder part of objtool. It passed my building test with allyesconfig and only few of objfile report error. Julien had some unorganized commits in his repo [2], mainly about changes to arm64 code to eliminate some of these errors. While fixing these problems in next version, I'm also planning to implement the orc unwinder for arm64, then we can completely test everything on arm64. [1] https://lkml.org/lkml/2021/3/3/1135 [2] https://github.com/julien-thierry/linux.git --- Changs v2 -> v3: - [04] rebase Julien's version to mainstream and solve conflicts. - [05, 06, 08] Merge dumplicate "*type = INSN_OTHER". - [08, 09, 10] When meeting unrecognized instructions such as datas in .text code or 0x0 padding insns, last version used "loc->ignorable" to mark and remove them from objtool insn list. However there are two problems to do so: 1. when meeting insns can't be decoded or excluded, objtool will just stop. 2. deleting every insn can cause problems in fellow procedure. So I changed "record_invalid_insn" that we can delete one insn or just set it ignored. Now check will throw an error and going on when meeting undecodable instructions. Also, to prevent the confusion between "loc->ignorable" and "insn->ignore" I changed "ignore" to "delete". Changs v1 -> v2: - Drop gcc plugin in favor of -fno-jump-tables - miscelaneous fixes and cleanups ---> Julien Thierry (12): tools: Add some generic functions and headers tools: arm64: Make aarch64 instruction decoder available to tools tools: bug: Remove duplicate definition objtool: arm64: Add base definition for arm64 backend objtool: arm64: Decode add/sub instructions objtool: arm64: Decode jump and call related instructions objtool: arm64: Decode other system instructions objtool: arm64: Decode load/store instructions objtool: arm64: Decode LDR instructions objtool: arm64: Accept non-instruction data in code sections objtool: arm64: Handle supported relocations in alternatives objtool: arm64: Ignore replacement section for alternative callback Raphael Gault (1): objtool: arm64: Enable stack validation for arm64 arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 4 + tools/arch/arm64/include/asm/insn.h | 565 +++++++ tools/arch/arm64/lib/insn.c | 1464 +++++++++++++++++ tools/include/asm-generic/bitops/__ffs.h | 11 + tools/include/linux/bug.h | 6 +- tools/include/linux/kernel.h | 21 + tools/include/linux/printk.h | 40 + tools/objtool/Makefile | 5 + tools/objtool/arch/arm64/Build | 8 + tools/objtool/arch/arm64/decode.c | 500 ++++++ .../arch/arm64/include/arch/cfi_regs.h | 14 + tools/objtool/arch/arm64/include/arch/elf.h | 8 + .../arch/arm64/include/arch/endianness.h | 9 + .../objtool/arch/arm64/include/arch/special.h | 22 + tools/objtool/arch/arm64/special.c | 36 + tools/objtool/arch/x86/decode.c | 5 + tools/objtool/check.c | 6 + tools/objtool/include/objtool/arch.h | 3 + tools/objtool/sync-check.sh | 5 + 20 files changed, 2728 insertions(+), 5 deletions(-) create mode 100644 tools/arch/arm64/include/asm/insn.h create mode 100644 tools/arch/arm64/lib/insn.c create mode 100644 tools/include/linux/printk.h create mode 100644 tools/objtool/arch/arm64/Build create mode 100644 tools/objtool/arch/arm64/decode.c create mode 100644 tools/objtool/arch/arm64/include/arch/cfi_regs.h create mode 100644 tools/objtool/arch/arm64/include/arch/elf.h create mode 100644 tools/objtool/arch/arm64/include/arch/endianness.h create mode 100644 tools/objtool/arch/arm64/include/arch/special.h create mode 100644 tools/objtool/arch/arm64/special.c