Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2260252pxm; Fri, 4 Mar 2022 12:32:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaualZD8KLsUIoUDiMhS7vf9TC5W3syQuK6Dp9VZYcoN40OUX0QSVIEwS2OvVOf69tW7K+ X-Received: by 2002:a17:902:bcc2:b0:14f:23c6:c8c5 with SMTP id o2-20020a170902bcc200b0014f23c6c8c5mr172660pls.131.1646425958400; Fri, 04 Mar 2022 12:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646425958; cv=none; d=google.com; s=arc-20160816; b=NiG/bKgaNBe54J+XCE2Pq8v7YSby/nbgwZVgMuDjPkUkpCcqgKQwbafxbrH1YSSann Jkql/oWDaWORnzFWHPaZwqRWDFwttZ88FLEKtGJn9ImOuPjb3/PX7c2S5hByRLRkbSNT vBJg/gGE3jO6uSURFlCTyhMaur0+xitKWreKITAsnRAIjv9+mfAyzPSeLMsgDTRGASM3 oLRv/KwRepApmOKr0ZL54qpqQp9lNE4iml84cFGdCf7YJJUfbMtjR+3Smb6NkTfBLFSY j+VfAut2NfkfO6gkJ1jNJZdNIDFIQ+tqiWyE0vLrPpktl1FioKeUD92cBbw1tEb5w+cf XgfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rCz0m9X2qfcLrQ17iU+zBSGZpBuvHijRaj3zwrGqBqI=; b=BkbnP9ctBs8i76uWMz4+sfSLHsFR9Lj8VO6mtrq3158eCxHrn3qXTjE/5oN47Ah6uq HzNh4tBIyb5U3ouJ/t03XvUxfgo1zsAo5bz3dVYZQa0wqWojN2asAVEQuJjv/CdOCzE3 5k/h9yTwVxFA56Nfag2LFSFiF10zHR6NiGYtyN+0nIIAYqa/Lk/xZ4Tp7oeDouLE+WAV oUo5rlZb/n/3cnvs+BIhcHutC7wcbWuZ+UxSC9rAH4PqgUkcgxr4BpiLWuUAqSgJs8IC eIFZDfcwthUyoKDlT6dtyMVdQpCc4oZ/R0ViC8TDQSByw30XcHSwTUESFr9m9fBUr72r 9ZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JEE3gqzh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p6-20020a170902bd0600b0014fea76a5besi5136304pls.314.2022.03.04.12.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:32:38 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JEE3gqzh; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 80AEF2590D5; Fri, 4 Mar 2022 11:36:53 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241137AbiCDRcI (ORCPT + 99 others); Fri, 4 Mar 2022 12:32:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241114AbiCDRcC (ORCPT ); Fri, 4 Mar 2022 12:32:02 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 84AD31D0360 for ; Fri, 4 Mar 2022 09:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646415072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rCz0m9X2qfcLrQ17iU+zBSGZpBuvHijRaj3zwrGqBqI=; b=JEE3gqzhQcp7GqD+fs0Z3KteQ97FJbVE884TFnd4X/0c/IJCZ+G0eoJu0ZYh4irjgj6BRZ kVxLKHuvFPW7D3RBoiSoJLFyJ1kbuKNLimaU6b9teIb53SABBlVXr2rQa0kKSpmti7n5bi WTJRrVLLjkxr+YQmrSloxgtiWlYcOW0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-377-ArT2qtWiMi2Tv-xsW-M3kQ-1; Fri, 04 Mar 2022 12:31:09 -0500 X-MC-Unique: ArT2qtWiMi2Tv-xsW-M3kQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF76518766D0; Fri, 4 Mar 2022 17:31:06 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0126B86595; Fri, 4 Mar 2022 17:31:02 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer Cc: Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Benjamin Tissoires Subject: [PATCH bpf-next v2 04/28] libbpf: add HID program type and API Date: Fri, 4 Mar 2022 18:28:28 +0100 Message-Id: <20220304172852.274126-5-benjamin.tissoires@redhat.com> In-Reply-To: <20220304172852.274126-1-benjamin.tissoires@redhat.com> References: <20220304172852.274126-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HID-bpf program type are needing a new SEC. To bind a hid-bpf program, we can rely on bpf_program__attach_fd() so export a new function to the API. Signed-off-by: Benjamin Tissoires --- changes in v2: - split the series by bpf/libbpf/hid/selftests and samples --- tools/lib/bpf/libbpf.c | 7 +++++++ tools/lib/bpf/libbpf.h | 2 ++ tools/lib/bpf/libbpf.map | 1 + 3 files changed, 10 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 81bf01d67671..356bbd3ad2c7 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -8680,6 +8680,7 @@ static const struct bpf_sec_def section_defs[] = { SEC_DEF("cgroup/setsockopt", CGROUP_SOCKOPT, BPF_CGROUP_SETSOCKOPT, SEC_ATTACHABLE | SEC_SLOPPY_PFX), SEC_DEF("struct_ops+", STRUCT_OPS, 0, SEC_NONE), SEC_DEF("sk_lookup", SK_LOOKUP, BPF_SK_LOOKUP, SEC_ATTACHABLE | SEC_SLOPPY_PFX), + SEC_DEF("hid/device_event", HID, BPF_HID_DEVICE_EVENT, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX), }; #define MAX_TYPE_NAME_SIZE 32 @@ -10659,6 +10660,12 @@ static struct bpf_link *attach_iter(const struct bpf_program *prog, long cookie) return bpf_program__attach_iter(prog, NULL); } +struct bpf_link * +bpf_program__attach_hid(const struct bpf_program *prog, int hid_fd) +{ + return bpf_program__attach_fd(prog, hid_fd, 0, "hid"); +} + struct bpf_link *bpf_program__attach(const struct bpf_program *prog) { if (!prog->sec_def || !prog->sec_def->attach_fn) diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index c8d8daad212e..f677ac0a9ede 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -529,6 +529,8 @@ struct bpf_iter_attach_opts { LIBBPF_API struct bpf_link * bpf_program__attach_iter(const struct bpf_program *prog, const struct bpf_iter_attach_opts *opts); +LIBBPF_API struct bpf_link * +bpf_program__attach_hid(const struct bpf_program *prog, int hid_fd); /* * Libbpf allows callers to adjust BPF programs before being loaded diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map index 47e70c9058d9..fdc6fa743953 100644 --- a/tools/lib/bpf/libbpf.map +++ b/tools/lib/bpf/libbpf.map @@ -424,6 +424,7 @@ LIBBPF_0.6.0 { LIBBPF_0.7.0 { global: bpf_btf_load; + bpf_program__attach_hid; bpf_program__expected_attach_type; bpf_program__log_buf; bpf_program__log_level; -- 2.35.1