Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp762079ybh; Wed, 15 Jul 2020 14:43:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzZZveakTXabLDsXd7CR2GXMZzsEUcTfLkDPfIva0InCy7t86ZULdgLWvGBABRKaI7RNcP X-Received: by 2002:aa7:c749:: with SMTP id c9mr1606365eds.107.1594849436233; Wed, 15 Jul 2020 14:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594849436; cv=none; d=google.com; s=arc-20160816; b=kK9epnXN3tmsAyClLqqdc4YrkS7QT6MUS1r7UQziwfzjK5e1pF1fx5nYwxbf+RErpj RPeqjbLmO1XfJJvDwOSZzMY7X/oEJgzeP8QemB07b60fYcpo5JdsZ+IzQ4aeqqBOKtZ/ hrYkuhS+LczdHa6wryzi96aQDUzmUdJBv7uv5jc+R5ZQn98Vre2AmnF15v6D+m3K08QD WEcEzy/btmtFOwyRvp8MUe3ObLTYerDzeoALI088qbXbxVpejcozNVJED6Z4sy4yZFYz 2NfEqgEw9AwNVlGO+ovzjUY8jgza8jWZkgwOyLO7HrMOvFMjjb1c0qSxYiQ52P4ot3xL kkxw== 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:mime-version :message-id:date:dkim-signature; bh=WPW2jthcymgJJnDe4srAy8GflGzwLl52ZFtIA0Ixzqw=; b=jElMn2V0mvHw/ysog21nyFVcFONlM28bjCcLhi9j7vcu3P/MgbikJeapZc/XJXpDZk 6I/6+iY81uwhH9S6XM2Cf3pWS5MI0dNfmM4IzmtygPfldvSaDBBXWboOCC4+Z7mEBRoX 5qEk6Zs3D5G+avJDfeAxNw83aLhbC25GwnsLt2kVdplZ95wM+9uPFSiY58mSRJXOg6Ch 800fRtL47A2k1MeF8EHPDYLpmY4kpkn27I+NjS8+TnXDVbdkQck9ZOQxw/rymcWivEvd 0B5aYM12Mr6trg4xynARyEucpXjYLkLFIJt0IAVLQqQB8PBaXNtyvI9/j3+d2cWdWGGA NiVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PvN9qtLW; 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 rn4si2259368ejb.658.2020.07.15.14.43.33; Wed, 15 Jul 2020 14:43:56 -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=PvN9qtLW; 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 S1727121AbgGOVnT (ORCPT + 99 others); Wed, 15 Jul 2020 17:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbgGOVnS (ORCPT ); Wed, 15 Jul 2020 17:43:18 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB263C08C5CE for ; Wed, 15 Jul 2020 14:43:18 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id s9so4573523ybj.18 for ; Wed, 15 Jul 2020 14:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=WPW2jthcymgJJnDe4srAy8GflGzwLl52ZFtIA0Ixzqw=; b=PvN9qtLWYSDsNHkgj/A27DsYxbLZ/Xnm+V0boSzvB8ey5BIexmosCy7fP6UkN8Zb4C sjRU/+R5zu11ex3BuKYJXCu8Ou4nJO1JBvDeL/VWYvR9Ex4e5VutdUb9RQCUUB8sYUag 2w+3i8jQdmRvbG9KhMIy39jcQELLbsG//2Iy5fj3qTFiC12LFmrkC3diSfvc5Yuxy/9F KtwNHAQwI/2lNQ+CS57Ti7gxaqePN96jkHJ039IoZCkJHRp1e/E5SdJmPZj6+/Kr/vMy 7T5pI1oyS6yTvXp3k+5+h5huvsrNOh7L4gpAnasiC27Ib9QLtf6R2tjZRCDElxuZLeOS 18uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=WPW2jthcymgJJnDe4srAy8GflGzwLl52ZFtIA0Ixzqw=; b=CfviIi+BHHindIRPg1r6xZRKcRKz6sPpTnj7D901ekDw+fgDJI3SzXBktyxt0XKDge L8svuwRYta59A9s2sf0PohGKIDP1f3vzT3OmSO/p3QqIOrXyblJ0K0Rfik18fcuhZBGS fXjLXeVzIWELOWXQW3/0DXFI02EGbL8rkonjuOg16QInVOw0I/FuOLkjBnziCSpgGM9b CybSPXDAUGg1pJogokjjwvmoHrAyp+TPgbTdIVMV1ZkNGmBIosdToLdcxu7imoWWZaqF xZA8Jqszm2wRVYoGBc/vEbbOISbOX0250QBro3mWSPHtouAIzuXoa60kp+4KrAMM8tqd bKHg== X-Gm-Message-State: AOAM531IFvLCJNYR1WMbjKCU6dTiPS/wIkcyS/wk+1/1GVMoLz5kPTri ZeQ1Dy6htoosv6U/yu77VuHo9xrxyKM= X-Received: by 2002:a25:6c57:: with SMTP id h84mr1497780ybc.211.1594849397781; Wed, 15 Jul 2020 14:43:17 -0700 (PDT) Date: Wed, 15 Jul 2020 14:43:10 -0700 Message-Id: <20200715214312.2266839-1-haoluo@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [RFC PATCH bpf-next 0/2] BTF support for ksyms 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 This patch series extends the previously add __ksym externs with btf info. Right now the __ksym externs are treated as pure 64-bit scalar value. Libbpf replaces ld_imm64 insn of __ksym by its kernel address at load time. This patch series extend those extern with their btf info. Note that btf support for __ksym must come with the btf that has VARs encoded to work properly. Therefore, these patches are tested against a btf generated by a patched pahole, whose change will available in released pahole soon. There are a couple of design choices that I would like feedbacks from bpf/btf experts. 1. Because the newly added pseudo_btf_id needs to carry both a kernel address (64 bits) and a btf id (32 bits), I used the 'off' fields of ld_imm insn to carry btf id. I wonder if this breaks anything or if there is a better idea. 2. Since only a subset of vars are going to be encoded into the new btf, if a ksym that doesn't find its btf id, it doesn't get converted into pseudo_btf_id. It is still treated as pure scalar value. But we require kernel btf to be loaded in libbpf if there is any ksym in the bpf prog. This is RFC as it requires pahole changes that encode kernel vars into btf. Hao Luo (2): bpf: BTF support for __ksym externs selftests/bpf: Test __ksym externs with BTF include/uapi/linux/bpf.h | 37 ++++++++++---- kernel/bpf/verifier.c | 26 ++++++++-- tools/include/uapi/linux/bpf.h | 37 ++++++++++---- tools/lib/bpf/libbpf.c | 50 ++++++++++++++++++- .../testing/selftests/bpf/prog_tests/ksyms.c | 2 + .../testing/selftests/bpf/progs/test_ksyms.c | 14 ++++++ 6 files changed, 143 insertions(+), 23 deletions(-) -- 2.27.0.389.gc38d7665816-goog