Message ID | 20230106102332.1019632-1-benjamin.tissoires@redhat.com |
---|---|
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 p1csp748860wrt; Fri, 6 Jan 2023 02:26:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1V2RKhs0MkswN7w0xoUMMTTNB43WB+G044VYhy+1njey2ca9c2fPJuQegbMNAqdOhv1LC X-Received: by 2002:a17:907:3e0c:b0:7c0:f90f:163d with SMTP id hp12-20020a1709073e0c00b007c0f90f163dmr62434021ejc.11.1673000768709; Fri, 06 Jan 2023 02:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673000768; cv=none; d=google.com; s=arc-20160816; b=B1EcNimTKkE2d5AWCzbA/GYZmFUNVca6JMQ6yEG0qEhRQO3S/q5fC5ooQNN2DtwnDN 7CvbfwQ2amHO3HIcTi/fSYFbVTA4sRfAXnPGayrxIYe4zi1Kpnc2wLofpx/y9JNkfmXs RfDFbRelcaD7So3HSjMCiYf7hfueei4FYhFvzs+Vu/XW3zz1ogWWWDTq8b9TmVO0H8Th MpcftaduXAb/KenLLYMa/+mBZziYYkuilPBopx817ZOpHU8mpL6PeAZkOF6z/c/ekJ3q hdBbI5l/4kbLMFq0ZdZuYHMWxVgjNDVZAsiG0HcSZOKnFfQNmmgMnq8k3nJbEcQ/YKaq uVkQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Asorenzas+kjlhcMKAW/jVBQ4k5PIZb3mjnBvSPg95E=; b=PgjEnheq+7qCLaPnhuIKs0Ap4+dThrSUKrEAvWnm6A0AeM80bQhweh1WOgoINHpO2v Hpm+r2qZoLauVvNhkyXjPPQ4LDmO1dxkI/sCtwdwsT6EaCC09G/8JRLQUhO6A0K3F8QE VYhoOUS2ZzJehhfV+kktWn6HQPtm5250kGsdds8Rj4TPf+9YXaoE07GLpuTB+6e262r7 z3OlpHtwWWV+d5L2eTNYi/FsUBZd7UslsSYUNOfr+WsJR3SAaRGaUhLnqDOW8IGdVU8o OqM2Jwc1v3+OTj/5/KepCX5v4dUWgwFb4ffGy1BxpOkICv6qFjYRIuZKpZmhk28T/Dio bhzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eZjaMrNt; 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 j7-20020a05640211c700b0048c37066651si1704641edw.41.2023.01.06.02.25.45; Fri, 06 Jan 2023 02:26:08 -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=eZjaMrNt; 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 S232424AbjAFKYe (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Fri, 6 Jan 2023 05:24:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbjAFKYa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Jan 2023 05:24:30 -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 E067469B3E for <linux-kernel@vger.kernel.org>; Fri, 6 Jan 2023 02:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673000621; 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; bh=Asorenzas+kjlhcMKAW/jVBQ4k5PIZb3mjnBvSPg95E=; b=eZjaMrNt5KBEVduHxefTLXdEVjEGw4Hr4SfWwx147SYMzHocnDBfop6ms1hBaSkd/z3ru5 T3Atp7mKNh5JYgLLlBmVB0HUBncEIU/UeYXx/rteatHXN4QCBacznAmOLa7x0WEt7HezZH moFYuDDW17jciZ4laLOLjQsbO774ZoQ= 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-646-6UQoocw_OkuXf3YWNdbAng-1; Fri, 06 Jan 2023 05:23:40 -0500 X-MC-Unique: 6UQoocw_OkuXf3YWNdbAng-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D679B85A588; Fri, 6 Jan 2023 10:23:39 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id B38FFC15BAD; Fri, 6 Jan 2023 10:23:37 +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 v1 0/9] HID-BPF LLVM fixes, no more hacks Date: Fri, 6 Jan 2023 11:23:23 +0100 Message-Id: <20230106102332.1019632-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=ham 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?1754268454195989130?= X-GMAIL-MSGID: =?utf-8?q?1754268454195989130?= |
Series |
HID-BPF LLVM fixes, no more hacks
|
|
Message
Benjamin Tissoires
Jan. 6, 2023, 10:23 a.m. UTC
Hi, So this is the fix for the bug that actually prevented me to integrate HID-BPF in v6.2. While testing the code base with LLVM, I realized that clang was smarter than I expected it to be, and it sometimes inlined a function or not depending on the branch. This lead to segfaults because my current code in linux-next is messing up the bpf programs refcounts assuming that I had enough observability over the kernel. So I came back to the drawing board and realized that what I was missing was exactly a bpf_link, to represent the attachment of a bpf program to a HID device. This is the bulk of the series, in patch 6/9. The other patches are cleanups, tests, and also the addition of the vmtests.sh script I run locally, largely inspired by the one in the bpf selftests dir. This allows very fast development of HID-BPF, assuming we have tests that cover the bugs :) Cheers, Benjamin Benjamin Tissoires (9): selftests: hid: add vmtest.sh selftests: hid: allow to compile hid_bpf with LLVM selftests: hid: attach/detach 2 bpf programs, not just one selftests: hid: ensure the program is correctly pinned selftests: hid: prepare tests for HID_BPF API change HID: bpf: rework how programs are attached and stored in the kernel selftests: hid: enforce new attach API HID: bpf: clean up entrypoint HID: bpf: reorder BPF registration Documentation/hid/hid-bpf.rst | 12 +- drivers/hid/bpf/entrypoints/entrypoints.bpf.c | 9 - .../hid/bpf/entrypoints/entrypoints.lskel.h | 188 ++++-------- drivers/hid/bpf/hid_bpf_dispatch.c | 28 +- drivers/hid/bpf/hid_bpf_dispatch.h | 3 - drivers/hid/bpf/hid_bpf_jmp_table.c | 116 +++---- include/linux/hid_bpf.h | 7 + tools/testing/selftests/hid/.gitignore | 1 + tools/testing/selftests/hid/Makefile | 10 +- tools/testing/selftests/hid/config.common | 241 +++++++++++++++ tools/testing/selftests/hid/config.x86_64 | 4 + tools/testing/selftests/hid/hid_bpf.c | 32 +- tools/testing/selftests/hid/progs/hid.c | 13 + tools/testing/selftests/hid/vmtest.sh | 284 ++++++++++++++++++ 14 files changed, 724 insertions(+), 224 deletions(-) create mode 100644 tools/testing/selftests/hid/config.common create mode 100644 tools/testing/selftests/hid/config.x86_64 create mode 100755 tools/testing/selftests/hid/vmtest.sh