Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1832001imw; Sat, 16 Jul 2022 16:19:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uPQJiWm+4UHFBs0Nd9AFp2KXdDbL343Y0FxniABHW+sM64ICyxXWFeseSgpVtP7COZNkQv X-Received: by 2002:aa7:dd4b:0:b0:43a:d508:7cb9 with SMTP id o11-20020aa7dd4b000000b0043ad5087cb9mr28783749edw.218.1658013584644; Sat, 16 Jul 2022 16:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658013584; cv=none; d=google.com; s=arc-20160816; b=zP0R1PRozofQa0EujktIiOMYEg2xaiq2YkIpK0IjEan+oUos0U7J+WvWwjRo1Q/Sbs 18/3MuAZQEs0TQyGZO7GaWJhbo+uA/KNC0WZkKUj1Daf9jepjw0RKBSlEb4zUFPMe01B j5blY1WMAu3KcYCvpZAGaYQVWHKLfGoVRc/maDYNdUtBPQixwbF+KzydHLPMB8TE30aU gOpkam4I7LO2pfliy0CU9iKihNE4+3+06q3Joyxe95WVAvZKJDMVGlAJtwq6ISvGx+Iq k0W0Dh2lz+6FVh/RE26MXzHHbszVWEjRh8Ca37a686NTVrgV8azxV9QZYU2w6OqPeAUA vzMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=l2lzGHvFrgNLjFsSfHpJzcBOALkxr+/ChBRuIFW3BaA=; b=H2PK88KtllKpDqy7mebKUG7s5EVrxowrOr6N9cuTrc9tjfQxjR7x7KWdUIuCZ5mP5U JSejIjuvHG0WeIb9vWaVEfWgHFTfU4tmguUdQY1OVjJ3FzryZk6WMvnNeNF7LeC9of7H cgJ5LmlpewXZZsnw0HwBk8d5JX79xFeZrzccE0JIZE4z0+VjCk4DaZn0qrPvCT6H0NJP /3EzfGx6oJYm5BpGQN0WCSfvGuZUIMvLcdCyfZlAbKeAoId1xfesWczTwUWjIRxpK/Ka NSnD+evq55zTj+hp8hCKKQ9gUd8X1rgP3HsGBELLZY8Luj+44+tzD9jL2JsBwV9PQ8vK 84OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XONyBgQq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d22-20020a50f696000000b00437d9388cd4si9836351edn.275.2022.07.16.16.19.20; Sat, 16 Jul 2022 16:19:44 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XONyBgQq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233017AbiGPXRn (ORCPT + 99 others); Sat, 16 Jul 2022 19:17:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbiGPXRa (ORCPT ); Sat, 16 Jul 2022 19:17:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C587A1AF19 for ; Sat, 16 Jul 2022 16:17:23 -0700 (PDT) Message-ID: <20220716230953.080514530@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1658013441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=l2lzGHvFrgNLjFsSfHpJzcBOALkxr+/ChBRuIFW3BaA=; b=XONyBgQq0seJpfnpxivemXHQE6LTkW160Y2Kc05nkwQMtyGGWMjpnAP9LOgWZe+psc0A4X LPTKvPvFpivllkiFQhzYIeDu8IOwzBgFLSNs1Ml9KFgC8d3nf4M7gHUnF6ip4JV4wPvFAi DGENKBqU89blXosybfItpdtQ3XQUlYkiUNnKI0vgCCjCfVpVM+/vl+dbXPelhNnuQuSLz5 hir4SERcmTYaMPO23zu4Z99s+U+3Our9b1OCjzb1PQ+zI2NzXZ8anL/FxGAOtOVewTdZoB 3AfUwY3p9kzL9QzvaRD/wN9II2lABQMX5xfgTRKjK7oRqN7/dSw60tZ4CRbVEQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1658013441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=l2lzGHvFrgNLjFsSfHpJzcBOALkxr+/ChBRuIFW3BaA=; b=OWbQxHqw/P1t2rc6hxBIsazunE0+o6TPZck5IeDtbgI9NDEzaX8Q1e8J+CuU7jsoV0fPEp 3gN/yNKSEdQWbkAQ== From: Thomas Gleixner To: LKML Cc: 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 , "Peter Zijlstra (Intel)" Subject: [patch 07/38] objtool: Track init section References: <20220716230344.239749011@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Sun, 17 Jul 2022 01:17:21 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 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 --- 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 = true; + /* + * .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 = true; + for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { insn = malloc(sizeof(*insn)); if (!insn) { @@ -3720,13 +3729,7 @@ static int validate_retpoline(struct obj if (insn->retpoline_safe) continue; - /* - * .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; if (insn->type == 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; }; struct symbol {