From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3E88397350; Wed, 13 May 2026 03:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778643276; cv=none; b=p0JvgPhHXlg5c9MTTisVYHpDTt1s0xU3hn17zvDBPJcJ4hhB4zQC9EgAI7pxbp/dQlG0hE+EEGSt63Blwgd3BV8UBryFj97c0eGZAimDStz8Exfi+OJP70m2A+ebyLs2fk35igdM+LtGcMjiKxGfdCGYrSevFVNjtqaM9my5czY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778643276; c=relaxed/simple; bh=voedLEVhufD2EC2qnX2retheCvvJ6sgwG1j/M2rJ6o4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gz4GHtOl2xqqZtdSdhIKqm359pbnFq2pVRGbaBlObq4XoAHO7U3XI6RetfP3V/KzbkN3xXoX/XvzL3JhwGwgv3BHhn1eWlrWsPmMpSeN+d4wL9F1zdPNnXDHW91mRr1ejRH6Chg0Ew+i9iloekfjcISvC5jvczdsGJxfFY8jpvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vIprIIHJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vIprIIHJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 376F0C4AF0C; Wed, 13 May 2026 03:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778643276; bh=voedLEVhufD2EC2qnX2retheCvvJ6sgwG1j/M2rJ6o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIprIIHJ/gc88MjsvGV+iSCWjgIRrxQQ7HtYjYUFYhEl5ubF7WygFbdw2O31xsaMF jS8J4tdUeo4ObYLbE+VKPuDMBZGvzs2uAAFNvdgFyBHEG97Ng6EyqprLLUihe1fNMP h66I0LgN0RkUYXKvn7S4HRqFpl63oL++AAZHh3vHTJnTbXxzKKpOpidXg+4w+nrcsY CzP+nWsTp2cB+5utoDbiFdFuN5Dr5dSCwc9OVSwuw7Umz2WcZp17C0CzhyOvCoTJZs Yu+KmX8LPho6lxymdfETKlajMcGtuH7Oik5rXuqUIWr71e+rNJz1fnYa6ZwcyIxiXS acXMyjfLWa0GA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Miroslav Benes , Petr Mladek Subject: [PATCH v3 10/21] objtool: Ignore jumps to the end of the function for checksum runs Date: Tue, 12 May 2026 20:33:44 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sometimes Clang arm64 code jumps to the end of the function for UB. No need to make that an error for checksum runs. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 10b18cf9c3608..73451aef68029 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -37,6 +37,22 @@ struct disas_context *objtool_disas_ctx; size_t sym_name_max_len; +static bool validate_branch_enabled(void) +{ + return opts.stackval || + opts.orc || + opts.uaccess; +} + +static bool alts_needed(void) +{ + return validate_branch_enabled() || + opts.noinstr || + opts.hack_jump_label || + opts.disas || + opts.checksum; +} + struct instruction *find_insn(struct objtool_file *file, struct section *sec, unsigned long offset) { @@ -1593,10 +1609,14 @@ static int add_jump_destinations(struct objtool_file *file) /* * GCOV/KCOV dead code can jump to the end of * the function/section. + * + * Clang on arm64 also does this sometimes for + * undefined behavior. */ - if (file->ignore_unreachables && func && - dest_sec == insn->sec && - dest_off == func->offset + func->len) + if (!validate_branch_enabled() || + (file->ignore_unreachables && func && + dest_sec == insn->sec && + dest_off == func->offset + func->len)) continue; ERROR_INSN(insn, "can't find jump dest instruction at %s", @@ -2584,22 +2604,6 @@ static void mark_holes(struct objtool_file *file) } } -static bool validate_branch_enabled(void) -{ - return opts.stackval || - opts.orc || - opts.uaccess; -} - -static bool alts_needed(void) -{ - return validate_branch_enabled() || - opts.noinstr || - opts.hack_jump_label || - opts.disas || - opts.checksum; -} - int decode_file(struct objtool_file *file) { arch_initial_func_cfi_state(&initial_func_cfi); -- 2.53.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DC7E3A4257; Wed, 13 May 2026 03:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778643291; cv=none; b=G+rILZlhkQGmItYezR67Fs4mUQuoaG9Zjr+2asMXSS+JWtdfyofqTZeZ62WmRkEqxSFXH7Wlbsoyp0HhptNfNwWmGUR8h6JnA3isHkyIdcX3cJupn0WsmRWYXdqAygLmRQYNe/MNIDZOFmf62/G/S88yS3Gb7tB7UGHXUfBz9rM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778643291; c=relaxed/simple; bh=voedLEVhufD2EC2qnX2retheCvvJ6sgwG1j/M2rJ6o4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Inqwj1zXiWSCTW9C7y6j+/ywxZZKCNMprMV98kQKjpp/fXQRVp1t0JcknHyKSflw5kbB0OxSMb+y5JpQWUZHs5QoBvcttYQc5UNLrbKoubm0raT0/SE27Rh2H1NboiR3CejwHqv049Y43p4iy/tzTrXw7ijTe0sG5tUhpw1UR2M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hA06cJnD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hA06cJnD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3F3CC2BCFB; Wed, 13 May 2026 03:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778643291; bh=voedLEVhufD2EC2qnX2retheCvvJ6sgwG1j/M2rJ6o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hA06cJnDIUfmXB/3JBgPXTt/tPmcVQStNmHqYSgYdqyZK1z0fhnA5E1Wg+3OSwk4a l8+c9EEraTlHhcNn7ogPeQ/SxzRmhMbzbhv5S5t+feNsOaX+Kpu2J0K4LNjATTU4+X Hsv7TAQEP9qJYXyTOZnWW8Io2lS2QDF3YQ6h7tScpWhbeD2JBV8QITnFwehBfkuSYh p46H1xKZh9y+H9uzV/VPpcoRn3KpKS80XEnstUKE19kRTS2KmXnsYyDhAyzGzSAOn/ NxWt21EH45/0Jg707+N2zxMaWD/QGFatK5a9YDhSE1a5Fy/JXEp9CvMx/87hyCf7/R fKGB57IpVN9Bg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Miroslav Benes , Petr Mladek Subject: [PATCH v3 10/21] objtool: Ignore jumps to the end of the function for checksum runs Date: Tue, 12 May 2026 20:34:06 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: <20260513033406.N0SRbRrzPYTcMKPQyhyIIz9RF_0Iusd4DO3vuXpFKJw@z> Sometimes Clang arm64 code jumps to the end of the function for UB. No need to make that an error for checksum runs. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 10b18cf9c3608..73451aef68029 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -37,6 +37,22 @@ struct disas_context *objtool_disas_ctx; size_t sym_name_max_len; +static bool validate_branch_enabled(void) +{ + return opts.stackval || + opts.orc || + opts.uaccess; +} + +static bool alts_needed(void) +{ + return validate_branch_enabled() || + opts.noinstr || + opts.hack_jump_label || + opts.disas || + opts.checksum; +} + struct instruction *find_insn(struct objtool_file *file, struct section *sec, unsigned long offset) { @@ -1593,10 +1609,14 @@ static int add_jump_destinations(struct objtool_file *file) /* * GCOV/KCOV dead code can jump to the end of * the function/section. + * + * Clang on arm64 also does this sometimes for + * undefined behavior. */ - if (file->ignore_unreachables && func && - dest_sec == insn->sec && - dest_off == func->offset + func->len) + if (!validate_branch_enabled() || + (file->ignore_unreachables && func && + dest_sec == insn->sec && + dest_off == func->offset + func->len)) continue; ERROR_INSN(insn, "can't find jump dest instruction at %s", @@ -2584,22 +2604,6 @@ static void mark_holes(struct objtool_file *file) } } -static bool validate_branch_enabled(void) -{ - return opts.stackval || - opts.orc || - opts.uaccess; -} - -static bool alts_needed(void) -{ - return validate_branch_enabled() || - opts.noinstr || - opts.hack_jump_label || - opts.disas || - opts.checksum; -} - int decode_file(struct objtool_file *file) { arch_initial_func_cfi_state(&initial_func_cfi); -- 2.53.0