linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: x86@kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, Miroslav Benes <mbenes@suse.cz>
Subject: [PATCH v2 16/25] objtool: Extricate sls from stack validation
Date: Mon, 18 Apr 2022 09:50:35 -0700	[thread overview]
Message-ID: <2545c86ffa5f27497f0d0c542540ad4a4be3c5a5.1650300597.git.jpoimboe@redhat.com> (raw)
In-Reply-To: <cover.1650300597.git.jpoimboe@redhat.com>

Extricate sls functionality from validate_branch() so they can be
executed (or ported) independently from each other.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/objtool/check.c | 56 +++++++++++++++++++++++++++++++++----------
 1 file changed, 43 insertions(+), 13 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0059b592195e..88b527b3eb37 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -3272,11 +3272,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
 		switch (insn->type) {
 
 		case INSN_RETURN:
-			if (opts.sls && !insn->retpoline_safe &&
-			    next_insn && next_insn->type != INSN_TRAP) {
-				WARN_FUNC("missing int3 after ret",
-					  insn->sec, insn->offset);
-			}
 			return validate_return(func, insn, &state);
 
 		case INSN_CALL:
@@ -3320,13 +3315,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
 			break;
 
 		case INSN_JUMP_DYNAMIC:
-			if (opts.sls && !insn->retpoline_safe &&
-			    next_insn && next_insn->type != INSN_TRAP) {
-				WARN_FUNC("missing int3 after indirect jump",
-					  insn->sec, insn->offset);
-			}
-
-			/* fallthrough */
 		case INSN_JUMP_DYNAMIC_CONDITIONAL:
 			if (is_sibling_call(insn)) {
 				ret = validate_sibling_call(file, insn, &state);
@@ -3846,6 +3834,41 @@ static int validate_ibt(struct objtool_file *file)
 	return warnings;
 }
 
+static int validate_sls(struct objtool_file *file)
+{
+	struct instruction *insn, *next_insn;
+	int warnings = 0;
+
+	for_each_insn(file, insn) {
+		next_insn = next_insn_same_sec(file, insn);
+
+		if (insn->retpoline_safe)
+			continue;
+
+		switch (insn->type) {
+		case INSN_RETURN:
+			if (!next_insn || next_insn->type != INSN_TRAP) {
+				WARN_FUNC("missing int3 after ret",
+					  insn->sec, insn->offset);
+				warnings++;
+			}
+
+			break;
+		case INSN_JUMP_DYNAMIC:
+			if (!next_insn || next_insn->type != INSN_TRAP) {
+				WARN_FUNC("missing int3 after indirect jump",
+					  insn->sec, insn->offset);
+				warnings++;
+			}
+			break;
+		default:
+			break;
+		}
+	}
+
+	return warnings;
+}
+
 static int validate_reachable_instructions(struct objtool_file *file)
 {
 	struct instruction *insn;
@@ -3914,7 +3937,7 @@ int check(struct objtool_file *file)
 		warnings += ret;
 	}
 
-	if (opts.stackval || opts.orc || opts.uaccess || opts.sls) {
+	if (opts.stackval || opts.orc || opts.uaccess) {
 		ret = validate_functions(file);
 		if (ret < 0)
 			goto out;
@@ -3940,6 +3963,13 @@ int check(struct objtool_file *file)
 		warnings += ret;
 	}
 
+	if (opts.sls) {
+		ret = validate_sls(file);
+		if (ret < 0)
+			goto out;
+		warnings += ret;
+	}
+
 	ret = create_static_call_sections(file);
 	if (ret < 0)
 		goto out;
-- 
2.34.1


  parent reply	other threads:[~2022-04-18 16:52 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18 16:50 [PATCH v2 00/25] objtool: Interface overhaul Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 01/25] objtool: Enable unreachable warnings for CLANG LTO Josh Poimboeuf
2022-04-19 20:08   ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 02/25] libsubcmd: Fix OPTION_GROUP sorting Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 03/25] x86/static_call: Add ANNOTATE_NOENDBR to static call trampoline Josh Poimboeuf
2022-04-19 20:08   ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 04/25] x86/retpoline: Add ANNOTATE_ENDBR for retpolines Josh Poimboeuf
2022-04-19 20:08   ` [tip: x86/urgent] x86/retpoline: Add ANNOTATE_NOENDBR " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 05/25] x86/uaccess: Add ENDBR to __put_user_nocheck*() Josh Poimboeuf
2022-04-19 20:08   ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 06/25] x86/xen: Add ANNOTATE_ENDBR to startup_xen() Josh Poimboeuf
2022-04-19 11:42   ` Andrew Cooper
2022-04-19 11:57     ` Peter Zijlstra
2022-04-19 12:06       ` Juergen Gross
2022-04-19 12:12       ` Andrew Cooper
2022-04-19 13:10         ` Peter Zijlstra
2022-04-19 14:25           ` Andrew Cooper
2022-04-19 20:08   ` [tip: x86/urgent] x86/xen: Add ANNOTATE_NOENDBR " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 07/25] objtool: Reorganize cmdline options Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 08/25] objtool: Ditch subcommands Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 09/25] objtool: Don't print parentheses in function addresses Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 10/25] objtool: Print data address for "!ENDBR" data warnings Josh Poimboeuf
2022-04-19 20:08   ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 11/25] objtool: Use offstr() to print address of missing ENDBR Josh Poimboeuf
2022-04-19 20:08   ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 12/25] objtool: Add option to print section addresses Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 13/25] scripts: Create objdump-func helper script Josh Poimboeuf
2022-04-19 11:15   ` Peter Zijlstra
2022-04-19 16:09     ` Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 14/25] objtool: Make stack validation optional Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 15/25] objtool: Rework ibt and extricate from stack validation Josh Poimboeuf
2022-04-20 17:25   ` Miroslav Benes
2022-04-22 10:50     ` Peter Zijlstra
2022-04-22 15:17       ` Josh Poimboeuf
2022-04-25  6:27       ` Miroslav Benes
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` Josh Poimboeuf [this message]
2022-04-22 10:35   ` [tip: objtool/core] objtool: Extricate sls " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 17/25] objtool: Add CONFIG_OBJTOOL Josh Poimboeuf
2022-04-19 11:22   ` Peter Zijlstra
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 18/25] objtool: Make stack validation frame-pointer-specific Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 19/25] objtool: Make static call annotation optional Josh Poimboeuf
2022-04-22 10:35   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 20/25] objtool: Make jump label hack optional Josh Poimboeuf
2022-04-22 10:34   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 21/25] objtool: Make noinstr hacks optional Josh Poimboeuf
2022-04-22 10:34   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 22/25] objtool: Rename "VMLINUX_VALIDATION" -> "NOINSTR_VALIDATION" Josh Poimboeuf
2022-04-22 10:34   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 23/25] objtool: Add HAVE_NOINSTR_VALIDATION Josh Poimboeuf
2022-04-22 10:34   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 24/25] objtool: Remove --lto and --vmlinux in favor of --link Josh Poimboeuf
2022-04-20 17:25   ` Miroslav Benes
2022-04-22 10:34   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-18 16:50 ` [PATCH v2 25/25] objtool: Update documentation Josh Poimboeuf
2022-04-22 10:34   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2022-04-19 11:51 ` [PATCH v2 00/25] objtool: Interface overhaul Peter Zijlstra
2022-04-19 15:36   ` Josh Poimboeuf
2022-04-19 16:43     ` Peter Zijlstra
2022-04-20 17:27 ` Miroslav Benes

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=2545c86ffa5f27497f0d0c542540ad4a4be3c5a5.1650300597.git.jpoimboe@redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).