From nobody Mon Apr 6 21:32:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E980EC38145 for ; Fri, 2 Sep 2022 14:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236676AbiIBOaS (ORCPT ); Fri, 2 Sep 2022 10:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235936AbiIBO1f (ORCPT ); Fri, 2 Sep 2022 10:27:35 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17EA8168A07 for ; Fri, 2 Sep 2022 06:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=KetPcUlF1b8CoRduWYRVJ1Z0OAFAjWB3tdLqyvUvF+o=; b=Q+LN1KJ5tTML0ppwIjo9awpJFF YTRMCTltV1xg0UBdjueEEpetKChLxj719aEN149U5fjpOJ0u6K0iRj9SHZrDIq+N9Sc/mnJfs8A2K LG+UGD/IUcsVZ6boMmQxYRy+wzm76RZm0UlZJYqCz+eRWcXtXJVLe2MGuUHSDyDUwA9F2oEkHSNLH D18MJfCo8IFZ4Njbxz8h6+7UEzQHr/qNDQh+KiZEKeUl0QZ503ZyRuA7g8wxTGmHwjBb1FOOwBSIM 2RByOfoO5Jp9VcsU4cylaaNE66DPHj06TezT/rTjFyo5Oli01hfPBrDCxKYSuUaQSBfyDYflPwWzB xivfqgxg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU77M-008g8C-BV; Fri, 02 Sep 2022 13:53:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 26CC4301D06; Fri, 2 Sep 2022 15:53:54 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id D5C952B8EF7F3; Fri, 2 Sep 2022 15:53:52 +0200 (CEST) Message-ID: <20220902130949.370354037@infradead.org> User-Agent: quilt/0.66 Date: Fri, 02 Sep 2022 15:06:54 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, x86@kernel.org, Linus Torvalds , Tim Chen , Josh Poimboeuf , Andrew Cooper , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , Joao Moreira , Joseph Nuzman , Steven Rostedt , Juergen Gross , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , K Prateek Nayak , Eric Dumazet Subject: [PATCH v2 29/59] objtool: Track init section References: <20220902130625.217071627@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra For future usage of .init.text exclusion track the init section in the instruction decoder and use the result in retpoline validation. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 17 ++++++++++------- tools/objtool/include/objtool/elf.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -380,6 +380,15 @@ static int decode_instructions(struct ob !strncmp(sec->name, ".text.__x86.", 12)) sec->noinstr =3D true; =20 + /* + * .init.text code is ran before userspace and thus doesn't + * strictly need retpolines, except for modules which are + * loaded late, they very much do need retpoline in their + * .init.text + */ + if (!strcmp(sec->name, ".init.text") && !opts.module) + sec->init =3D true; + for (offset =3D 0; offset < sec->sh.sh_size; offset +=3D insn->len) { insn =3D malloc(sizeof(*insn)); if (!insn) { @@ -3720,13 +3729,7 @@ static int validate_retpoline(struct obj if (insn->retpoline_safe) continue; =20 - /* - * .init.text code is ran before userspace and thus doesn't - * strictly need retpolines, except for modules which are - * loaded late, they very much do need retpoline in their - * .init.text - */ - if (!strcmp(insn->sec->name, ".init.text") && !opts.module) + if (insn->sec->init) continue; =20 if (insn->type =3D=3D INSN_RETURN) { --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -38,7 +38,7 @@ struct section { Elf_Data *data; char *name; int idx; - bool changed, text, rodata, noinstr; + bool changed, text, rodata, noinstr, init; }; =20 struct symbol {