Commit 1f6ab566 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Andrew Morton

printk: export console trace point for kcsan/kasan/kfence/kmsan

The console tracepoint is used by kcsan/kasan/kfence/kmsan test modules. 
Since this tracepoint is not exported, these modules iterate over all
available tracepoints to find the console trace point.  Export the trace
point so that it can be directly used.

Link: https://lkml.kernel.org/r/20230413100859.1492323-1-quic_pkondeti@quicinc.comSigned-off-by: default avatarPavankumar Kondeti <quic_pkondeti@quicinc.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Marco Elver <elver@google.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c7b23b68
...@@ -1572,34 +1572,26 @@ static void test_exit(struct kunit *test) ...@@ -1572,34 +1572,26 @@ static void test_exit(struct kunit *test)
} }
__no_kcsan __no_kcsan
static void register_tracepoints(struct tracepoint *tp, void *ignore) static void register_tracepoints(void)
{ {
check_trace_callback_type_console(probe_console); register_trace_console(probe_console, NULL);
if (!strcmp(tp->name, "console"))
WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
} }
__no_kcsan __no_kcsan
static void unregister_tracepoints(struct tracepoint *tp, void *ignore) static void unregister_tracepoints(void)
{ {
if (!strcmp(tp->name, "console")) unregister_trace_console(probe_console, NULL);
tracepoint_probe_unregister(tp, probe_console, NULL);
} }
static int kcsan_suite_init(struct kunit_suite *suite) static int kcsan_suite_init(struct kunit_suite *suite)
{ {
/* register_tracepoints();
* Because we want to be able to build the test as a module, we need to
* iterate through all known tracepoints, since the static registration
* won't work here.
*/
for_each_kernel_tracepoint(register_tracepoints, NULL);
return 0; return 0;
} }
static void kcsan_suite_exit(struct kunit_suite *suite) static void kcsan_suite_exit(struct kunit_suite *suite)
{ {
for_each_kernel_tracepoint(unregister_tracepoints, NULL); unregister_tracepoints();
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
} }
......
...@@ -71,6 +71,8 @@ EXPORT_SYMBOL_GPL(console_printk); ...@@ -71,6 +71,8 @@ EXPORT_SYMBOL_GPL(console_printk);
atomic_t ignore_console_lock_warning __read_mostly = ATOMIC_INIT(0); atomic_t ignore_console_lock_warning __read_mostly = ATOMIC_INIT(0);
EXPORT_SYMBOL(ignore_console_lock_warning); EXPORT_SYMBOL(ignore_console_lock_warning);
EXPORT_TRACEPOINT_SYMBOL_GPL(console);
/* /*
* Low level drivers may need that to know if they can schedule in * Low level drivers may need that to know if they can schedule in
* their unblank() callback or not. So let's export it. * their unblank() callback or not. So let's export it.
......
...@@ -56,19 +56,6 @@ static void probe_console(void *ignore, const char *buf, size_t len) ...@@ -56,19 +56,6 @@ static void probe_console(void *ignore, const char *buf, size_t len)
WRITE_ONCE(test_status.async_fault, true); WRITE_ONCE(test_status.async_fault, true);
} }
static void register_tracepoints(struct tracepoint *tp, void *ignore)
{
check_trace_callback_type_console(probe_console);
if (!strcmp(tp->name, "console"))
WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
}
static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
{
if (!strcmp(tp->name, "console"))
tracepoint_probe_unregister(tp, probe_console, NULL);
}
static int kasan_suite_init(struct kunit_suite *suite) static int kasan_suite_init(struct kunit_suite *suite)
{ {
if (!kasan_enabled()) { if (!kasan_enabled()) {
...@@ -86,12 +73,7 @@ static int kasan_suite_init(struct kunit_suite *suite) ...@@ -86,12 +73,7 @@ static int kasan_suite_init(struct kunit_suite *suite)
*/ */
multishot = kasan_save_enable_multi_shot(); multishot = kasan_save_enable_multi_shot();
/* register_trace_console(probe_console, NULL);
* Because we want to be able to build the test as a module, we need to
* iterate through all known tracepoints, since the static registration
* won't work here.
*/
for_each_kernel_tracepoint(register_tracepoints, NULL);
return 0; return 0;
} }
...@@ -99,7 +81,7 @@ static void kasan_suite_exit(struct kunit_suite *suite) ...@@ -99,7 +81,7 @@ static void kasan_suite_exit(struct kunit_suite *suite)
{ {
kasan_kunit_test_suite_end(); kasan_kunit_test_suite_end();
kasan_restore_multi_shot(multishot); kasan_restore_multi_shot(multishot);
for_each_kernel_tracepoint(unregister_tracepoints, NULL); unregister_trace_console(probe_console, NULL);
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
} }
......
...@@ -825,33 +825,15 @@ static void test_exit(struct kunit *test) ...@@ -825,33 +825,15 @@ static void test_exit(struct kunit *test)
test_cache_destroy(); test_cache_destroy();
} }
static void register_tracepoints(struct tracepoint *tp, void *ignore)
{
check_trace_callback_type_console(probe_console);
if (!strcmp(tp->name, "console"))
WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
}
static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
{
if (!strcmp(tp->name, "console"))
tracepoint_probe_unregister(tp, probe_console, NULL);
}
static int kfence_suite_init(struct kunit_suite *suite) static int kfence_suite_init(struct kunit_suite *suite)
{ {
/* register_trace_console(probe_console, NULL);
* Because we want to be able to build the test as a module, we need to
* iterate through all known tracepoints, since the static registration
* won't work here.
*/
for_each_kernel_tracepoint(register_tracepoints, NULL);
return 0; return 0;
} }
static void kfence_suite_exit(struct kunit_suite *suite) static void kfence_suite_exit(struct kunit_suite *suite)
{ {
for_each_kernel_tracepoint(unregister_tracepoints, NULL); unregister_trace_console(probe_console, NULL);
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
} }
......
...@@ -626,33 +626,15 @@ static void test_exit(struct kunit *test) ...@@ -626,33 +626,15 @@ static void test_exit(struct kunit *test)
{ {
} }
static void register_tracepoints(struct tracepoint *tp, void *ignore)
{
check_trace_callback_type_console(probe_console);
if (!strcmp(tp->name, "console"))
WARN_ON(tracepoint_probe_register(tp, probe_console, NULL));
}
static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
{
if (!strcmp(tp->name, "console"))
tracepoint_probe_unregister(tp, probe_console, NULL);
}
static int kmsan_suite_init(struct kunit_suite *suite) static int kmsan_suite_init(struct kunit_suite *suite)
{ {
/* register_trace_console(probe_console, NULL);
* Because we want to be able to build the test as a module, we need to
* iterate through all known tracepoints, since the static registration
* won't work here.
*/
for_each_kernel_tracepoint(register_tracepoints, NULL);
return 0; return 0;
} }
static void kmsan_suite_exit(struct kunit_suite *suite) static void kmsan_suite_exit(struct kunit_suite *suite)
{ {
for_each_kernel_tracepoint(unregister_tracepoints, NULL); unregister_trace_console(probe_console, NULL);
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment