From patchwork Mon Oct 17 14:54:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 3524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1493880wrs; Mon, 17 Oct 2022 07:57:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6qEgQXVIztzytET9GvwtRmS5GQEpqkZafG9fiQbL04sLxQdvRm15KlFcxCMEokhL4qszgM X-Received: by 2002:a17:90a:e60d:b0:20a:f035:176b with SMTP id j13-20020a17090ae60d00b0020af035176bmr14321307pjy.127.1666018648022; Mon, 17 Oct 2022 07:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666018648; cv=none; d=google.com; s=arc-20160816; b=YjP4lR+6Ya2G6Qz3f407P8VJVZ1EZKwOZUaILK3FJv16hBQ1LeDz+tvXcvsYbnM/eM fxxjbSlwzmRyhICxC2AK8/zrnpHDqeRtTHnQMh2p+Aaw7o6XKe+BZm9cImACmL53Sma7 LN+3h7dWt5K4saMJZ8rcfsxmZ2baSC0SCPV7mAXSpab/Gw7m9eIGeusVLvsuMdLF9Fn9 ZrbnSVj1PR/+s8utFYNFprOcRXpQY9GOqK4OPgvYcgyEfrr7fQ33PhF0wRQs2muspCKH pR8s+Tps9XEU1gAQy8LjxQlcsj0J6AxW1CCIH0ahPbiU/qOtY1qcvSUZ0p32s1aMg0qa eIUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=9hp0mos0E5tiiArrrX3oYVon6nqy3KoAW1xuLuR6niQ=; b=yGHCfQSBy5TwEsPIYM2vEFK7+LEt7pCvN/U0to1ioCamhsoauRGeXbWrsrWST3+zwf z/dtIfh3Sj5UfAmZYaYWdgeMrGd57vg0GukGz4TgKi5S8zi0Fy7j/M1zjvvmCqXXATjF bgl56fxiWJOE/YCdjuZ2PDQc5RScOl4X+iGKd+RiBk1zIfzTnU3nA5q/d6miil5tRJL9 iRuErRxotbvf6E6SV1u+XW0e5WfsmJ7hSftLnDOAr4fwG+QnFVUnqkS7N5wMjIZ8uMgG lNzcJ+KbQzdbBprnEE4BD64IhvJHflaajCJKgZ4AR59TTozlJzJEMi5nfbh16qpqyrz8 FnUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=j4Ox5Vv1; dkim=neutral (no key) header.i=@linutronix.de; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a65590b000000b0046b014d12d8si12165414pgu.492.2022.10.17.07.57.15; Mon, 17 Oct 2022 07:57:27 -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=j4Ox5Vv1; dkim=neutral (no key) header.i=@linutronix.de; 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 S231409AbiJQO4f (ORCPT + 99 others); Mon, 17 Oct 2022 10:56:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231183AbiJQOyP (ORCPT ); Mon, 17 Oct 2022 10:54:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD1F6919C; Mon, 17 Oct 2022 07:54:04 -0700 (PDT) Date: Mon, 17 Oct 2022 14:54:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666018442; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9hp0mos0E5tiiArrrX3oYVon6nqy3KoAW1xuLuR6niQ=; b=j4Ox5Vv19GswD3+zOb+aGkXIhqDSgs3dZzBRSSYbJZC2TZc3MpDUtHxGb6A94zHrsJO6he Dzegfx6PjNTVetEyD6S9ZVgzT+pcSvGxVVeLznuOeHDUCFyzeO649q2UmWppsWmYvQcChT 5hp+QB1eEz/T9dPkAZQjpDsRONGamuVx1oVVO96Qgu/YBqvrbauyfMcIJ37zGvOGoJ2aRS KErLE+xq7aqqBu77piYUYdrQQ7xksmfX4fvWidi9tXFUh38ceWFRLLpD/wA35snK5cOY+T yYmGjcnQbbLS5NaclDb4V8AjmPGfOjOss0NyF4Brvcy6nG9G2GYc9nh3B0sSvw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666018442; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9hp0mos0E5tiiArrrX3oYVon6nqy3KoAW1xuLuR6niQ=; b=zFVxN+UdE4t4XWbf3py0T3xVKSsy0H+SUCzRQmZLBfidhEXGuLk3zlK8ulEc3PXUwoTxX2 LhChO7UdEBBtxIBA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] objtool: Track init section Cc: "Peter Zijlstra (Intel)" , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220915111145.910334431@infradead.org> References: <20220915111145.910334431@infradead.org> MIME-Version: 1.0 Message-ID: <166601844116.401.582646215088062442.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746947169521728140?= X-GMAIL-MSGID: =?utf-8?q?1746947169521728140?= The following commit has been merged into the x86/core branch of tip: Commit-ID: 6644ee846cb983437063da8fd24b7cae671fd019 Gitweb: https://git.kernel.org/tip/6644ee846cb983437063da8fd24b7cae671fd019 Author: Peter Zijlstra AuthorDate: Thu, 15 Sep 2022 13:11:08 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 17 Oct 2022 16:41:07 +02:00 objtool: Track init section 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) Link: https://lore.kernel.org/r/20220915111145.910334431@infradead.org --- tools/objtool/check.c | 17 ++++++++++------- tools/objtool/include/objtool/elf.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 7174bba..bb7c819 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -382,6 +382,15 @@ static int decode_instructions(struct objtool_file *file) !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) { @@ -3748,13 +3757,7 @@ static int validate_retpoline(struct objtool_file *file) 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) { diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index 16f4067..baa8085 100644 --- 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 {