Message ID | 20230113090935.1763477-10-benjamin.tissoires@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp167671wrt; Fri, 13 Jan 2023 01:18:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXvx22VoIdsLxH9ogd8o+Nt1WsBhgxrIebytGs4OxOLShLY1wwsJ7CHvswo+i6ZLKIRJcYKC X-Received: by 2002:a17:907:8b90:b0:84d:207d:c00c with SMTP id tb16-20020a1709078b9000b0084d207dc00cmr25625302ejc.25.1673601485422; Fri, 13 Jan 2023 01:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601485; cv=none; d=google.com; s=arc-20160816; b=dgeucznS8c+CwdgVxk8mLlqShQw/tfrBvPZQXIxysL135hDMGgBVFNxlIezptVjPzS Lsuvb45Q9KWnbvZhRwL6mNTXgxRjorC7kgI80cdGmc+XGgtfQPaG+eM+H2TV6ZJuPkmZ 8ToXjs/Pv2r+mNcQoPOsQxi1+Ri2b8eDAq7dYWROQk+jEsSxnh1VfS/UCSL3mjdjIh2C HR9LavDQuB9y7s/eR8TB0N5l+aIXpGGwL8ayIEx8keVwDYku95MlVh4sdvWDXj01PHmr 0j4lXMURicJdCySWHZP0X9mpQKtCqgAPpJhaZDASIWC6bv291fbGFSdWxqrT6gMYP55Z PJRw== 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=/inVd9UHQixWXyAa+0MDkfw5LIKFllU3vs3HgZK6jgc=; b=f4/7uWHo+Zw8sly0zt+HEreOWLjipqkiSqSQ+43i1AHytIwoKrTFUz+YxDFjbGCVdV l76e2Bj2pOABd6IQjI3nlMxyzZUqktO0NuhBQbnpqU1cV6gPekT1Yrcszjg/VfQqZqpk TpaUUI9KxDHNHYa1ir/IkxMyBcPW/8/hlfkwhH+laKFkdG8vZoLCJyBcIXc2hh+j9SmM iKu7nUhLJ+ZWiBOd8dfLf3WqSSQqFIsLwu8WpV6c6mujU5UQnbaU5DsEH/oQiz0/SERl 7ZsJoIOubZPcAhOWIm4GPEHWFYyPt56zkArCKDOOS9OXsDaNVENWNsoAiSuqerRiSxBH vj+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J2qmS1vI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a056402125300b00487ceac6d34si18308310edw.137.2023.01.13.01.17.41; Fri, 13 Jan 2023 01:18:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J2qmS1vI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235389AbjAMJOw (ORCPT <rfc822;callmefire3@gmail.com> + 99 others); Fri, 13 Jan 2023 04:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241208AbjAMJM2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Jan 2023 04:12:28 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B4C14035 for <linux-kernel@vger.kernel.org>; Fri, 13 Jan 2023 01:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673601009; 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=/inVd9UHQixWXyAa+0MDkfw5LIKFllU3vs3HgZK6jgc=; b=J2qmS1vI3H+cSoaRnu7FbHVoIz1jh/VzaUu6SWnsh3znpuZrrZ1aUAXNEVlSi7prTWvm/n 59Or0Dp6dZNNmUX+V9QM79TxhhNMiJjQRU606DkEHhwTmOIdcHD87A0NnHrXXk3pXre1LK Yl2AaiNiCNQCT/1RnEGRoP65NUD2+5I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550--HjQU60KNxmzY7XjHPb57A-1; Fri, 13 Jan 2023 04:10:03 -0500 X-MC-Unique: -HjQU60KNxmzY7XjHPb57A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40D81101A55E; Fri, 13 Jan 2023 09:10:02 +0000 (UTC) Received: from plouf.redhat.com (ovpn-193-50.brq.redhat.com [10.40.193.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EF531121314; Fri, 13 Jan 2023 09:09:59 +0000 (UTC) From: Benjamin Tissoires <benjamin.tissoires@redhat.com> To: Greg KH <gregkh@linuxfoundation.org>, Jiri Kosina <jikos@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Tero Kristo <tero.kristo@linux.intel.com>, 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 <benjamin.tissoires@redhat.com> Subject: [PATCH HID for-next v2 9/9] HID: bpf: reorder BPF registration Date: Fri, 13 Jan 2023 10:09:35 +0100 Message-Id: <20230113090935.1763477-10-benjamin.tissoires@redhat.com> In-Reply-To: <20230113090935.1763477-1-benjamin.tissoires@redhat.com> References: <20230113090935.1763477-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898351409572276?= X-GMAIL-MSGID: =?utf-8?q?1754898351409572276?= |
Series |
HID-BPF LLVM fixes, no more hacks
|
|
Commit Message
Benjamin Tissoires
Jan. 13, 2023, 9:09 a.m. UTC
Given that our initial BPF program is not using any kfuncs anymore,
we can reorder the initialization to first try to load it and then
register the kfuncs. This has the advantage of not exporting kfuncs
when HID-BPF is not working.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
no changes in v2
---
drivers/hid/bpf/hid_bpf_dispatch.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Comments
On Fri, Jan 13, 2023 at 10:09:35AM +0100, Benjamin Tissoires wrote: > Given that our initial BPF program is not using any kfuncs anymore, > we can reorder the initialization to first try to load it and then > register the kfuncs. This has the advantage of not exporting kfuncs > when HID-BPF is not working. > > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Alexei Starovoitov <ast@kernel.org>
diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index 26117b4ec016..8a034a555d4c 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -514,15 +514,16 @@ static int __init hid_bpf_init(void) return 0; } - err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set); + err = hid_bpf_preload_skel(); if (err) { - pr_warn("error while setting HID BPF tracing kfuncs: %d", err); + pr_warn("error while preloading HID BPF dispatcher: %d", err); return 0; } - err = hid_bpf_preload_skel(); + /* register tracing kfuncs after we are sure we can load our preloaded bpf program */ + err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set); if (err) { - pr_warn("error while preloading HID BPF dispatcher: %d", err); + pr_warn("error while setting HID BPF tracing kfuncs: %d", err); return 0; }