Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp762277ybh; Wed, 15 Jul 2020 14:44:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2ipkNXQ+7V/5FcwQkWsrj5fzVZz0ZuhwRoUw1/CCKgxEpCb8UEsgeVU0ts60WOzLNSmfi X-Received: by 2002:a17:906:4a45:: with SMTP id a5mr900302ejv.384.1594849467376; Wed, 15 Jul 2020 14:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594849467; cv=none; d=google.com; s=arc-20160816; b=HULEAVn9jtDC+6nA/3eukEVyBDrDXs2NvRPgFUhvv0F3XqJIBD+DOcI37228eC9sbl SxDRIPGP6sMDOlhreAiY2Cgg/eGymX+mdLZMQOiczVGFGNVhu8nmpWQNLY7e27WSxzt/ nQZ1TgAOZ84TwcHXJFZqBFzO9aexJm9Zl8+415Nkhf5Qdl7Av4yzMJ/LbJ6ipKpB3+HW FQLohMj09YhY89Ex5cXuuU70FYXPjdAQevV0FoFryuTiwPZTxmembg3qt4SuEZWqTlt/ Wu2trvUx+x0Ja6UUyat4BbGzwY8LinozO0qdOXk52xGF9dplTo+yjBP35hzuRtuI1gzU 7/Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=ml+sd9PV8EvUQ7KhKL77+R7Whg5aSMZ83owFPqGx5e8=; b=ih/fgLqTopju/+4ZLu0aXPjAbbyHnG7GreIqW0Q4vVxVVphKm1ouIDwbJFesTD/VVx t0fhYnnMuIVT9hqZYZw6iFLDphqfJaLcxEisPHUGJnxGnlnxrQJUph22FsBUqZZH49AO vCet7ZgA4pvdbF+AwZSAiLgFMk6RKH9xR9O0JE1Smh9YeALMR10mlk32LPjdYmG7HndZ x3yx0H3NnaMpGihmC1s1tAto33GzIPnDWl1JKrFtDG0X59QreNMXjAHdsA/LKKFxrv2m 0q7nNW+GwlP3ccIuC7uugeWJJcRee/CjwJX7WaG9/dTYXjmRPeMMPc5DZBa4ALZNxFuj TDqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="M/9Hf/LT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si2247138edk.332.2020.07.15.14.44.05; Wed, 15 Jul 2020 14:44:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="M/9Hf/LT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727873AbgGOVnd (ORCPT + 99 others); Wed, 15 Jul 2020 17:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727849AbgGOVn3 (ORCPT ); Wed, 15 Jul 2020 17:43:29 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A65AFC08C5CE for ; Wed, 15 Jul 2020 14:43:29 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id x184so4602348ybx.10 for ; Wed, 15 Jul 2020 14:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ml+sd9PV8EvUQ7KhKL77+R7Whg5aSMZ83owFPqGx5e8=; b=M/9Hf/LTNpql/NGtl2rSNbltCgdU1qoTHNtmZZUDdz0zlA0Aa06tg9Kkwk7FHflyJS isS2O8ZMpKycgy1QcsYrUqiI3Zdb/BQOQ7t+hVTG+qAOzNUZAE6SqqIm2r+qfLtDrHYN qPgIK0EKZdOrAewBpkokymRzmBm16vTyias/uArmk+hlpgIqB8JLMDvW3TsA3/URW4Ip JlkT8QPtzTuvT6ZhsQiWisV5ujGrv6bNErH1zNUaaAef9VaC04g91+QgZ+C85PDs+U12 xZ0fvZGtpFoI4O95ol4TMYUTXzjYDAtvJyKg43cqjVvlZPCxHJzMAhTiVZW8lOdlA9w5 YVoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ml+sd9PV8EvUQ7KhKL77+R7Whg5aSMZ83owFPqGx5e8=; b=sP8uosfWQ2bXdsHkiio5mxQhIRqQUE5wCglIe4yqQ/Jyo+f/n4s6+Go1wGnBVMNVG5 Fw/ot9UZCdwXgST4sbTEdAcvFHQBIHAU6Wd40rvIqCUuLQ4iRt9qK0VCnK3D261MwFc4 xeXiUoCsM28lrETREQhNp8S03RsGSDDPTbkZkFF6xjBZtGtYznkIWVOLTlm8FWYxqOXJ IwMdTsK9NYyoNUXIyTb5recKSUf0UrLS888iNROm/VDjGD2CVYTDLzzjXPBaWjeL1yxb zAxode2UeRiixHLqjR2D9rkjRMUfuHiojaK/40icjEbCJ/24DF7+0uDJ8aXxfTpBv5dc vqdw== X-Gm-Message-State: AOAM533aCUwFh6QslHngRzd4CbUfLIMzAjhU79xO3hNc9asTsGHG63Ti 8fIdhfoLhpMGWgD35JT1n1ShhcqJwyU= X-Received: by 2002:a25:ac02:: with SMTP id w2mr1734259ybi.57.1594849408882; Wed, 15 Jul 2020 14:43:28 -0700 (PDT) Date: Wed, 15 Jul 2020 14:43:12 -0700 In-Reply-To: <20200715214312.2266839-1-haoluo@google.com> Message-Id: <20200715214312.2266839-3-haoluo@google.com> Mime-Version: 1.0 References: <20200715214312.2266839-1-haoluo@google.com> X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [RFC PATCH bpf-next 2/2] selftests/bpf: Test __ksym externs with BTF From: Hao Luo To: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Shuah Khan , Alexei Starovoitov , Andrii Nakryiko , John Fastabend , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Quentin Monnet , Hao Luo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend ksyms.c selftest to make sure BTF enables direct loads of ksyms. Note that test is done against the kernel btf extended with kernel VARs. Signed-off-by: Hao Luo --- tools/testing/selftests/bpf/prog_tests/ksyms.c | 2 ++ tools/testing/selftests/bpf/progs/test_ksyms.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms.c b/tools/testing/selftests/bpf/prog_tests/ksyms.c index e3d6777226a8..0e7f3bc3b0ae 100644 --- a/tools/testing/selftests/bpf/prog_tests/ksyms.c +++ b/tools/testing/selftests/bpf/prog_tests/ksyms.c @@ -65,6 +65,8 @@ void test_ksyms(void) "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__rq_cpu != 0, "rq_cpu", + "got %llu, exp %llu\n", data->out__rq_cpu, (__u64)0); 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..e777603757e5 100644 --- a/tools/testing/selftests/bpf/progs/test_ksyms.c +++ b/tools/testing/selftests/bpf/progs/test_ksyms.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2019 Facebook */ +#include "vmlinux.h" #include #include #include @@ -9,11 +10,13 @@ __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__rq_cpu = -1; extern const void bpf_link_fops __ksym; extern const void __start_BTF __ksym; extern const void __stop_BTF __ksym; extern const void __per_cpu_start __ksym; +extern const void runqueues __ksym; /* non-existing symbol, weak, default to zero */ extern const void bpf_link_fops1 __ksym __weak; @@ -29,4 +32,15 @@ int handler(const void *ctx) return 0; } +SEC("tp_btf/sys_enter") +int handler_tp_btf(const void *ctx) +{ + const struct rq *rq = &runqueues; + + /* rq now points to the runqueue of cpu 0. */ + out__rq_cpu = rq->cpu; + + return 0; +} + char _license[] SEC("license") = "GPL"; -- 2.27.0.389.gc38d7665816-goog