All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Thierry <jthierry@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: jpoimboe@redhat.com, peterz@infradead.org, raphael.gault@arm.com,
	Julien Thierry <jthierry@redhat.com>
Subject: [PATCH 03/10] objtool: check: Clean instruction state before each function validation
Date: Wed, 25 Mar 2020 08:41:56 +0000	[thread overview]
Message-ID: <20200325084203.17005-4-jthierry@redhat.com> (raw)
In-Reply-To: <20200325084203.17005-1-jthierry@redhat.com>

When a function fails its validation, it might leave a stale state
that will be used for the validation of other functions. That would
cause false warnings on potentially valid functions.

Reset the instruction state before the validation of each individual
function.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
---
 tools/objtool/check.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 44a3abbb0b0b..0ccf6882d8ce 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2406,13 +2406,6 @@ static int validate_functions(struct objtool_file *file)
 	struct insn_state state;
 	int ret, warnings = 0;
 
-	clear_insn_state(&state);
-
-	state.cfa = initial_func_cfi.cfa;
-	memcpy(&state.regs, &initial_func_cfi.regs,
-	       CFI_NUM_REGS * sizeof(struct cfi_reg));
-	state.stack_size = initial_func_cfi.cfa.offset;
-
 	for_each_sec(file, sec) {
 		list_for_each_entry(func, &sec->symbol_list, list) {
 			if (func->type != STT_FUNC)
@@ -2431,6 +2424,12 @@ static int validate_functions(struct objtool_file *file)
 			if (!insn || insn->ignore || insn->visited)
 				continue;
 
+			clear_insn_state(&state);
+			state.cfa = initial_func_cfi.cfa;
+			memcpy(&state.regs, &initial_func_cfi.regs,
+			       CFI_NUM_REGS * sizeof(struct cfi_reg));
+			state.stack_size = initial_func_cfi.cfa.offset;
+
 			state.uaccess = func->uaccess_safe;
 
 			ret = validate_branch(file, func, insn, state);
-- 
2.21.1


  parent reply	other threads:[~2020-03-25  8:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  8:41 [PATCH 00/10] Objtool updates for easier portability Julien Thierry
2020-03-25  8:41 ` [PATCH 01/10] objtool: Move header sync-check ealier in build Julien Thierry
2020-03-25  8:41 ` [PATCH 02/10] objtool: check: Remove redundant checks on operand type Julien Thierry
2020-03-25  8:41 ` Julien Thierry [this message]
2020-03-25  8:41 ` [PATCH 04/10] objtool: check: Ignore empty alternative groups Julien Thierry
2020-03-25  8:41 ` [PATCH 05/10] objtool: check: Remove check preventing branches within alternative Julien Thierry
2020-03-25  8:41 ` [PATCH 06/10] objtool: check: Use arch specific values in restore_reg() Julien Thierry
2020-03-25  8:42 ` [PATCH 07/10] objtool: check: Allow save/restore hint in non standard function symbols Julien Thierry
2020-03-25  8:42 ` [PATCH 08/10] objtool: Add abstraction for computation of symbols offsets Julien Thierry
2020-03-25  8:42 ` [PATCH 09/10] objtool: Split generic and arch specific CFI definitions Julien Thierry
2020-03-25  8:42 ` [PATCH 10/10] objtool: Support multiple stack_op per instruction Julien Thierry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325084203.17005-4-jthierry@redhat.com \
    --to=jthierry@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=raphael.gault@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.