Skip to contentSkip to conversation

selftests/bpf: Fix test_ksyms on non-SMP kernels

PATCH Applied Ilya Leoshkevich 3 participants 3 messages Sep 10, 2020 – Sep 11, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: Fix test_ksyms on non-SMP kernels

On non-SMP kernels __per_cpu_start is not 0, so look it up in kallsyms.

---
 tools/testing/selftests/bpf/prog_tests/ksyms.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/ksyms.c +4 -2
index e3d6777226a8..b771804b2342 100644
@@ -32,6 +32,7 @@ static __u64 kallsyms_find(const char *sym)
 
 void test_ksyms(void)
 {
+	__u64 per_cpu_start_addr = kallsyms_find("__per_cpu_start");
 	__u64 link_fops_addr = kallsyms_find("bpf_link_fops");
 	const char *btf_path = "/sys/kernel/btf/vmlinux";
 	struct test_ksyms *skel;
@@ -63,8 +64,9 @@ void test_ksyms(void)
 	      "got %llu, exp %llu\n", data->out__bpf_link_fops1, (__u64)0);
 	CHECK(data->out__btf_size != btf_size, "btf_size",
 	      "got %llu, exp %llu\n", data->out__btf_size, btf_size);
-	CHECK(data->out__per_cpu_start != 0, "__per_cpu_start",
-	      "got %llu, exp %llu\n", data->out__per_cpu_start, (__u64)0);
+	CHECK(data->out__per_cpu_start != per_cpu_start_addr, "__per_cpu_start",
+	      "got %llu, exp %llu\n", data->out__per_cpu_start,
+	      per_cpu_start_addr);
 
 cleanup:
 	test_ksyms__destroy(skel);
Signature · 1 line
2.25.4
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ilya Leoshkevich

On non-SMP kernels __per_cpu_start is not 0, so look it up in kallsyms.

---

Quoted 30 lines
 tools/testing/selftests/bpf/prog_tests/ksyms.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/ksyms.c +4 -3
index e3d6777226a8..b771804b2342 100644
@@ -32,6 +32,7 @@ static __u64 kallsyms_find(const char *sym)
 
 void test_ksyms(void)
 {
+       __u64 per_cpu_start_addr = kallsyms_find("__per_cpu_start");
        __u64 link_fops_addr = kallsyms_find("bpf_link_fops");
        const char *btf_path = "/sys/kernel/btf/vmlinux";
        struct test_ksyms *skel;
@@ -63,8 +64,9 @@ void test_ksyms(void)
              "got %llu, exp %llu\n", data->out__bpf_link_fops1, (__u64)0);
        CHECK(data->out__btf_size != btf_size, "btf_size",
              "got %llu, exp %llu\n", data->out__btf_size, btf_size);
-       CHECK(data->out__per_cpu_start != 0, "__per_cpu_start",
-             "got %llu, exp %llu\n", data->out__per_cpu_start, (__u64)0);
+       CHECK(data->out__per_cpu_start != per_cpu_start_addr, "__per_cpu_start",
+             "got %llu, exp %llu\n", data->out__per_cpu_start,
+             per_cpu_start_addr);
 
 cleanup:
        test_ksyms__destroy(skel);
--

2.25.4