Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp851720ybb; Wed, 25 Mar 2020 10:50:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuB8SGGL0U2lCqzbBSieirbbTHg35CFdk2ztOWRSfERKPAoO8ah4qK0HpYWI5ABVdwaKbRl X-Received: by 2002:aca:d489:: with SMTP id l131mr3413132oig.5.1585158609658; Wed, 25 Mar 2020 10:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585158609; cv=none; d=google.com; s=arc-20160816; b=LXm2yLIHXPpJeBvUAGjKu8g6yxOsscoA+JVqSD5BD23LGdrLwUQ/n3qwSj0wAJFCz8 Zq6RKkEB/0930xjbu7WH0pMFXf4UtVyrJ9wM9smEffWo3Xr7tDKiGw14yMUf5bmIKTkN Obh4AsOtCRmylHZq3Kl0Xl08uzKPbl/n7GVQ4B5CjcJaPxgfW/CXyYi+1ohKE/fUMQce 6L+PPcrdaNOV1ZKCgMr40DzKWrr7TPQMUyHqDWhSRNQoqKhitMj9qXKgTPFmQ8LVFO9d cO3P16eQyF3wbUmWa4DMSXj+1VstmA2ELdFg9MIoM2a4Ecx9Bd2RNOy4sF6bRSVA6MUV QG2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=Kqw2eANcr/NXrVf+g4UsmSnBMu4St2jvCKmskXKN8nA=; b=NXJxPPUx2sP3iUFZiyp/a2R18d8Fjfn29a6HViCBryQffJ/fOQSA5RqwAXtlFCmC5O uNpJo7MrwbDPIYVJQpQ8Tk077jZPvSf03+NE0f55CBuPDMF5TnNwv/QTwm5Iff3Q88sL Bdv80sc/pbU+10gL8G3vKp40EQIo+02nqpF+LAu/Y0I6FT8wA0UvOA/GsFNapfxxSyEx 4tXJWZ5qOZfYaErAeAZRgKaP0oOI7RhgZlDv119diAY/IoLQ+RUYdET2ZHLzpRgIPVeB RZKFBSFIsFjM6x9b2fG65OJe4IG+BjELquMMwjGzNdookQ8cUcqJq1VoXrSZT+8y564b 838g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ztoLJ0nu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i184si100550oia.14.2020.03.25.10.49.55; Wed, 25 Mar 2020 10:50:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=ztoLJ0nu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728173AbgCYRsP (ORCPT + 99 others); Wed, 25 Mar 2020 13:48:15 -0400 Received: from merlin.infradead.org ([205.233.59.134]:58434 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727903AbgCYRru (ORCPT ); Wed, 25 Mar 2020 13:47:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; 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=Kqw2eANcr/NXrVf+g4UsmSnBMu4St2jvCKmskXKN8nA=; b=ztoLJ0nu4vzJkgIPrzMaGq1UbT fv2ZM7z8HXKPVgze9SaZlUrnAvlcVSg0tj4WZFag4BFiS5rtZKKM17N2LZzOJAnz8NOTpmap/xC8P N08Wrl6HBzl4gF6mckSWHhmMjq2Zjl1Z/Xa4okCzX1nXroxdOZtzZVseC2WF8PZYoBKQH2RPKw10L jv/FmuygQu/D4U2v63YWfnRruIwCoo/TOrMcPTvYl/JIRB6ZkpGg0KMzgYASKNkhJmrL69aSV5Nyt N8TZnw87LWCVh/UKSHmGB13JaW9wAJE9XEb0PWuDFnV9yTYI4/Fyjv1oNJxcvaSQmqVyTTygM8F7f htSyrRAw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHA82-0003oi-Hw; Wed, 25 Mar 2020 17:47:46 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B32C43010CF; Wed, 25 Mar 2020 18:47:42 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id A2E92286C1385; Wed, 25 Mar 2020 18:47:42 +0100 (CET) Message-Id: <20200325174605.369570202@infradead.org> User-Agent: quilt/0.65 Date: Wed, 25 Mar 2020 18:45:26 +0100 From: Peter Zijlstra To: tglx@linutronix.de, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, peterz@infradead.org, mhiramat@kernel.org, mbenes@suse.cz Subject: [PATCH v4 01/13] objtool: Remove CFI save/restore special case References: <20200325174525.772641599@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a special case in the UNWIND_HINT_RESTORE code. When, upon looking for the UNWIND_HINT_SAVE instruction to restore from, it finds the instruction hasn't been visited yet, it normally issues a WARN, except when this HINT_SAVE instruction is the first instruction of this branch. This special case is of dubious correctness and is certainly unused (verified with an allmodconfig build), the two sites that employ UNWIND_HINT_SAVE/RESTORE (sync_core() and ftrace_regs_caller()) have the SAVE on unconditional instructions at the start of the function. It is therefore impossible for the save_insn not to have been visited when we do hit the RESTORE. Remove this. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf --- tools/objtool/check.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2040,15 +2040,14 @@ static int validate_return(struct symbol * tools/objtool/Documentation/stack-validation.txt. */ static int validate_branch(struct objtool_file *file, struct symbol *func, - struct instruction *first, struct insn_state state) + struct instruction *insn, struct insn_state state) { + struct instruction *next_insn; struct alternative *alt; - struct instruction *insn, *next_insn; struct section *sec; u8 visited; int ret; - insn = first; sec = insn->sec; if (insn->alt_group && list_empty(&insn->alts)) { @@ -2101,16 +2100,6 @@ static int validate_branch(struct objtoo } if (!save_insn->visited) { - /* - * Oops, no state to copy yet. - * Hopefully we can reach this - * instruction from another branch - * after the save insn has been - * visited. - */ - if (insn == first) - return 0; - WARN_FUNC("objtool isn't smart enough to handle this CFI save/restore combo", sec, insn->offset); return 1;