117 lines
5.2 KiB
Diff
117 lines
5.2 KiB
Diff
commit b8d4274d1e7697801c12c512b6724dd3f59f2c72
|
|
Author: William Cohen <wcohen@redhat.com>
|
|
Date: Mon May 6 11:36:42 2024 -0400
|
|
|
|
Support kernels that backported kallsym functions from newer linux kernels
|
|
|
|
Some Linux distributions may have backported
|
|
module_kallsyms_on_each_symbol and kallsyms_on_each_symbol functions
|
|
from newer linux kernels. In these situations checking the kernel
|
|
version would not detect the proper arguments for these functions.
|
|
Systemtap now has a couple of autoconf tests to determine what
|
|
arguments should be used for these functions.
|
|
|
|
diff --git a/buildrun.cxx b/buildrun.cxx
|
|
index bb7bdcc9d..8ee8c391f 100644
|
|
--- a/buildrun.cxx
|
|
+++ b/buildrun.cxx
|
|
@@ -506,6 +506,8 @@ compile_pass (systemtap_session& s)
|
|
|
|
output_autoconf(s, o, cs, "autoconf-pagefault_disable.c", "STAPCONF_PAGEFAULT_DISABLE", NULL);
|
|
output_exportconf(s, o2, "kallsyms_lookup_name", "STAPCONF_KALLSYMS_LOOKUP_NAME_EXPORTED");
|
|
+ output_autoconf(s, o, cs, "autoconf-kallsyms_6_3.c", "STAPCONF_KALLSYMS_6_3", NULL);
|
|
+ output_autoconf(s, o, cs, "autoconf-kallsyms_6_4.c", "STAPCONF_KALLSYMS_6_4", NULL);
|
|
output_autoconf(s, o, cs, "autoconf-uidgid.c", "STAPCONF_LINUX_UIDGID_H", NULL);
|
|
output_exportconf(s, o2, "sigset_from_compat", "STAPCONF_SIGSET_FROM_COMPAT_EXPORTED");
|
|
output_exportconf(s, o2, "vzalloc", "STAPCONF_VZALLOC");
|
|
diff --git a/runtime/linux/autoconf-kallsyms_6_3.c b/runtime/linux/autoconf-kallsyms_6_3.c
|
|
new file mode 100644
|
|
index 000000000..0af1a5c35
|
|
--- /dev/null
|
|
+++ b/runtime/linux/autoconf-kallsyms_6_3.c
|
|
@@ -0,0 +1,6 @@
|
|
+#include <linux/module.h>
|
|
+
|
|
+int module_kallsyms_on_each_symbol(const char *modname,
|
|
+ int (*fn)(void *, const char *, struct module*,
|
|
+ unsigned long),
|
|
+ void *data);
|
|
diff --git a/runtime/linux/autoconf-kallsyms_6_4.c b/runtime/linux/autoconf-kallsyms_6_4.c
|
|
new file mode 100644
|
|
index 000000000..3b3680c53
|
|
--- /dev/null
|
|
+++ b/runtime/linux/autoconf-kallsyms_6_4.c
|
|
@@ -0,0 +1,3 @@
|
|
+#include <linux/kallsyms.h>
|
|
+int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long),
|
|
+ void *data);
|
|
diff --git a/runtime/linux/kprobes.c b/runtime/linux/kprobes.c
|
|
index 6b30f2c52..2fba61cbb 100644
|
|
--- a/runtime/linux/kprobes.c
|
|
+++ b/runtime/linux/kprobes.c
|
|
@@ -737,7 +737,7 @@ __stapkp_symbol_callback(void *data, const char *name,
|
|
}
|
|
|
|
static int
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_4)
|
|
stapkp_symbol_callback(void *data, const char *name,
|
|
unsigned long addr)
|
|
{
|
|
@@ -780,7 +780,7 @@ stapkp_init(struct stap_kprobe_probe *probes,
|
|
mutex_lock(&module_mutex);
|
|
#endif
|
|
kallsyms_on_each_symbol(stapkp_symbol_callback, &sd);
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_3) || defined(STAPCONF_KALLSYMS_6_4)
|
|
module_kallsyms_on_each_symbol(sd.modname, stapkp_symbol_callback, &sd);
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0)
|
|
module_kallsyms_on_each_symbol(stapkp_symbol_callback, &sd);
|
|
@@ -855,7 +855,7 @@ stapkp_refresh(const char *modname,
|
|
mutex_lock(&module_mutex);
|
|
#endif
|
|
kallsyms_on_each_symbol(stapkp_symbol_callback, &sd);
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_3)
|
|
module_kallsyms_on_each_symbol(sd.modname, stapkp_symbol_callback, &sd);
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0)
|
|
module_kallsyms_on_each_symbol(stapkp_symbol_callback, &sd);
|
|
diff --git a/runtime/sym.c b/runtime/sym.c
|
|
index 3947d42f7..23dd3be30 100644
|
|
--- a/runtime/sym.c
|
|
+++ b/runtime/sym.c
|
|
@@ -1187,7 +1187,7 @@ unsigned long kallsyms_lookup_name (const char *name)
|
|
typedef typeof(&kallsyms_on_each_symbol) kallsyms_on_each_symbol_fn;
|
|
|
|
// XXX Will be linked in place of the kernel's kallsyms_on_each_symbol:
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_4)
|
|
int kallsyms_on_each_symbol(int (*fn)(void *, const char *,
|
|
unsigned long),
|
|
void *data)
|
|
@@ -1214,13 +1214,13 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
|
|
typedef typeof(&module_kallsyms_on_each_symbol) module_kallsyms_on_each_symbol_fn;
|
|
|
|
// XXX Will be linked in place of the kernel's module_kallsyms_on_each_symbol:
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_4)
|
|
int module_kallsyms_on_each_symbol(const char *modname,
|
|
int (*fn)(void *, const char *,
|
|
unsigned long),
|
|
void *data)
|
|
#else
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_3)
|
|
int module_kallsyms_on_each_symbol(const char *modname,
|
|
int (*fn)(void *, const char *, struct module *,
|
|
unsigned long),
|
|
@@ -1235,7 +1235,7 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module
|
|
/* First, try to use a kallsyms_lookup_name address passed to us
|
|
through the relocation mechanism. */
|
|
if (_stp_module_kallsyms_on_each_symbol != NULL)
|
|
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0)
|
|
+#if defined(STAPCONF_KALLSYMS_6_3) || defined(STAPCONF_KALLSYMS_6_4)
|
|
return ibt_wrapper(int,
|
|
(* (module_kallsyms_on_each_symbol_fn)_stp_module_kallsyms_on_each_symbol)(modname, fn, data));
|
|
#else
|