Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4980519iog; Wed, 22 Jun 2022 09:28:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tocluXMYmWyuvN9C4/x6c381oSjM+EM2gQyoNJQfxMs7MhLzTJmGZxZxEZanvPeBJ03DYu X-Received: by 2002:a17:90a:ca8b:b0:1ec:9afb:1a2d with SMTP id y11-20020a17090aca8b00b001ec9afb1a2dmr22029416pjt.225.1655915303830; Wed, 22 Jun 2022 09:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655915303; cv=none; d=google.com; s=arc-20160816; b=zrczVumpycumJD9zS8xr2+VMndiw7+csw5uzpo6ALxWXYc6Ub9WoT4OlRfHCj/z3T/ qBeNihWt55RvbnAue6l3oEcivAapfHADDrGKLKwRaW2iibrT3Rmj+J1c11OAWezDwu5y 7OlFGjE53ghnUt/svTmPeZYwJ5IDv5Ec9hL+hH08caZtTrMU0Rl7vwYpGrBaVfSaLwvc Kk+E9hJz6eaDNTIDsvA5IJfxLaOACOdi0UxjwmAPOoWzOzdcUzG+2yQtpnnbbHVhw7eC g47Mcg9QS7e5/rH2J1knuxnF0X7Of6oo4BVyhusFsmkgsKIFk07Y3FurKnNvuk/co9TU narQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ugDI1d9NoryDkC3zLMi0ykqR4Kvjn++sO8+AdeMq9Gw=; b=ZTp9Sz/6zJCyFsaTiL3qd659EVoa1HW5cEo/+ypzZ+YKeEcseZzgeO5+Mai8OR9yBz 0wl8GXDxZ20mhUD3p49THCVmtRYaWEk4h9Tx9EKciPnSOouUTsRH6esdcKQVqRK4GC/M jzjJPLLSQ53Zxb3XTvgUVadtKnepIPBbbSpQL61FDr3E4OiWb59DT64QJzibLyOyhRJY KNO6xb/B/wEJuWpMliM8yQ+I67SymxQlxOKIm+F3FKkq7tHxzgj/nRlzXnfMIG+XB3+C iU/fgma+eV3S/CPHsGNBsmvlK0bDCqVt8v10eJ9G0wUbUtr6VKG9c++Txt8z5Rf5xxn1 tUKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a63e347000000b00408c66425f8si21273494pgj.270.2022.06.22.09.28.12; Wed, 22 Jun 2022 09:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359677AbiFVPxE (ORCPT + 99 others); Wed, 22 Jun 2022 11:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357223AbiFVPws (ORCPT ); Wed, 22 Jun 2022 11:52:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67BD410C0; Wed, 22 Jun 2022 08:52:45 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LSntV4jblzkWN0; Wed, 22 Jun 2022 23:51:30 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 22 Jun 2022 23:52:43 +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.2375.24; Wed, 22 Jun 2022 23:52:43 +0800 From: Chen Zhongjin To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v5 08/33] objtool: arm64: Accept non-instruction data in code sections Date: Wed, 22 Jun 2022 23:48:55 +0800 Message-ID: <20220622154920.95075-9-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220622154920.95075-1-chenzhongjin@huawei.com> References: <20220622154920.95075-1-chenzhongjin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The compiler can generate some '0x0' words in code sections to pad the end of functions. Also some pesudo-instructions can generate data in code sections. Mark them as INSN_NOP. If there are other undecoded instructions, just record and remove them from validation list. These doesn't influence check and orc generation because these undecoded instructions also won't be excuted. Signed-off-by: Chen Zhongjin --- tools/objtool/arch/arm64/decode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c index 9bdd59e0d11d..37e42148dbe0 100644 --- a/tools/objtool/arch/arm64/decode.c +++ b/tools/objtool/arch/arm64/decode.c @@ -347,8 +347,15 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec switch (aarch64_get_insn_class(insn)) { case AARCH64_INSN_CLS_UNKNOWN: - WARN("can't decode instruction at %s:0x%lx", sec->name, offset); - return -1; + if (insn == 0x0) { + *type = INSN_NOP; + } else { + WARN("undecoded insn at %s:0x%lx", sec->name, offset); + return record_invalid_insn(sec, offset); + } + + break; case AARCH64_INSN_CLS_DP_IMM: /* Mov register to and from SP are aliases of add_imm */ if (aarch64_insn_is_add_imm(insn) || -- 2.17.1