From patchwork Fri Jun 9 07:47:40 2023 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: 105330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp780240vqr; Fri, 9 Jun 2023 00:56:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lU5qSA5IGs1+0qiUgdV40RBqvhe8jdKsgVbHC4oiM9DWeoqft8mEzg+anK0palOu9wAUf X-Received: by 2002:a17:903:41ca:b0:1a6:a405:f714 with SMTP id u10-20020a17090341ca00b001a6a405f714mr701287ple.63.1686297360560; Fri, 09 Jun 2023 00:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297360; cv=none; d=google.com; s=arc-20160816; b=RRXAqY+NPUDFdHKoczSTwvxC6GSLARUHqYeBlBU478L16FpJpEAYOjY7A3Q2qNuvCQ b8X8PkemsoxJxsX/4YbEuC9wQAfvnDeUGELMmF5XEgSP1zeyjyFozx8BtkENmokSz3W3 WgUTXyY/XUEDhhUv3hM0QxIfdc9V+xkT0N4umWotmLDsix6wuTeb46yOLaBnY1DJHExi wreeiqtqvdrPSOiXmkgLXsiuuiJ5NOBXuteerYsosx3yGj8WnVo1PcM0wPrh54h5IFwB qygpA1LfY1BumFY1jw1wxJUpVvwdx8Zv+LyuAjcNUaHRO5bQqCSeq7XdtuDN1G19baZP uTkQ== 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=vlHTX3+aA/2+zboelFSuY6ojH1eXBOnVryBW0r+TA6c=; b=fLO6CVB9PN2zEG5fmbw6zaHxtLLW+b+A47jabHQEDLGwGAO9b/VjzgpDfIn+kVvHgh rD1u0Djjm35zWiKb309v53QIAXNpsVSrvi6Lu6X8vWciWJKJ6xwEYp9InJK85ghgLyev M0Yr117sM5Qo9fV4e7jC5c3NaphDdb3gosVPgSSs+HtiGHDrK7ufYw2QCP0A60jKEVm8 /WIKK7fPqnria5XAyk0cZfKLaMsSqplqLCsOStqKtJz2/wDhtwhz5cShu7xjVDOryZTV SGQOeuR1EY5OqUI6oX/cILLIZmHjwHWBTD8lU1Ywa1pFCBX+ZikDbif0XsVtX0wrF8nI 1IeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KZfjmxMj; 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 jc17-20020a17090325d100b001b04dd66179si2332691plb.274.2023.06.09.00.55.47; Fri, 09 Jun 2023 00:56:00 -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=KZfjmxMj; 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 S239170AbjFIHtS (ORCPT + 99 others); Fri, 9 Jun 2023 03:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239120AbjFIHrq (ORCPT ); Fri, 9 Jun 2023 03:47:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D27B4210C; Fri, 9 Jun 2023 00:47:43 -0700 (PDT) Date: Fri, 09 Jun 2023 07:47:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686296861; 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=vlHTX3+aA/2+zboelFSuY6ojH1eXBOnVryBW0r+TA6c=; b=KZfjmxMj+Bu5VvTgaiuO45PgX/o77sVetHbu/o/1Wyi5pYgKHXA7pOKr8beiIKgwbvb3vF RM1Uq6oWNvajhT4Wwe73+SsC5YxCZwsFtiWug2iFXdIcnoSJ/pQvB/4NsPZ73GVrK04zfs Q+84uYKlf1J6zFsN//WHErt8tNeplPXvXfVRPgejkmcyNtOHtD/4H+DvPAOk1cuglNj1nk xewD1rooI8hOXt/3OzFtdW00AOj8islzqGk9k21s+BwykK9DlLXnDeELACRPZAaQNhxAh6 eV89FEpKMT6YXqpdS9Ao+UshrkyixH8v349xzBbJ9JFvPjit2cWGpsyU4DTPzA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686296861; 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=vlHTX3+aA/2+zboelFSuY6ojH1eXBOnVryBW0r+TA6c=; b=twi8vI3HA/cHgiW+9/AXXPwcY2ciX/PorlU2qCUULLyoOqpKMuokQgDiTbFmYJxTJnwZVd kv673jHbwsPc7iDA== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Allow stack operations in UNWIND_HINT_UNDEFINED regions Cc: Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <820c5b433f17c84e8761fb7465a8d319d706b1cf.1685981486.git.jpoimboe@kernel.org> References: <820c5b433f17c84e8761fb7465a8d319d706b1cf.1685981486.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <168629686051.404.16012940122573453456.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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1767881334807929224?= X-GMAIL-MSGID: =?utf-8?q?1768210941429580372?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: 1e4b619185e83e54aca617cf5070c64a88fe936b Gitweb: https://git.kernel.org/tip/1e4b619185e83e54aca617cf5070c64a88fe936b Author: Josh Poimboeuf AuthorDate: Mon, 05 Jun 2023 09:12:21 -07:00 Committer: Josh Poimboeuf CommitterDate: Wed, 07 Jun 2023 10:03:11 -07:00 objtool: Allow stack operations in UNWIND_HINT_UNDEFINED regions If the code specified UNWIND_HINT_UNDEFINED, skip the "undefined stack state" warning due to a stack operation. Just ignore the stack op and continue to propagate the undefined state. Link: https://lore.kernel.org/r/820c5b433f17c84e8761fb7465a8d319d706b1cf.1685981486.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 12 ++++++++++++ tools/objtool/include/objtool/cfi.h | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4b869de..b11c25a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -33,6 +33,7 @@ static unsigned long nr_cfi, nr_cfi_reused, nr_cfi_cache; static struct cfi_init_state initial_func_cfi; static struct cfi_state init_cfi; static struct cfi_state func_cfi; +static struct cfi_state force_undefined_cfi; struct instruction *find_insn(struct objtool_file *file, struct section *sec, unsigned long offset) @@ -2240,6 +2241,11 @@ static int read_unwind_hints(struct objtool_file *file) insn->hint = true; + if (hint->type == UNWIND_HINT_TYPE_UNDEFINED) { + insn->cfi = &force_undefined_cfi; + continue; + } + if (hint->type == UNWIND_HINT_TYPE_SAVE) { insn->hint = false; insn->save = true; @@ -2793,6 +2799,10 @@ static int update_cfi_state(struct instruction *insn, struct cfi_reg *cfa = &cfi->cfa; struct cfi_reg *regs = cfi->regs; + /* ignore UNWIND_HINT_UNDEFINED regions */ + if (cfi->force_undefined) + return 0; + /* stack operations don't make sense with an undefined CFA */ if (cfa->base == CFI_UNDEFINED) { if (insn_func(insn)) { @@ -4607,6 +4617,8 @@ int check(struct objtool_file *file) init_cfi_state(&init_cfi); init_cfi_state(&func_cfi); set_func_state(&func_cfi); + init_cfi_state(&force_undefined_cfi); + force_undefined_cfi.force_undefined = true; if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) goto out; diff --git a/tools/objtool/include/objtool/cfi.h b/tools/objtool/include/objtool/cfi.h index b1258e7..c8a6bec 100644 --- a/tools/objtool/include/objtool/cfi.h +++ b/tools/objtool/include/objtool/cfi.h @@ -36,6 +36,7 @@ struct cfi_state { bool drap; bool signal; bool end; + bool force_undefined; }; #endif /* _OBJTOOL_CFI_H */