lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230815103509.309443-1-nik.borisov@suse.com>
Date:   Tue, 15 Aug 2023 13:35:09 +0300
From:   Nikolay Borisov <nik.borisov@...e.com>
To:     Josh Poimboeuf <jpoimboe@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        linux-kernel@...r.kernel.org
Cc:     Nikolay Borisov <nik.borisov@...e.com>
Subject: [PATCH] objtool: Cache number of return sites recorded

On an allyesconfig currently the kernels emits 454324. No point in
making around half a million iterations just to count them. Simply
increment a counter at the time of creation of each site.

Quick measurements shows a meager 200ms improvement when running
    objtool --rethunk --prefix=64 --no-unreachable --stats   --link

Signed-off-by: Nikolay Borisov <nik.borisov@...e.com>
---
 tools/objtool/check.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 8936a05f0e5a..bb71c5d8859f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -33,6 +33,7 @@ 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;
+static unsigned long nr_rethunk_sites;
 
 struct instruction *find_insn(struct objtool_file *file,
 			      struct section *sec, unsigned long offset)
@@ -802,15 +803,12 @@ static int create_return_sites_sections(struct objtool_file *file)
 		return 0;
 	}
 
-	idx = 0;
-	list_for_each_entry(insn, &file->return_thunk_list, call_node)
-		idx++;
-
-	if (!idx)
+	if (!nr_rethunk_sites)
 		return 0;
 
 	sec = elf_create_section_pair(file->elf, ".return_sites",
-				      sizeof(int), idx, idx);
+				      sizeof(int), nr_rethunk_sites,
+				      nr_rethunk_sites);
 	if (!sec)
 		return -1;
 
@@ -1473,8 +1471,10 @@ static void add_return_call(struct objtool_file *file, struct instruction *insn,
 	insn->type = INSN_RETURN;
 	insn->retpoline_safe = true;
 
-	if (add)
+	if (add) {
 		list_add_tail(&insn->call_node, &file->return_thunk_list);
+		nr_rethunk_sites++;
+	}
 }
 
 static bool is_first_func_insn(struct objtool_file *file,
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ