From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796170580; b=ucNtHSgnmDztsDOwflFIviX8Ho9h+97hPFnBt7L8dFfsFN3aN0doVAznvLbbi/YX5Iz6 BXbh7uJRdVjllZMlbr69WJxPKY+23BseNXVbKMt8NG9+wK9QkI3a7r0/hSsz3ovUBhb5z Q9NUQWSiH8l4lBfmFyjMJsF2fLS8za14sHQRqhianAoVQ2ouFCEnQB4P3Q3cUpWoihLMF G4EUemXEj+lM7G7E1Wlr2R9DGUpMaj0ChCq+ldOKvgMyTZPh1UAzr1eFSdnT4KqubHgHT C9L6PghVrH71Zmm1tEY7JoY4jVfFf25+3H+6hisWhbAz3ViRAUNrv13DuAHt7WGvYDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796170580; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=FfeoRE2WgfMFZianO/2oCrm91wE8bE3mESPBwA19XOk=; b=mQT83i6oYctLtUHM94jJG1KWvoWk8sN+V9caG5g2DCSC0UEC6GcXXJEHF3dRfEakE2xU WdcCZUWsrQr7wMcsTcf5V3gcJQequy3vtt3B1nogF9MqK4uVAO9yEjR6ejz6PYo3lW8z3 TxBJh1LhEnFikaxfRT2lXer1F9GBaPXZfYj2WrqMzfFwnisUErxf0NnnuJZ+mWKZHfFvl CWW443HLYfCEXFJUmfq68nU4f4cFXy6t3DBXQ6svMg/Op1NOGu9iq8Nda+phGH5J9fK1r h9ltKh/ncHDWO3iJChQemorqQZFBiN1SVuOMsvjeFvxmjWscyIMtOsSjhXfWzUwD29w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=mcNygOcM; arc=none smtp.remote-ip=209.85.161.69 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E68B606A320 for ; Wed, 2 Dec 2026 00:16:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5E68B606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=mcNygOcM Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-704a881f959so10449585eaf.2 for ; Tue, 01 Dec 2026 16:16:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796170578; x=1796775378; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FfeoRE2WgfMFZianO/2oCrm91wE8bE3mESPBwA19XOk=; b=mcNygOcMy38emhcptPeBaOwhNiYP1cqiXeCArazidxl+NZeRQzy5IHRMZ74xf4ccfn RSchR9ZlHUIz3Z04pJQGTMHCjS0k+NUBGunWX7GZSy1+VKUmWGG1OyxzuRbrxIP8Gt07 Ge889MG5GQLTUPgHsPdbIxeddTFv87YbEHpzKNFyc18jCngh0GbbTmTpDnuNmg1di15t QuGodYzLp2q1cyL3XbH3qyxAln1mVYojZCzhiFznJ3VCJm08VlsAcZOgDFoPuAhWPsHd o/5OqEufn+A8JrG1kL31JqKHVhIilZ1xjwWW45IlDviO+ECHyO0KUXg2HR9gttjvV3AB mktA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796170578; x=1796775378; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FfeoRE2WgfMFZianO/2oCrm91wE8bE3mESPBwA19XOk=; b=VUvNWLcAQWQFzQ/23xNChjfu592vcKEeIOrtKJmIkN3lnnikv/JRP3MBIgXNsRKf0+ oUFG6GJulb5YwOifqwpYDu1k5fWhQ6rJgCqi2xYuHZYhGSgnJVQ0YRKtxpy4JzVU3hzo 3NlQT6rR3tIs7Lg24QHAQnPL9Ti4GvzQpo9WnhHodhmAXlfmSvhOcKIqulKLQyoh/HFy doGffkBojZ2G8uUVS9iWA4vkt6dZ95AC/sSITBKgHcye240JfNmkb73Mdk4N469mw585 Trn4ybnaCuA1rxZ5Ij91IvDA3xbriAn1iBoQwLQ9E+LiL7zbrBPZ8hDGnoxwp6fzviZc Xxhg== X-Forwarded-Encrypted: i=1; AL+hErG/uf/amPxH4GYwG1yh104V/JvtD9rBqFAtfzaSgiwzqXpS+tmRKRsHoxJqS44T05kczVWBXbdBZ1ohZCA=@vger.kernel.org X-Gm-Message-State: APuU4Z+spUMNsnHJo6OqLT3oIHFymRmYxJ/UjMcM5SHEMT5DPpM5epKn STum7VWcAjeQQLwl+22vFSL/38sIZHCc+De2zP1nVg6RoTkLlEJDUjI+qaxI761/GG9i4acTfIU 3agE38+Ag92U1dg== X-Received: from oakt7-n1.prod.google.com ([2002:a05:687c:41c7:10b0:494:50e2:71dd]) (user=wusamuel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:c319:b0:71a:fce5:c67b with SMTP id 006d021491bc7-71b394959b1mr25521883eaf.45.1796170578095; Tue, 01 Dec 2026 16:16:18 -0800 (PST) Date: Tue, 1 Dec 2026 16:13:51 -0800 In-Reply-To: <20261202001344.2721429-12-wusamuel@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202001344.2721429-12-wusamuel@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202001344.2721429-22-wusamuel@google.com> Subject: [PATCH bpf-next v4 10/10] selftests/bpf: Test typeless module ksym resolution From: Samuel Wu To: Jonathan Corbet , Shuah Khan , Randy Dunlap , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Alexander Viro , Christian Brauner , Jan Kara , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: david.laight.linux@gmail.com, akpm@linux-foundation.org, pmladek@suse.com, Samuel Wu , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, bpf@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" The module ksym tests use typed ksyms, which libbpf resolves through BTF. Add a weak typeless module ksym to the ksyms test, to cover the module path of KALLSYMS_QUERY_BY_NAME. Signed-off-by: Samuel Wu --- tools/testing/selftests/bpf/prog_tests/ksyms.c | 9 +++++++++ tools/testing/selftests/bpf/progs/test_ksyms.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms.c b/tools/testing/selftests/bpf/prog_tests/ksyms.c index dc7aab532fb1..801d38560473 100644 --- a/tools/testing/selftests/bpf/prog_tests/ksyms.c +++ b/tools/testing/selftests/bpf/prog_tests/ksyms.c @@ -11,6 +11,7 @@ void test_ksyms(void) struct test_ksyms *skel; struct test_ksyms__data *data; __u64 link_fops_addr, per_cpu_start_addr; + __u64 testmod_ksym_addr = 0; struct stat st; __u64 btf_size; int err; @@ -27,6 +28,12 @@ void test_ksyms(void) if (!ASSERT_NEQ(err, -ENOENT, "__per_cpu_start: ksym_find")) return; + if (env.has_testmod && + !ASSERT_OK(kallsyms_find("bpf_testmod_ksym_percpu", + &testmod_ksym_addr), + "bpf_testmod_ksym_percpu: kallsyms_find")) + return; + if (!ASSERT_OK(stat(btf_path, &st), "stat_btf")) return; btf_size = st.st_size; @@ -47,6 +54,8 @@ void test_ksyms(void) ASSERT_EQ(data->out__bpf_link_fops1, 0, "bpf_link_fops1"); ASSERT_EQ(data->out__btf_size, btf_size, "btf_size"); ASSERT_EQ(data->out__per_cpu_start, per_cpu_start_addr, "__per_cpu_start"); + ASSERT_EQ(data->out__bpf_testmod_ksym_percpu, testmod_ksym_addr, + "bpf_testmod_ksym_percpu"); cleanup: test_ksyms__destroy(skel); diff --git a/tools/testing/selftests/bpf/progs/test_ksyms.c b/tools/testing/selftests/bpf/progs/test_ksyms.c index 6c9cbb5a3bdf..0506bb574c4a 100644 --- a/tools/testing/selftests/bpf/progs/test_ksyms.c +++ b/tools/testing/selftests/bpf/progs/test_ksyms.c @@ -9,6 +9,7 @@ __u64 out__bpf_link_fops = -1; __u64 out__bpf_link_fops1 = -1; __u64 out__btf_size = -1; __u64 out__per_cpu_start = -1; +__u64 out__bpf_testmod_ksym_percpu = -1; extern const void bpf_link_fops __ksym; extern const void __start_BTF __ksym; @@ -16,6 +17,8 @@ extern const void __stop_BTF __ksym; extern const void __per_cpu_start __ksym; /* non-existing symbol, weak, default to zero */ extern const void bpf_link_fops1 __ksym __weak; +/* module symbol, weak, zero if bpf_testmod is not loaded */ +extern const void bpf_testmod_ksym_percpu __ksym __weak; SEC("raw_tp/sys_enter") int handler(const void *ctx) @@ -25,6 +28,7 @@ int handler(const void *ctx) out__per_cpu_start = (__u64)&__per_cpu_start; out__bpf_link_fops1 = (__u64)&bpf_link_fops1; + out__bpf_testmod_ksym_percpu = (__u64)&bpf_testmod_ksym_percpu; return 0; } -- 2.56.1.911.g883d8bcb20-goog