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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240110104854.292752-1-songshuaishuai@tinylab.org>
Date: Wed, 10 Jan 2024 18:48:54 +0800
From: Song Shuai <songshuaishuai@...ylab.org>
To: peterz@...radead.org,
	jpoimboe@...nel.org,
	jbaron@...mai.com,
	rostedt@...dmis.org,
	ardb@...nel.org,
	songshuaishuai@...ylab.org
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] static_call: make selftest available for out-of-line SC

Static call selftest should be built once HAVE_STATIC_CALL is configured.
but it's now bonded with HAVE_STATIC_CALL_INLINE.

Move selftest to static_call.c making it available for out-of-line SC.

Signed-off-by: Song Shuai <songshuaishuai@...ylab.org>
---
 kernel/static_call.c        | 44 +++++++++++++++++++++++++++++++++++++
 kernel/static_call_inline.c | 42 -----------------------------------
 2 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/kernel/static_call.c b/kernel/static_call.c
index e9c3e69f3837..b1e1b4573201 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -1,8 +1,52 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/static_call.h>
+#include <linux/init.h>
 
 long __static_call_return0(void)
 {
 	return 0;
 }
 EXPORT_SYMBOL_GPL(__static_call_return0);
+
+#ifdef CONFIG_STATIC_CALL_SELFTEST
+
+static int func_a(int x)
+{
+	return x+1;
+}
+
+static int func_b(int x)
+{
+	return x+2;
+}
+
+DEFINE_STATIC_CALL(sc_selftest, func_a);
+
+static struct static_call_data {
+      int (*func)(int);
+      int val;
+      int expect;
+} static_call_data [] __initdata = {
+      { NULL,   2, 3 },
+      { func_b, 2, 4 },
+      { func_a, 2, 3 }
+};
+
+static int __init test_static_call_init(void)
+{
+      int i;
+
+      for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) {
+	      struct static_call_data *scd = &static_call_data[i];
+
+              if (scd->func)
+                      static_call_update(sc_selftest, scd->func);
+
+              WARN_ON(static_call(sc_selftest)(scd->val) != scd->expect);
+      }
+
+      return 0;
+}
+early_initcall(test_static_call_init);
+
+#endif /* CONFIG_STATIC_CALL_SELFTEST */
diff --git a/kernel/static_call_inline.c b/kernel/static_call_inline.c
index 639397b5491c..3e65bfafe559 100644
--- a/kernel/static_call_inline.c
+++ b/kernel/static_call_inline.c
@@ -512,45 +512,3 @@ int __init static_call_init(void)
 }
 early_initcall(static_call_init);
 
-#ifdef CONFIG_STATIC_CALL_SELFTEST
-
-static int func_a(int x)
-{
-	return x+1;
-}
-
-static int func_b(int x)
-{
-	return x+2;
-}
-
-DEFINE_STATIC_CALL(sc_selftest, func_a);
-
-static struct static_call_data {
-      int (*func)(int);
-      int val;
-      int expect;
-} static_call_data [] __initdata = {
-      { NULL,   2, 3 },
-      { func_b, 2, 4 },
-      { func_a, 2, 3 }
-};
-
-static int __init test_static_call_init(void)
-{
-      int i;
-
-      for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) {
-	      struct static_call_data *scd = &static_call_data[i];
-
-              if (scd->func)
-                      static_call_update(sc_selftest, scd->func);
-
-              WARN_ON(static_call(sc_selftest)(scd->val) != scd->expect);
-      }
-
-      return 0;
-}
-early_initcall(test_static_call_init);
-
-#endif /* CONFIG_STATIC_CALL_SELFTEST */
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ