From patchwork Fri Aug 25 08:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 13365167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2841C3DA6F for ; Fri, 25 Aug 2023 08:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241311AbjHYIhU (ORCPT ); Fri, 25 Aug 2023 04:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243228AbjHYIgo (ORCPT ); Fri, 25 Aug 2023 04:36:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AA831FF2; Fri, 25 Aug 2023 01:36:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8BD6164175; Fri, 25 Aug 2023 08:36:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A501FC433CC; Fri, 25 Aug 2023 08:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692952602; bh=ZRxhja+kWh95QQ9Ag5tsl+R/z0NeWzN9jHlu0C7A4wA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ft+8pwJyuWHEfv4Jl7PdNA12K2RPuM6IDfiaadzHshHHqYz1dFU4H1rXpJMxZDIQx 6WnBtnSNWpdPeCZwuVRLxMzU2o22MxJVx29n1xnV97mJXenykoSu1mtuwuyFOX0Z6k 5YS+ESe4wewwrbSMD+rqyizPXG3H91b2a4QfelR44e+VaIyGd5ztW7AE5VdbcWOEKn +un/KtsRYlXpRMDqUyR0ublP6/5ITXfQMELxz+rCeO7gkLzYruy0SWtcyOsSCii6nc a4xZfHQIx/co4aJ0GeZbU02icMfWj9DOCZ8Dei3KvM1olfOAXzYAQfEf2adUhw7luK dT70CsaI6jSLA== From: Benjamin Tissoires Date: Fri, 25 Aug 2023 10:36:31 +0200 Subject: [PATCH 1/3] selftests/hid: ensure we can compile the tests on kernels pre-6.3 MIME-Version: 1.0 Message-Id: <20230825-wip-selftests-v1-1-c862769020a8@kernel.org> References: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> In-Reply-To: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Justin Stitt , Nick Desaulniers Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692952596; l=2354; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=ZRxhja+kWh95QQ9Ag5tsl+R/z0NeWzN9jHlu0C7A4wA=; b=iimzBHHTtnw9UqT5LTPnPjH2BmblUlmSaOVOnH9AokjeoHggqohBXHVXAhGNKTDsWMAp+ZDkr if9Qg/YhTcsBAMcZJyNG0YP8pdfdEPEJYwJ+j4k+6GM4wtitaQ6IbZJ X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org For the hid-bpf tests to compile, we need to have the definition of struct hid_bpf_ctx. This definition is an internal one from the kernel and it is supposed to be defined in the generated vmlinux.h. This vmlinux.h header is generated based on the currently running kernel or if the kernel was already compiled in the tree. If you just compile the selftests without compiling the kernel beforehand and you are running on a 6.2 kernel, you'll end up with a vmlinux.h without the hid_bpf_ctx definition. Use the clever trick from tools/testing/selftests/bpf/progs/bpf_iter.h to force the definition of that symbol in case we don't find it in the BTF. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/progs/hid.c | 3 --- tools/testing/selftests/hid/progs/hid_bpf_helpers.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/hid/progs/hid.c b/tools/testing/selftests/hid/progs/hid.c index 88c593f753b5..1e558826b809 100644 --- a/tools/testing/selftests/hid/progs/hid.c +++ b/tools/testing/selftests/hid/progs/hid.c @@ -1,8 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2022 Red hat */ -#include "vmlinux.h" -#include -#include #include "hid_bpf_helpers.h" char _license[] SEC("license") = "GPL"; diff --git a/tools/testing/selftests/hid/progs/hid_bpf_helpers.h b/tools/testing/selftests/hid/progs/hid_bpf_helpers.h index 4fff31dbe0e7..749097f8f4d9 100644 --- a/tools/testing/selftests/hid/progs/hid_bpf_helpers.h +++ b/tools/testing/selftests/hid/progs/hid_bpf_helpers.h @@ -5,6 +5,26 @@ #ifndef __HID_BPF_HELPERS_H #define __HID_BPF_HELPERS_H +/* "undefine" structs in vmlinux.h, because we "override" them below */ +#define hid_bpf_ctx hid_bpf_ctx___not_used +#include "vmlinux.h" +#undef hid_bpf_ctx + +#include +#include + + +struct hid_bpf_ctx { + __u32 index; + const struct hid_device *hid; + __u32 allocated_size; + enum hid_report_type report_type; + union { + __s32 retval; + __s32 size; + }; +}; + /* following are kfuncs exported by HID for HID-BPF */ extern __u8 *hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, From patchwork Fri Aug 25 08:36:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 13365169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4D24EE49AB for ; Fri, 25 Aug 2023 08:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242044AbjHYIhW (ORCPT ); Fri, 25 Aug 2023 04:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239709AbjHYIgr (ORCPT ); Fri, 25 Aug 2023 04:36:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85C6019AC; Fri, 25 Aug 2023 01:36:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 230A365A22; Fri, 25 Aug 2023 08:36:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E58CC433C7; Fri, 25 Aug 2023 08:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692952604; bh=SoOIZhPy+BH1lhh+PkibmCi/a28e+9FwfvE7RWdGdTc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l8zFt9TnpPicBKDMUvdOLhXOmD0jypML3YAdrq07kg9QizPhjHluajOQkrOCuj9jg 8a8xpdCd+ywjdbeVd8bu5PLwcRLwypSQ3IhZ2wsgwlaBnSoT/xadaXFoXZJfBlxxbi OkEeTAAp5uw+xKuqWYmvNnfJm/RUlr/wC49kcl1kKc1cmv/OJx58+Z08Cq+OpoYdAd fHHCB2elSPTEf9YKOXbVV2Ouic9MUfF3XK5Ktyxh75rTJl2UrUiDN8PKZrJD3o5UkF dImrZjg8bCp2P8MlX54lOUvF/MjTU6TYsMpNQ1oVCaiYGLnYq3af36hn++tq6vZawL VC6dDlqTRx1Dg== From: Benjamin Tissoires Date: Fri, 25 Aug 2023 10:36:32 +0200 Subject: [PATCH 2/3] selftests/hid: do not manually call headers_install MIME-Version: 1.0 Message-Id: <20230825-wip-selftests-v1-2-c862769020a8@kernel.org> References: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> In-Reply-To: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Justin Stitt , Nick Desaulniers Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692952596; l=1935; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=SoOIZhPy+BH1lhh+PkibmCi/a28e+9FwfvE7RWdGdTc=; b=R9Znvk2sGB/OjwoSxK6aPdlfboNJEpepCTlCc1wBNAygDf9Fbz1fE3Gv4qJ5OQpVYiwWg35tY WeEjnIWm+7sAYt+lui27uQf+gzDSerrE+pvsqGmnHb3ypUwo/+3XkCU X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org "make headers" is a requirement before calling make on the selftests dir, so we should not have to manually install those headers Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/hid/Makefile b/tools/testing/selftests/hid/Makefile index 01c0491d64da..c5522088ece4 100644 --- a/tools/testing/selftests/hid/Makefile +++ b/tools/testing/selftests/hid/Makefile @@ -21,7 +21,7 @@ CXX ?= $(CROSS_COMPILE)g++ HOSTPKG_CONFIG := pkg-config -CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(KHDR_INCLUDES) -I$(OUTPUT) +CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(OUTPUT) LDLIBS += -lelf -lz -lrt -lpthread # Silence some warnings when compiled with clang @@ -65,7 +65,6 @@ BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool SCRATCH_DIR := $(OUTPUT)/tools BUILD_DIR := $(SCRATCH_DIR)/build INCLUDE_DIR := $(SCRATCH_DIR)/include -KHDR_INCLUDES := $(SCRATCH_DIR)/uapi/include BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a ifneq ($(CROSS_COMPILE),) HOST_BUILD_DIR := $(BUILD_DIR)/host @@ -151,9 +150,6 @@ else $(Q)cp "$(VMLINUX_H)" $@ endif -$(KHDR_INCLUDES)/linux/hid.h: $(top_srcdir)/include/uapi/linux/hid.h - $(MAKE) -C $(top_srcdir) INSTALL_HDR_PATH=$(SCRATCH_DIR)/uapi headers_install - $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ $(TOOLSDIR)/bpf/resolve_btfids/main.c \ $(TOOLSDIR)/lib/rbtree.c \ @@ -231,7 +227,7 @@ $(BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(OUTPUT) $(Q)$(BPFTOOL) gen object $(<:.o=.linked1.o) $< $(Q)$(BPFTOOL) gen skeleton $(<:.o=.linked1.o) name $(notdir $(<:.bpf.o=)) > $@ -$(OUTPUT)/%.o: %.c $(BPF_SKELS) $(KHDR_INCLUDES)/linux/hid.h +$(OUTPUT)/%.o: %.c $(BPF_SKELS) $(call msg,CC,,$@) $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@ From patchwork Fri Aug 25 08:36:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 13365168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 187A0C7EE2C for ; Fri, 25 Aug 2023 08:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242612AbjHYIhX (ORCPT ); Fri, 25 Aug 2023 04:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240951AbjHYIgt (ORCPT ); Fri, 25 Aug 2023 04:36:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C49D219AC; Fri, 25 Aug 2023 01:36:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5A2CB64175; Fri, 25 Aug 2023 08:36:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFD12C433CB; Fri, 25 Aug 2023 08:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692952606; bh=Q2ZIsubew9vjZV4NTRllMB9+S/zfEbLIL8U7zfyp2fY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FiXrbbU5wd2YWWfvKxQ75kgpXUZ1r3EYDKBbLz7Cc4qCwJu2Aj+m3kPleLC4c1T2E S3u3gGOobarm37fRQ1HmNC/5NPC5HiD+zipKXOH09PHF6hZGu3+enfScnlSWOrKYGx rhaX00Z3kSROX9T9rWTPbl8Tf3B6VV9VjfgzzAXVdffwAmwMITeNfWQxXTSGUnuhaR K1mEyvvNAVu9icopvEcu7rNNhyl0LBfKgqKsUNbD0WsYDiF+6kFrGidojzCTlIGy4l wkvNVUqYdmDjoHk3/gdp4ooid83dacxscm0M+ZXb0WhKwyymDfvM022TPYlV68T5sp Pl4MLUa8Az1yQ== From: Benjamin Tissoires Date: Fri, 25 Aug 2023 10:36:33 +0200 Subject: [PATCH 3/3] selftests/hid: force using our compiled libbpf headers MIME-Version: 1.0 Message-Id: <20230825-wip-selftests-v1-3-c862769020a8@kernel.org> References: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> In-Reply-To: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Justin Stitt , Nick Desaulniers Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692952596; l=798; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=Q2ZIsubew9vjZV4NTRllMB9+S/zfEbLIL8U7zfyp2fY=; b=+lEQzv9hCNetlUBhrOIu51yeljnR3xW75p6UxKDfmNdvqNMzDHmzekZqiMA0UasGLiQCQRFbD N9XPa2ae5U2CkFGO2TpI4jmOLXbF9q9HMMUenMC8C9aCkZAk/9Grarn X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Turns out that we were relying on the globally installed headers, not the ones we freshly compiled. Add a manual include in CFLAGS to sort this out. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/hid/Makefile b/tools/testing/selftests/hid/Makefile index c5522088ece4..b01c14077c5d 100644 --- a/tools/testing/selftests/hid/Makefile +++ b/tools/testing/selftests/hid/Makefile @@ -22,6 +22,8 @@ CXX ?= $(CROSS_COMPILE)g++ HOSTPKG_CONFIG := pkg-config CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(OUTPUT) +CFLAGS += -I$(OUTPUT)/tools/include + LDLIBS += -lelf -lz -lrt -lpthread # Silence some warnings when compiled with clang From patchwork Fri Aug 25 18:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13366212 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C88C1EE49A3 for ; Fri, 25 Aug 2023 18:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231843AbjHYSXr (ORCPT ); Fri, 25 Aug 2023 14:23:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbjHYSXi (ORCPT ); Fri, 25 Aug 2023 14:23:38 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34B1C270F for ; Fri, 25 Aug 2023 11:23:21 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-34ca1aadce9so4379805ab.1 for ; Fri, 25 Aug 2023 11:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692987800; x=1693592600; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4uemtBlWK9rkaEGTDArBGM1rxtMvvs952rnMKGpZNgc=; b=qjxkUm8IeMTvcWnFAG9ky4z9+aWcGSYpB2vRLxLvDF8AWoufIDj8n2S0Xmd4Xhw/rf zD0MlUaBCyu43va5i/c4ND2zauhSavpfcHqC+v31wlCeVbYoznsTgb/5olONvwTkWhOz lVidrD37z+OL3rVBgOjmJ5UaeE8TFMJvtbzGCC7S7IwI5H170NRn+Civvi2RQRCx/6d0 kh1apcjSlGjRhqyQYqyxwWMc5wTDBzr3WhrxNyVYE/ygXlGI7P0DtbYkc7GxStop1ihP DucpNWJYPVD6VUNxiEzRR8b3JMOOcdUul18t6X2G8JL/I4Bx1d01V2kOEgCwdr/jqusO Sg0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692987800; x=1693592600; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4uemtBlWK9rkaEGTDArBGM1rxtMvvs952rnMKGpZNgc=; b=OZy1kbtHmE0aI/KKNqcnw+cIfvftYe01qRSMQF/dW2xW+yUHb6gzTbmAyx9i1dhsra nXF02YCBMkzbmK33o3WF4R+rhID15doJl+Yrkb5yRAiXidThNHzKxpNM+BeJQsFeEz9R Wy67DxFl99rbM/Ql3D4yT/wZOEDNnE6HhyItiZIWK1SdqKKprxlZavJRGWvV7sWyl+eg v7iSwT3qNFPzXwluNBqmrcnEh0F5mivTeUznWkN7PxwbCKyAd3MACsFrpYYhPcCa20C6 QnquUIOZb+WcHHGNcCqKBrN5mnkxyk3LsHHU0I+oZv7ZfOqHOJ+Kvcg5Yic2jeyU1ZT3 BUMA== X-Gm-Message-State: AOJu0Yw0K2VvMmfNiNlyCqtzJdjKmQStsNnNloxm/pzDU3oIIUwPBzXH 0xRjK0WerGbmrrIv5EK2A7s5tQ== X-Google-Smtp-Source: AGHT+IFcAVvQPKWzqhcVnjKVq9+7EyDOWK0X/+bObEJDSn6zObhqwCHknKvskbTimwfI6VQcPa5C/g== X-Received: by 2002:a05:6e02:20c3:b0:349:862e:a863 with SMTP id 3-20020a056e0220c300b00349862ea863mr11937012ilq.15.1692987800519; Fri, 25 Aug 2023 11:23:20 -0700 (PDT) Received: from google.com (161.74.123.34.bc.googleusercontent.com. [34.123.74.161]) by smtp.gmail.com with ESMTPSA id q8-20020a92d408000000b0032b72b5c1c3sm677826ilm.9.2023.08.25.11.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 11:23:19 -0700 (PDT) Date: Fri, 25 Aug 2023 18:23:16 +0000 From: Justin Stitt To: Benjamin Tissoires Cc: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Nick Desaulniers , linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 4/3] selftests/hid: more fixes to build with older kernel Message-ID: <20230825182316.m2ksjoxe4s7dsapn@google.com> References: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230825-wip-selftests-v1-0-c862769020a8@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Fri, Aug 25, 2023 at 10:36:30AM +0200, Benjamin Tissoires wrote: > These fixes have been triggered by [0]: > basically, if you do not recompile the kernel first, and are > running on an old kernel, vmlinux.h doesn't have the required > symbols and the compilation fails. > > The tests will fail if you run them on that very same machine, > of course, but the binary should compile. > > And while I was sorting out why it was failing, I realized I > could do a couple of improvements on the Makefile. > > [0] https://lore.kernel.org/linux-input/56ba8125-2c6f-a9c9-d498-0ca1c153dcb2@redhat.com/T/#t > > Signed-off-by: Benjamin Tissoires > --- > Benjamin Tissoires (3): > selftests/hid: ensure we can compile the tests on kernels pre-6.3 > selftests/hid: do not manually call headers_install > selftests/hid: force using our compiled libbpf headers > > tools/testing/selftests/hid/Makefile | 10 ++++------ > tools/testing/selftests/hid/progs/hid.c | 3 --- > tools/testing/selftests/hid/progs/hid_bpf_helpers.h | 20 ++++++++++++++++++++ > 3 files changed, 24 insertions(+), 9 deletions(-) > --- > base-commit: 1d7546042f8fdc4bc39ab91ec966203e2d64f8bd > change-id: 20230825-wip-selftests-9a7502b56542 > > Best regards, > -- > Benjamin Tissoires > Benjamin, thanks for the work here. Your series fixed up _some_ of the errors I had while building on my 6.3.11 kernel. I'm proposing a single patch that should be applied on top of your series that fully fixes _all_ of the build errors I'm experiencing. Can you let me know if it works and potentially formulate a new series so that `b4 shazam` applies it cleanly? PATCH BELOW --- From 5378d70e1b3f7f75656332f9bff65a37122bb288 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Fri, 25 Aug 2023 18:10:33 +0000 Subject: [PATCH 4/3] selftests/hid: more fixes to build with older kernel I had to use the clever trick [1] on some other symbols to get my builds working. Apply this patch on top of Benjamin's series [2]. This is now a n=4 patch series which has fixed my builds when running: | $ make LLVM=1 -j128 ARCH=x86_64 mrproper headers | $ make LLVM=1 -j128 ARCH=x86_64 -C tools/testing/selftests TARGETS=hid [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/progs/bpf_iter.h#n3 [2]: https://lore.kernel.org/all/20230825-wip-selftests-v1-0-c862769020a8@kernel.org/ Signed-off-by: Justin Stitt --- .../selftests/hid/progs/hid_bpf_helpers.h | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) -- 2.42.0.rc1.204.g551eb34607-goog diff --git a/tools/testing/selftests/hid/progs/hid_bpf_helpers.h b/tools/testing/selftests/hid/progs/hid_bpf_helpers.h index 749097f8f4d9..e2eace2c0029 100644 --- a/tools/testing/selftests/hid/progs/hid_bpf_helpers.h +++ b/tools/testing/selftests/hid/progs/hid_bpf_helpers.h @@ -7,12 +7,26 @@ /* "undefine" structs in vmlinux.h, because we "override" them below */ #define hid_bpf_ctx hid_bpf_ctx___not_used +#define hid_report_type hid_report_type___not_used +#define hid_class_request hid_class_request___not_used +#define hid_bpf_attach_flags hid_bpf_attach_flags___not_used #include "vmlinux.h" #undef hid_bpf_ctx +#undef hid_report_type +#undef hid_class_request +#undef hid_bpf_attach_flags #include #include +#include +enum hid_report_type { + HID_INPUT_REPORT = 0, + HID_OUTPUT_REPORT = 1, + HID_FEATURE_REPORT = 2, + + HID_REPORT_TYPES, +}; struct hid_bpf_ctx { __u32 index; @@ -25,6 +39,21 @@ struct hid_bpf_ctx { }; }; +enum hid_class_request { + HID_REQ_GET_REPORT = 0x01, + HID_REQ_GET_IDLE = 0x02, + HID_REQ_GET_PROTOCOL = 0x03, + HID_REQ_SET_REPORT = 0x09, + HID_REQ_SET_IDLE = 0x0A, + HID_REQ_SET_PROTOCOL = 0x0B, +}; + +enum hid_bpf_attach_flags { + HID_BPF_FLAG_NONE = 0, + HID_BPF_FLAG_INSERT_HEAD = _BITUL(0), + HID_BPF_FLAG_MAX, +}; + /* following are kfuncs exported by HID for HID-BPF */ extern __u8 *hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset,