Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5854009rwd; Mon, 5 Jun 2023 09:22:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73LwuI0+mQyXXWbZSd9O8gvMNGiLKwrrMEgGkboC3qeFq2bPdkioOFHpBo0xXAG2IQ8BdD X-Received: by 2002:a17:903:1cf:b0:1ad:e2b6:d292 with SMTP id e15-20020a17090301cf00b001ade2b6d292mr9929014plh.4.1685982167024; Mon, 05 Jun 2023 09:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685982167; cv=none; d=google.com; s=arc-20160816; b=ntvPcg49U9dvKFbJNxyAkcCZryp6yDTF8nrO6+zfNlLVSzpGk5IQt4oLBxzsDZ05se Zwndl+mkNZ5WdFWk332Eyky01EouL01xnB8fI0FsJG+QW9qZ9vtZAmCwNiUYS1EL+zBQ 59t2RhDkozaE5sv+pcMgNwhNBoDX43TIdgW87xV6ef9AO/1/yQIMty3IyAkUMl+Lq7Vg NTuu9E4ALVUB6jHiUMo8UocxDAV2ekyouP7oVa3z0kFSjo5kEzAp+8SZfVW3wQ0qCcNb afX6UU271ol9hcEsDdwGXEX/D1kIslxdLh0G4tVSO2NpznwOj9TNqKABN3wtKx3j8ULh 23bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0Xz0jFabxOwGj3tju/EW2nEXpkermFnu9e9Ec199qZ0=; b=HjUit05zc8zmpgRk0dIclofG1gAacBaR+a0s6sxeIVUHxtAOCqXNJKLlkPiyt476w9 3PiiIOgCNH8bW4VW5G1KfcVgHzzT15/CZCJoeGXYnLu4YNAANqReBGFrfjyLtEQkAEMd F0dGuBlSoSM1eNGr5WZdiMBp9UR8FEl+ZJkFY832n017xvw/qb3qUbhf8qKjc66ApjLe 3efOkHOfRc5ADUnon9b2OlSBMFWfKRPfcsTkaJti5OJB8fpZrJsTL2sAyN6Hlj5Cy889 oBEaCPQ1mrbYwdY4gmk6mxsD43MkmiqVFT0pfGYO4PrSt+a7luZqYXe1yhpKWEJ0xpqY M6eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RpTmJiA3; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja19-20020a170902efd300b001b06fa86b0fsi5612373plb.272.2023.06.05.09.22.32; Mon, 05 Jun 2023 09:22:47 -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=@kernel.org header.s=k20201202 header.b=RpTmJiA3; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234559AbjFEQMg (ORCPT + 99 others); Mon, 5 Jun 2023 12:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbjFEQMc (ORCPT ); Mon, 5 Jun 2023 12:12:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A467FB7 for ; Mon, 5 Jun 2023 09:12:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 38D0F6209E for ; Mon, 5 Jun 2023 16:12:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 573E6C4339B; Mon, 5 Jun 2023 16:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685981550; bh=Y/CZjNZo+1qpj5wP4ui+d4BljXqVHm12WzlCqm4DwWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RpTmJiA3wvYc3nJFc3onPNTivqFIDK+4LergCSsq9dPrr2QukzMLRXUwmKxWyMx/H Kkn0zIevs/BE+n6arqBaKP/vrpzIbPzm6NJ9Fn3o4g111hZ+gJD47MzGI0V7lmqiBV L1VewThgnel9XuN25rqbCWprkFBl6SmPbrkVmqUB7df7eRty4T8vlbWjr3aBkVb2hF TLgyeBrq90lX1Gk892f1CWYrdgG10NVby5EkQ3K2g8dT+IkvTSO5DU2EuvWzXXjq+3 duqvTR/JO0GIIYbA3ko+Ms1+R+i18UT4kn3tTFKjnJolDLIhK0Bt/0qTPuMwKwcrNI qeMZLS20qxwPg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , linux-graphics-maintainer@vmware.com, Zack Rusin Subject: [PATCH v2 1/2] objtool: Allow stack operations in UNWIND_HINT_UNDEFINED regions Date: Mon, 5 Jun 2023 09:12:21 -0700 Message-Id: <820c5b433f17c84e8761fb7465a8d319d706b1cf.1685981486.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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. 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 4b869de7e827..b11c25a715ac 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 b1258e79a1b7..c8a6bec4f6b9 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 */ -- 2.40.1