Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include "tests.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include "perf-hooks.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) static void sigsegv_handler(int sig __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	pr_debug("SIGSEGV is observed as expected, try to recover.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	perf_hooks__recover();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	signal(SIGSEGV, SIG_DFL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	raise(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	exit(-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static void the_hook(void *_hook_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	int *hook_flags = _hook_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	*hook_flags = 1234;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	/* Generate a segfault, test perf_hooks__recover */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	raise(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	int hook_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	signal(SIGSEGV, sigsegv_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	perf_hooks__set_hook("test", the_hook, &hook_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	perf_hooks__invoke_test();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	/* hook is triggered? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	if (hook_flags != 1234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		pr_debug("Setting failed: %d (%p)\n", hook_flags, &hook_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		return TEST_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	/* the buggy hook is removed? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	if (perf_hooks__get_hook("test"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		return TEST_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	return TEST_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }