From patchwork Fri Jan 13 09:09:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 43097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp166715wrt; Fri, 13 Jan 2023 01:15:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXuECVGlLc2TDidol17ebiUdKTj6wWMJY9ePwucmErtSLXwNlD4jc7aKlWZzwXOzqmDaKluk X-Received: by 2002:a17:906:9f22:b0:7c1:bb5:5704 with SMTP id fy34-20020a1709069f2200b007c10bb55704mr2428032ejc.26.1673601311358; Fri, 13 Jan 2023 01:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601311; cv=none; d=google.com; s=arc-20160816; b=N/6M3PLwtmkmU+I7/YkKsdPuEJUXaiWuwdcsY7lpbKSClcc7tDK19cBcQtyvub3xcf j+IfFnNhJbgl4ig1SWNSU9UJfaw8iGWPi/DIIWgyJKYL3rDCyHZKxQe7+NT7GFBWBbEq TfP4bTPiNBWKyhbtUb6DHFV+ARbjLR6rBbWi608YVJvaLWh1bW+ItHPWJLU7YKxgusiP Du8xGY+MkLS5+Tk0aDKio2HcSt7K358LfhlqeHWA3WVTAjI8sCRfgEGjLQRu8cJ10PsM 1Rgrbw3oWFq3IkVcI0CRJEJ4pvgdbsPauMW6z2yZ5bEYYnqE1HWnthflbKTAVYiAgcKf SA6g== 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=7FCEfZxfWz7PsmqKYXy0FiPjlQnh4dwI/SQQNuLmUZM=; b=SBdteZZIGRWzan/lidPUGdzUYqjUUx09EPWEhU5d7XjNv2izJg//Xf1PLu/aviN62U 2IQ3pbqjCVIXKLtx1HZcE/j9NdSQ0T0O7KQ/zKDWwvMKUXCVNxZOih11dqs0zVabCKeP PNb7rRTOXs6pgq0NkeWCL9MMzcjVIdhQ6jyyq5T7A+2/pi2QaAPXSnFWua/YubdT6cMO yjug+EzTHU1kyvE/wrLlw2OvUyNRYz/EPtOSRvvgjDhEOJ64KiTp4lcJQ0yGt/ANWa+q 6fUX1cQ7Sh1udzOUuAt4xIwefXsv8tIkhlqM1yDFMrOqIm8Pxf5sxfPlKvk2Ep9lCUfi r79Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V5jyJbY3; 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 oq19-20020a170906cc9300b007acef3bec44si16887131ejb.221.2023.01.13.01.14.47; Fri, 13 Jan 2023 01:15:11 -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=V5jyJbY3; 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 S241174AbjAMJMU (ORCPT + 99 others); Fri, 13 Jan 2023 04:12:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240797AbjAMJMG (ORCPT ); Fri, 13 Jan 2023 04:12:06 -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 E5AE365AE for ; Fri, 13 Jan 2023 01:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673600988; 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=7FCEfZxfWz7PsmqKYXy0FiPjlQnh4dwI/SQQNuLmUZM=; b=V5jyJbY3/wLv89FvYVx+RKTZxox1QGKIfobi9aLJMh+3gJ4IQ5/00Du4abFOQZgrcXAKm3 ihFEDdpTuRL+l/oUXiGfwz6iDk5gv/KrCsnXmdWmTzocIVlHqucS/1yB7bxRhel0vgpUqq By173qNMliUnWPcao6ywkCDeGjnn+cs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-q-JFTs1TNf2wQjT_93cu0g-1; Fri, 13 Jan 2023 04:09:42 -0500 X-MC-Unique: q-JFTs1TNf2wQjT_93cu0g-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 3DB893815EE7; Fri, 13 Jan 2023 09:09:42 +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 0BF291121315; Fri, 13 Jan 2023 09:09:39 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 1/9] selftests: hid: add vmtest.sh Date: Fri, 13 Jan 2023 10:09:27 +0100 Message-Id: <20230113090935.1763477-2-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 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,UPPERCASE_50_75 autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898168995464511?= X-GMAIL-MSGID: =?utf-8?q?1754898168995464511?= Similar-ish in many points from the script in selftests/bpf, with a few differences: - relies on boot2container instead of a plain qemu image (meaning that we can take any container in a registry as a base) - runs in the hid selftest dir, and such uses the test program from there - the working directory to store the config is in tools/selftests/hid/results Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/.gitignore | 1 + tools/testing/selftests/hid/config.common | 241 ++++++++++++++++++ tools/testing/selftests/hid/config.x86_64 | 4 + tools/testing/selftests/hid/vmtest.sh | 284 ++++++++++++++++++++++ 4 files changed, 530 insertions(+) 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 diff --git a/tools/testing/selftests/hid/.gitignore b/tools/testing/selftests/hid/.gitignore index a462ca6ab2c0..995af0670f69 100644 --- a/tools/testing/selftests/hid/.gitignore +++ b/tools/testing/selftests/hid/.gitignore @@ -2,3 +2,4 @@ bpftool *.skel.h /tools hid_bpf +results diff --git a/tools/testing/selftests/hid/config.common b/tools/testing/selftests/hid/config.common new file mode 100644 index 000000000000..0617275d93cc --- /dev/null +++ b/tools/testing/selftests/hid/config.common @@ -0,0 +1,241 @@ +CONFIG_9P_FS_POSIX_ACL=y +CONFIG_9P_FS_SECURITY=y +CONFIG_9P_FS=y +CONFIG_AUDIT=y +CONFIG_BINFMT_MISC=y +CONFIG_BLK_CGROUP_IOLATENCY=y +CONFIG_BLK_CGROUP=y +CONFIG_BLK_DEV_BSGLIB=y +CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_BLK_DEV_RAM_SIZE=16384 +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_THROTTLING=y +CONFIG_BONDING=y +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y +CONFIG_BOOTTIME_TRACING=y +CONFIG_BSD_DISKLABEL=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_CFS_BANDWIDTH=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_DEBUG=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_HUGETLB=y +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_CGROUP_NET_PRIO=y +CONFIG_CGROUP_PERF=y +CONFIG_CGROUP_PIDS=y +CONFIG_CGROUP_RDMA=y +CONFIG_CGROUP_SCHED=y +CONFIG_CGROUPS=y +CONFIG_CGROUP_WRITEBACK=y +CONFIG_CMA_AREAS=7 +CONFIG_CMA=y +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_IDLE_GOV_LADDER=y +CONFIG_CPUSETS=y +CONFIG_CRC_T10DIF=y +CONFIG_CRYPTO_BLAKE2B=y +CONFIG_CRYPTO_DEV_VIRTIO=y +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_XXHASH=y +CONFIG_DCB=y +CONFIG_DEBUG_ATOMIC_SLEEP=y +CONFIG_DEBUG_CREDENTIALS=y +CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_DEFAULT_FQ_CODEL=y +CONFIG_DEFAULT_RENO=y +CONFIG_DEFAULT_SECURITY_DAC=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_DEVTMPFS=y +CONFIG_DMA_CMA=y +CONFIG_DNS_RESOLVER=y +CONFIG_EFI_STUB=y +CONFIG_EFI=y +CONFIG_EXPERT=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_EXT4_FS=y +CONFIG_FAIL_FUNCTION=y +CONFIG_FAULT_INJECTION_DEBUG_FS=y +CONFIG_FAULT_INJECTION=y +CONFIG_FB_MODE_HELPERS=y +CONFIG_FB_TILEBLITTING=y +CONFIG_FB_VESA=y +CONFIG_FB=y +CONFIG_FONT_8x16=y +CONFIG_FONT_MINI_4x6=y +CONFIG_FONTS=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FUSE_FS=y +CONFIG_FW_LOADER_USER_HELPER=y +CONFIG_GART_IOMMU=y +CONFIG_GENERIC_PHY=y +CONFIG_HARDLOCKUP_DETECTOR=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_HPET=y +CONFIG_HUGETLBFS=y +CONFIG_HUGETLB_PAGE=y +CONFIG_HWPOISON_INJECT=y +CONFIG_HZ_1000=y +CONFIG_INET=y +CONFIG_INTEL_POWERCLAMP=y +CONFIG_IP6_NF_FILTER=y +CONFIG_IP6_NF_IPTABLES=y +CONFIG_IP6_NF_NAT=y +CONFIG_IP6_NF_TARGET_MASQUERADE=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_MROUTE=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_NF_FILTER=y +CONFIG_IP_NF_IPTABLES=y +CONFIG_IP_NF_NAT=y +CONFIG_IP_NF_TARGET_MASQUERADE=y +CONFIG_IP_PIMSM_V1=y +CONFIG_IP_PIMSM_V2=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_IPV6_MIP6=y +CONFIG_IPV6_ROUTE_INFO=y +CONFIG_IPV6_ROUTER_PREF=y +CONFIG_IPV6_SEG6_LWTUNNEL=y +CONFIG_IPV6_SUBTREES=y +CONFIG_IRQ_POLL=y +CONFIG_JUMP_LABEL=y +CONFIG_KARMA_PARTITION=y +CONFIG_KEXEC=y +CONFIG_KPROBES=y +CONFIG_KSM=y +CONFIG_LEGACY_VSYSCALL_NONE=y +CONFIG_LOG_BUF_SHIFT=21 +CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 +CONFIG_LOGO=y +CONFIG_LSM="selinux,bpf,integrity" +CONFIG_MAC_PARTITION=y +CONFIG_MAGIC_SYSRQ=y +CONFIG_MCORE2=y +CONFIG_MEMCG=y +CONFIG_MEMORY_FAILURE=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_MODULES=y +CONFIG_NAMESPACES=y +CONFIG_NET_9P_VIRTIO=y +CONFIG_NET_9P=y +CONFIG_NET_ACT_BPF=y +CONFIG_NET_CLS_CGROUP=y +CONFIG_NETDEVICES=y +CONFIG_NET_EMATCH=y +CONFIG_NETFILTER_NETLINK_LOG=y +CONFIG_NETFILTER_NETLINK_QUEUE=y +CONFIG_NETFILTER_XTABLES=y +CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y +CONFIG_NETFILTER_XT_MATCH_BPF=y +CONFIG_NETFILTER_XT_MATCH_COMMENT=y +CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y +CONFIG_NETFILTER_XT_MATCH_MARK=y +CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y +CONFIG_NETFILTER_XT_MATCH_STATISTIC=y +CONFIG_NETFILTER_XT_NAT=y +CONFIG_NETFILTER_XT_TARGET_MASQUERADE=y +CONFIG_NET_IPGRE_BROADCAST=y +CONFIG_NET_L3_MASTER_DEV=y +CONFIG_NETLABEL=y +CONFIG_NET_SCH_DEFAULT=y +CONFIG_NET_SCHED=y +CONFIG_NET_SCH_FQ_CODEL=y +CONFIG_NET_TC_SKB_EXT=y +CONFIG_NET_VRF=y +CONFIG_NET=y +CONFIG_NF_CONNTRACK=y +CONFIG_NF_NAT_MASQUERADE=y +CONFIG_NF_NAT=y +CONFIG_NLS_ASCII=y +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NO_HZ=y +CONFIG_NR_CPUS=128 +CONFIG_NUMA_BALANCING=y +CONFIG_NUMA=y +CONFIG_NVMEM=y +CONFIG_OSF_PARTITION=y +CONFIG_OVERLAY_FS_INDEX=y +CONFIG_OVERLAY_FS_METACOPY=y +CONFIG_OVERLAY_FS_XINO_AUTO=y +CONFIG_OVERLAY_FS=y +CONFIG_PACKET=y +CONFIG_PANIC_ON_OOPS=y +CONFIG_PARTITION_ADVANCED=y +CONFIG_PCIEPORTBUS=y +CONFIG_PCI_IOV=y +CONFIG_PCI_MSI=y +CONFIG_PCI=y +CONFIG_PHYSICAL_ALIGN=0x1000000 +CONFIG_POSIX_MQUEUE=y +CONFIG_POWER_SUPPLY=y +CONFIG_PREEMPT=y +CONFIG_PRINTK_TIME=y +CONFIG_PROC_KCORE=y +CONFIG_PROFILING=y +CONFIG_PROVE_LOCKING=y +CONFIG_PTP_1588_CLOCK=y +CONFIG_RC_DEVICES=y +CONFIG_RC_LOOPBACK=y +CONFIG_RCU_CPU_STALL_TIMEOUT=60 +CONFIG_SCHED_STACK_END_CHECK=y +CONFIG_SCHEDSTATS=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SECURITY_SELINUX=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_DETECT_IRQ=y +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_NR_UARTS=32 +CONFIG_SERIAL_8250_RSA=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_NONSTANDARD=y +CONFIG_SERIO_LIBPS2=y +CONFIG_SGI_PARTITION=y +CONFIG_SMP=y +CONFIG_SOCK_CGROUP_DATA=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_SUN_PARTITION=y +CONFIG_SYNC_FILE=y +CONFIG_SYSVIPC=y +CONFIG_TASK_DELAY_ACCT=y +CONFIG_TASK_IO_ACCOUNTING=y +CONFIG_TASKSTATS=y +CONFIG_TASK_XACCT=y +CONFIG_TCP_CONG_ADVANCED=y +CONFIG_TCP_MD5SIG=y +CONFIG_TLS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS=y +CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y +CONFIG_TRANSPARENT_HUGEPAGE=y +CONFIG_TUN=y +CONFIG_UNIXWARE_DISKLABEL=y +CONFIG_UNIX=y +CONFIG_USER_NS=y +CONFIG_VALIDATE_FS_PARSER=y +CONFIG_VETH=y +CONFIG_VIRT_DRIVERS=y +CONFIG_VIRTIO_BALLOON=y +CONFIG_VIRTIO_BLK=y +CONFIG_VIRTIO_CONSOLE=y +CONFIG_VIRTIO_FS=y +CONFIG_VIRTIO_NET=y +CONFIG_VIRTIO_PCI=y +CONFIG_VLAN_8021Q=y +CONFIG_XFRM_SUB_POLICY=y +CONFIG_XFRM_USER=y +CONFIG_ZEROPLUS_FF=y diff --git a/tools/testing/selftests/hid/config.x86_64 b/tools/testing/selftests/hid/config.x86_64 new file mode 100644 index 000000000000..a8721f403c21 --- /dev/null +++ b/tools/testing/selftests/hid/config.x86_64 @@ -0,0 +1,4 @@ +CONFIG_X86_ACPI_CPUFREQ=y +CONFIG_X86_CPUID=y +CONFIG_X86_MSR=y +CONFIG_X86_POWERNOW_K8=y diff --git a/tools/testing/selftests/hid/vmtest.sh b/tools/testing/selftests/hid/vmtest.sh new file mode 100755 index 000000000000..90f34150f257 --- /dev/null +++ b/tools/testing/selftests/hid/vmtest.sh @@ -0,0 +1,284 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +set -u +set -e + +# This script currently only works for x86_64 +ARCH="$(uname -m)" +case "${ARCH}" in +x86_64) + QEMU_BINARY=qemu-system-x86_64 + BZIMAGE="arch/x86/boot/bzImage" + ;; +*) + echo "Unsupported architecture" + exit 1 + ;; +esac +DEFAULT_COMMAND="./hid_bpf" +SCRIPT_DIR="$(dirname $(realpath $0))" +OUTPUT_DIR="$SCRIPT_DIR/results" +KCONFIG_REL_PATHS=("${SCRIPT_DIR}/config" "${SCRIPT_DIR}/config.common" "${SCRIPT_DIR}/config.${ARCH}") +B2C_URL="https://gitlab.freedesktop.org/mupuf/boot2container/-/raw/master/vm2c.py" +NUM_COMPILE_JOBS="$(nproc)" +LOG_FILE_BASE="$(date +"hid_selftests.%Y-%m-%d_%H-%M-%S")" +LOG_FILE="${LOG_FILE_BASE}.log" +EXIT_STATUS_FILE="${LOG_FILE_BASE}.exit_status" +CONTAINER_IMAGE="registry.fedoraproject.org/fedora:36" + +usage() +{ + cat <] -- [] + + is the command you would normally run when you are in +tools/testing/selftests/bpf. e.g: + + $0 -- ./hid_bpf + +If no command is specified and a debug shell (-s) is not requested, +"${DEFAULT_COMMAND}" will be run by default. + +If you build your kernel using KBUILD_OUTPUT= or O= options, these +can be passed as environment variables to the script: + + O= $0 -- ./hid_bpf + +or + + KBUILD_OUTPUT= $0 -- ./hid_bpf + +Options: + + -u) Update the boot2container script to a newer version. + -d) Update the output directory (default: ${OUTPUT_DIR}) + -j) Number of jobs for compilation, similar to -j in make + (default: ${NUM_COMPILE_JOBS}) + -s) Instead of powering off the VM, start an interactive + shell. If is specified, the shell runs after + the command finishes executing +EOF +} + +download() +{ + local file="$1" + + echo "Downloading $file..." >&2 + curl -Lsf "$file" -o "${@:2}" +} + +recompile_kernel() +{ + local kernel_checkout="$1" + local make_command="$2" + + cd "${kernel_checkout}" + + ${make_command} olddefconfig + ${make_command} +} + +update_selftests() +{ + local kernel_checkout="$1" + local selftests_dir="${kernel_checkout}/tools/testing/selftests/hid" + + cd "${selftests_dir}" + ${make_command} +} + +run_vm() +{ + local b2c="$1" + local kernel_bzimage="$2" + local command="$3" + local post_command="" + + if ! which "${QEMU_BINARY}" &> /dev/null; then + cat < ${OUTPUT_DIR}/${EXIT_STATUS_FILE} + + set -e + + ${post_command} +} + +is_rel_path() +{ + local path="$1" + + [[ ${path:0:1} != "/" ]] +} + +do_update_kconfig() +{ + local kernel_checkout="$1" + local kconfig_file="$2" + + rm -f "$kconfig_file" 2> /dev/null + + for config in "${KCONFIG_REL_PATHS[@]}"; do + local kconfig_src="${config}" + cat "$kconfig_src" >> "$kconfig_file" + done +} + +update_kconfig() +{ + local kernel_checkout="$1" + local kconfig_file="$2" + + if [[ -f "${kconfig_file}" ]]; then + local local_modified="$(stat -c %Y "${kconfig_file}")" + + for config in "${KCONFIG_REL_PATHS[@]}"; do + local kconfig_src="${config}" + local src_modified="$(stat -c %Y "${kconfig_src}")" + # Only update the config if it has been updated after the + # previously cached config was created. This avoids + # unnecessarily compiling the kernel and selftests. + if [[ "${src_modified}" -gt "${local_modified}" ]]; then + do_update_kconfig "$kernel_checkout" "$kconfig_file" + # Once we have found one outdated configuration + # there is no need to check other ones. + break + fi + done + else + do_update_kconfig "$kernel_checkout" "$kconfig_file" + fi +} + +main() +{ + local script_dir="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" + local kernel_checkout=$(realpath "${script_dir}"/../../../../) + # By default the script searches for the kernel in the checkout directory but + # it also obeys environment variables O= and KBUILD_OUTPUT= + local kernel_bzimage="${kernel_checkout}/${BZIMAGE}" + local command="${DEFAULT_COMMAND}" + local update_b2c="no" + local debug_shell="no" + + while getopts ':hsud:j:' opt; do + case ${opt} in + u) + update_b2c="yes" + ;; + d) + OUTPUT_DIR="$OPTARG" + ;; + j) + NUM_COMPILE_JOBS="$OPTARG" + ;; + s) + command="/bin/sh" + debug_shell="yes" + ;; + h) + usage + exit 0 + ;; + \? ) + echo "Invalid Option: -$OPTARG" + usage + exit 1 + ;; + : ) + echo "Invalid Option: -$OPTARG requires an argument" + usage + exit 1 + ;; + esac + done + shift $((OPTIND -1)) + + # trap 'catch "$?"' EXIT + + if [[ "${debug_shell}" == "no" ]]; then + if [[ $# -eq 0 ]]; then + echo "No command specified, will run ${DEFAULT_COMMAND} in the vm" + else + command="$@" + + if [[ "${command}" == "/bin/bash" || "${command}" == "bash" ]] + then + debug_shell="yes" + fi + fi + fi + + local kconfig_file="${OUTPUT_DIR}/latest.config" + local make_command="make -j ${NUM_COMPILE_JOBS} KCONFIG_CONFIG=${kconfig_file}" + + # Figure out where the kernel is being built. + # O takes precedence over KBUILD_OUTPUT. + if [[ "${O:=""}" != "" ]]; then + if is_rel_path "${O}"; then + O="$(realpath "${PWD}/${O}")" + fi + kernel_bzimage="${O}/${BZIMAGE}" + make_command="${make_command} O=${O}" + elif [[ "${KBUILD_OUTPUT:=""}" != "" ]]; then + if is_rel_path "${KBUILD_OUTPUT}"; then + KBUILD_OUTPUT="$(realpath "${PWD}/${KBUILD_OUTPUT}")" + fi + kernel_bzimage="${KBUILD_OUTPUT}/${BZIMAGE}" + make_command="${make_command} KBUILD_OUTPUT=${KBUILD_OUTPUT}" + fi + + local b2c="${OUTPUT_DIR}/vm2c.py" + + echo "Output directory: ${OUTPUT_DIR}" + + mkdir -p "${OUTPUT_DIR}" + update_kconfig "${kernel_checkout}" "${kconfig_file}" + + recompile_kernel "${kernel_checkout}" "${make_command}" + + if [[ "${update_b2c}" == "no" && ! -f "${b2c}" ]]; then + echo "vm2c script not found in ${b2c}" + update_b2c="yes" + fi + + if [[ "${update_b2c}" == "yes" ]]; then + download $B2C_URL $b2c + chmod +x $b2c + fi + + update_selftests "${kernel_checkout}" "${make_command}" + run_vm $b2c "${kernel_bzimage}" "${command}" + if [[ "${debug_shell}" != "yes" ]]; then + echo "Logs saved in ${OUTPUT_DIR}/${LOG_FILE}" + fi + + exit $(cat ${OUTPUT_DIR}/${EXIT_STATUS_FILE}) +} + +main "$@" From patchwork Fri Jan 13 09:09:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 43101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp167275wrt; Fri, 13 Jan 2023 01:16:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCS5pZPYceqykBvTfdX7imm+ASC7GpVqq25NgpqzDIpLqSWyN/GJ4X8qIUllHqH/YfseAT X-Received: by 2002:a17:907:d311:b0:86a:2c18:e422 with SMTP id vg17-20020a170907d31100b0086a2c18e422mr2182352ejc.77.1673601412199; Fri, 13 Jan 2023 01:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601412; cv=none; d=google.com; s=arc-20160816; b=cqeSnOUV+AJbhm8QjZgK20vEGsQBT+nEOUVmv2/x7HsoHPXdrE2mkCe8cgzQaezQ/5 TPvpF9zEjW5Jhd6GYLqFSAu8FOn1RSaFxyidoOm4/FM7W93kPMVcLfQkkUiNLxhZ92ZE GJtcPVeqezuG7my17ksz1DOCkalMD0C1TtPtNXlgT0kAb5/vZciJu3QmOoSj6o0LHDHU JNL9kadEoyNlLXFEwUetXDNycCB8NxHFsbbPvqICCWsUAyNJLq8BNHDPZ5OaqOF2h7qa gnHayopgMQxxeDcB+FVqg81QkVV+j68YJkPbis8NHnstmjF03quk5TAXhn3+0P6c+Sr4 VXuA== 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=RNKQ8lij9GJnJFwIqDvh0GiiDKlQ9djpTpCO2RWvjlI=; b=S69iDtZBpProfYX19HNyxXPBk+q7T5pTbb4hp8KAvhlW98CvUgokTCUOOm1C+MBsE9 YvrSi6SUX9Ecln4mZVV+l/PTvIaF8LYxLJCO27dDx+9ksasgzfYjGYKhu668YXpp1B96 onyuAWWBoWT8kMEreTWGn5KQU68T0F2UIKfg+S8Jskunybo4mHdTo5qgnBQG5V+cdPkC qNu9qX9HuzymVx9mB9Bz3azK/zIv+EuiHKaMtFOObmrXBGAenqhZoeTpFtLvGnUAqsni ZW1XTox0g+pxasTjzN6Wf4bxvL/9AQqErO37BUmwO3PJC+is7L8oqeLXpOEonooItLr/ t7cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="S/BtqWDO"; 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 dn21-20020a17090794d500b0084b9ac8f8a3si24106265ejc.836.2023.01.13.01.16.27; Fri, 13 Jan 2023 01:16:52 -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="S/BtqWDO"; 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 S240331AbjAMJMh (ORCPT + 99 others); Fri, 13 Jan 2023 04:12:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240194AbjAMJMI (ORCPT ); Fri, 13 Jan 2023 04:12:08 -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 ESMTPS id 3C9297665 for ; Fri, 13 Jan 2023 01:09:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673600990; 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=RNKQ8lij9GJnJFwIqDvh0GiiDKlQ9djpTpCO2RWvjlI=; b=S/BtqWDOxxfubyXSZb0OPCpZgSjzTf8qZ7QUonW7LogLRpCav4stL91DxqL/zKNq2H3t7z zixc0i+VHUesauWb54ARn0UFDP4JJxWIbRdaHS/ZkuChixhoxSwrYx7aVXepsb3EFWHioy tb+tDu9sX1siU+9qXQ9GS9QXcTogXKQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-0FU3mqukMnCQOpQBZwO4bQ-1; Fri, 13 Jan 2023 04:09:45 -0500 X-MC-Unique: 0FU3mqukMnCQOpQBZwO4bQ-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 B322F1C051A8; Fri, 13 Jan 2023 09:09:44 +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 836801121314; Fri, 13 Jan 2023 09:09:42 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 2/9] selftests: hid: allow to compile hid_bpf with LLVM Date: Fri, 13 Jan 2023 10:09:28 +0100 Message-Id: <20230113090935.1763477-3-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898274447418793?= X-GMAIL-MSGID: =?utf-8?q?1754898274447418793?= clang doesn't like to compile a source to the final binary directly: clang-14: error: cannot specify -o when generating multiple output files So split the final rule in 2, and ensure we compile all dependencies before. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/hid/Makefile b/tools/testing/selftests/hid/Makefile index f6fc5cfff770..83e8f87d643a 100644 --- a/tools/testing/selftests/hid/Makefile +++ b/tools/testing/selftests/hid/Makefile @@ -91,10 +91,6 @@ $(MAKE_DIRS): $(call msg,MKDIR,,$@) $(Q)mkdir -p $@ -$(OUTPUT)/%.o: %.c - $(call msg,CC,,$@) - $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@ - # LLVM's ld.lld doesn't support all the architectures, so use it only on x86 ifeq ($(SRCARCH),x86) LLD := lld @@ -223,7 +219,11 @@ $(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)/%:%.c $(BPF_SKELS) $(KHDR_INCLUDES)/linux/hid.h +$(OUTPUT)/%.o: %.c $(BPF_SKELS) $(KHDR_INCLUDES)/linux/hid.h + $(call msg,CC,,$@) + $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@ + +$(OUTPUT)/%: $(OUTPUT)/%.o $(call msg,BINARY,,$@) $(Q)$(LINK.c) $^ $(LDLIBS) -o $@ From patchwork Fri Jan 13 09:09:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 43098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp166718wrt; Fri, 13 Jan 2023 01:15:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWBnUOTKPRhfO3rgvr6D13aw6DITumXHvZjp/tAOiSplDpSjH4w/+gw9LcpDeho6Q4r3Q6 X-Received: by 2002:a50:fc10:0:b0:49b:5a1c:9cb5 with SMTP id i16-20020a50fc10000000b0049b5a1c9cb5mr4558013edr.16.1673601311965; Fri, 13 Jan 2023 01:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601311; cv=none; d=google.com; s=arc-20160816; b=kM0h/gDzbBZD/pLebUMypiyhzlsfd+zyxIgNQZfuRdwp9LgBdLQ83eIpi54IUJG2qi TUtRtYdWCS+q6oQAnfqcn9GVQuwdvS2gobRm2TtI07FZc+lbFGLtyicH7XciTFSuYAz8 FQA3FJ3B3Xxbqptq8N85imN5kHkI8GSEWjmt30RkuatwSdZUyef71af/8cmIvjxvdK8N wO84B59c+T7+jQWGRoG5zTCdJUX8uf41Q/PM5382zqZy+RIe+eMBqV2hjoEFadqkfXvB 2TB/9PjVylWr6TOFjLidXlxyr2CzvbpP8sJik40NpK9xyD6tuACw6WP7eVle50w42VE5 zozA== 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=4Xa6rCBRJrVK1eXRuijrJkoStISh9NdDuUsF0DClMfI=; b=zwm1mG2NfeS8D6x7tI3bv+36TtXzWlaMEVOC8gq0CB5PgMh11RJUTKHYnPYxQCJb07 tPRyanNYWfIzaJ0BJGo8iw60N9AI92zN6groMjZ29khMt8io4omV1azg25n64J1/qzKs 6o/9pBiLPGXVu5HE60bgA26gB7i1BAnPuLkgtMhnCKrEAsa53AAiTB5TWYHkANmYWO5y xpmGrRELc13KmiolMY8qWPULynweZ3uCesXkcpKUodPFs40t//POSlXZjIuUZgy4ehYo P9PzTOcykdwBakktxcNLJKCaSlQbpeBbLMMV6xxZk8Yo9/farOWkf7vndPp5abKGCfMf muqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P7OSha0r; 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 t25-20020a50ab59000000b0049577a9f113si2719651edc.566.2023.01.13.01.14.46; Fri, 13 Jan 2023 01:15:11 -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=P7OSha0r; 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 S240800AbjAMJNP (ORCPT + 99 others); Fri, 13 Jan 2023 04:13:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240944AbjAMJMO (ORCPT ); Fri, 13 Jan 2023 04:12:14 -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 ESMTPS id DD500A451 for ; Fri, 13 Jan 2023 01:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673600992; 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=4Xa6rCBRJrVK1eXRuijrJkoStISh9NdDuUsF0DClMfI=; b=P7OSha0riXttQokUD1dSv7b7TEAwHqpatHdexhhxnC/ivgMetlJ2A4Jh1KcBFx4R3n7Jh9 lrfkyEgyupGyxVh9ECIH5LOMHF+BB56l9pVxz9TgjzlwHsAJF4Zvmi1GTgEZLc3x1lPh/r 1GNpIG7SR9oS+On0HB0RpkStGKShDUA= 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-617--Uo7N5OcNxi7SH9osQobYw-1; Fri, 13 Jan 2023 04:09:48 -0500 X-MC-Unique: -Uo7N5OcNxi7SH9osQobYw-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 3215D811E9C; Fri, 13 Jan 2023 09:09:47 +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 035C41121314; Fri, 13 Jan 2023 09:09:44 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 3/9] selftests: hid: attach/detach 2 bpf programs, not just one Date: Fri, 13 Jan 2023 10:09:29 +0100 Message-Id: <20230113090935.1763477-4-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898169108008049?= X-GMAIL-MSGID: =?utf-8?q?1754898169108008049?= Add a second BPF program to attach to the device, as the development of this feature showed that we also need to ensure we can detach multiple programs to a device (hid_bpf_link->hid_table_index was actually not set initially, and this lead to any BPF program not being released except for the first one). Signed-off-by: Benjamin Tissoires --- changes in v2: - rewrote commit message s/->index/->hid_table_index/ --- tools/testing/selftests/hid/hid_bpf.c | 8 +++++++- tools/testing/selftests/hid/progs/hid.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c index 6615c26fb5dd..d215bb492eb4 100644 --- a/tools/testing/selftests/hid/hid_bpf.c +++ b/tools/testing/selftests/hid/hid_bpf.c @@ -616,6 +616,7 @@ TEST_F(hid_bpf, test_attach_detach) { const struct test_program progs[] = { { .name = "hid_first_event" }, + { .name = "hid_second_event" }, }; __u8 buf[10] = {0}; int err; @@ -634,7 +635,10 @@ TEST_F(hid_bpf, test_attach_detach) ASSERT_EQ(buf[0], 1); ASSERT_EQ(buf[2], 47); - /* pin the program and immediately unpin it */ + /* make sure both programs are run */ + ASSERT_EQ(buf[3], 52); + + /* pin the first program and immediately unpin it */ #define PIN_PATH "/sys/fs/bpf/hid_first_event" bpf_program__pin(self->skel->progs.hid_first_event, PIN_PATH); remove(PIN_PATH); @@ -660,6 +664,7 @@ TEST_F(hid_bpf, test_attach_detach) ASSERT_EQ(buf[0], 1); ASSERT_EQ(buf[1], 47); ASSERT_EQ(buf[2], 0); + ASSERT_EQ(buf[3], 0); /* re-attach our program */ @@ -677,6 +682,7 @@ TEST_F(hid_bpf, test_attach_detach) ASSERT_EQ(err, 6) TH_LOG("read_hidraw"); ASSERT_EQ(buf[0], 1); ASSERT_EQ(buf[2], 47); + ASSERT_EQ(buf[3], 52); } /* diff --git a/tools/testing/selftests/hid/progs/hid.c b/tools/testing/selftests/hid/progs/hid.c index 6a86af0aa545..88c593f753b5 100644 --- a/tools/testing/selftests/hid/progs/hid.c +++ b/tools/testing/selftests/hid/progs/hid.c @@ -32,6 +32,19 @@ int BPF_PROG(hid_first_event, struct hid_bpf_ctx *hid_ctx) return hid_ctx->size; } +SEC("?fmod_ret/hid_bpf_device_event") +int BPF_PROG(hid_second_event, struct hid_bpf_ctx *hid_ctx) +{ + __u8 *rw_data = hid_bpf_get_data(hid_ctx, 0 /* offset */, 4 /* size */); + + if (!rw_data) + return 0; /* EPERM check */ + + rw_data[3] = rw_data[2] + 5; + + return hid_ctx->size; +} + SEC("?fmod_ret/hid_bpf_device_event") int BPF_PROG(hid_change_report_id, struct hid_bpf_ctx *hid_ctx) { From patchwork Fri Jan 13 09:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 43095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp166714wrt; Fri, 13 Jan 2023 01:15:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXvFqh24Wnby+1IT44ad9XLKX/vz9scSFiNyTj0tIBo7kR6dyEZSF4FRcgpCUNBpTcJ3bT6J X-Received: by 2002:a17:907:73c1:b0:7e8:cf25:4b9c with SMTP id es1-20020a17090773c100b007e8cf254b9cmr62847192ejc.59.1673601311220; Fri, 13 Jan 2023 01:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601311; cv=none; d=google.com; s=arc-20160816; b=y7yXbpwTfPJlnoEDHjkNquZaRBfkYrHmFd/X+0gjFKZ38Hm4pZd3XNHa2Weg/0BSFf 2+tt+CbZWLHOMnANKqkbdHFS2PekHAyo8LP6/dDRTeK3E5SXPaljrRiQpsV0JxQdYlox VDkWdf4YYrmlja+51eRO9IHGp/2JKRj+nOPYkvEqMZvgnz0kq3Ljx0G6aO/fAHSpUX/h fmIL/6/5WjV/YGUkfWA5UJnsNiVvkfyPf61CEksZTMyQUYSfgSBa5eNMWlR0tt2zWX1h yamKF3FHuXtPlY3PdUbwZmqN+OdPZIhv3Cs/DH0HvTSMa0kqJ2GyfF+hQrGbXJllSrRP QLPg== 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=vxQrOpngc5m5sJ3ndl/6WbG/qisMRAH+hUsUrxa1xvM=; b=PmePFY63ej3amUHdwhExUUCEn4t2mSZR2gC52QW7gaGdjr4y/coxPJRi56BKb01ubJ CAoLgkAwHTXCbeGzhcg0ZoZsUuhhdqgy/TAceKRkM7SkVGE2/8WOz6zfQHIDUbiPw7wf XKLby1D0Mpgu6RWFs3plpR35rWHMFk1575W204GeKh8VUNYXqokS2NDEcNpZh2YD/+/t D8+r55/24y2AgDQs+gTxZvI26TF9KvwOk8a4z1o71krnDGH1LVakkkgd/ZmYSl9od1wO X7VosajAVMKoaTStcB/yq62oBl3HV+Nyvr2ogPWOIG8RygQqddbkCyfg9A19JA71uNEc Ijkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PLJecUx0; 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 hr27-20020a1709073f9b00b0078dcd448f97si22768548ejc.801.2023.01.13.01.14.47; Fri, 13 Jan 2023 01:15:11 -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=PLJecUx0; 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 S241266AbjAMJNV (ORCPT + 99 others); Fri, 13 Jan 2023 04:13:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241128AbjAMJMP (ORCPT ); Fri, 13 Jan 2023 04:12:15 -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 ESMTPS id 31AD6A478 for ; Fri, 13 Jan 2023 01:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673600993; 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=vxQrOpngc5m5sJ3ndl/6WbG/qisMRAH+hUsUrxa1xvM=; b=PLJecUx0e284E3MWLfVn4iI4ZbSLFZWq8wRVk6fUj9KDr51nn8tREKmRulCrMqLD67dxE4 DaR6T6hVRLZLGLzpde6557FPae2J9ojKoppp9MJJtr/cSmqwYGWp6WdJjFKyKdYj1gtnpG 9tens7riA0ze3gPbDahRhN244emHHrc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-JHAzXNGBM9es748yubQ6Qw-1; Fri, 13 Jan 2023 04:09:50 -0500 X-MC-Unique: JHAzXNGBM9es748yubQ6Qw-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 A6BB43C16E9C; Fri, 13 Jan 2023 09:09:49 +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 778171121314; Fri, 13 Jan 2023 09:09:47 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 4/9] selftests: hid: ensure the program is correctly pinned Date: Fri, 13 Jan 2023 10:09:30 +0100 Message-Id: <20230113090935.1763477-5-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898168452356133?= X-GMAIL-MSGID: =?utf-8?q?1754898168452356133?= Turns out that if bpffs was not mounted, the test was silently passing. So ensure it passes by checking the mount command result. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c index d215bb492eb4..3b204a15e44b 100644 --- a/tools/testing/selftests/hid/hid_bpf.c +++ b/tools/testing/selftests/hid/hid_bpf.c @@ -640,7 +640,8 @@ TEST_F(hid_bpf, test_attach_detach) /* pin the first program and immediately unpin it */ #define PIN_PATH "/sys/fs/bpf/hid_first_event" - bpf_program__pin(self->skel->progs.hid_first_event, PIN_PATH); + err = bpf_program__pin(self->skel->progs.hid_first_event, PIN_PATH); + ASSERT_OK(err) TH_LOG("error while calling bpf_program__pin"); remove(PIN_PATH); #undef PIN_PATH usleep(100000); From patchwork Fri Jan 13 09:09: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: 43102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp167276wrt; Fri, 13 Jan 2023 01:16:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXsSEszlxJvZAKJWgJZ6rbW4QIqyDYVNURiQKHvFWEpz7DFKIe7xzVjZaGXivmd97QSurE0u X-Received: by 2002:a05:6402:414:b0:495:77a9:f108 with SMTP id q20-20020a056402041400b0049577a9f108mr29165580edv.39.1673601412193; Fri, 13 Jan 2023 01:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601412; cv=none; d=google.com; s=arc-20160816; b=ZMZ4EHjdMAumKc51bCSavlLc7qcJ20MZ94raTojZVeWDOQDUKg+wecZU0AM1VDMPq3 5FbY/yYAf2+UNSbu8cO8dCi45QvEiLsUmc2jhyjUK/x5EoV2ZjZsJy3SMIsogg1CYLZw t4eB69i5ThxCCzI+lLc3jjN5u2pFSiLNXu+Tg2YNxzqJHyupNHJUSIQ+aIMaIjwj/V/g 7ugS3KXftgZ/8s3jZ8WPFTMSRrJCL/mQApp6PRlPUz4oHCalCd39vF1hsejsuVs2n3Ua xrUIkf2Ie/aftz7cRERU6ua0i2OXWYml2CHP7veUZV9Gdavtnk3X8hEoJ1NBRZBYDdiP Tr7A== 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=MReTfoZEtCBJ7/7PQF8RRjqn13uVX9nIzOsfgV2wfAI=; b=HtZV8TDde/+v9mIIRc4LPzQB0uS79H2DozVPcLJ3lKMOquCioseL8pveQxKyvoYoGv dNujEcwUfV0B98RdwRwYrU8+DY4NPtakM8CyMvsBge+D/1ukU8uld8sT2x1E9b72ejgJ VMT3NcUT/0/suVNhye4ntNj+Og/vvVOHG17Tlb5TSGGxk7l94M2xbgm1zzCyEowlvjuq xzWsTi448McsZN8TxJfXAA77bOtEF7zHLrj7Z3KFxmQ7Qf0Da7gV/+keBdXCHO/ysg3k +Aiy8s2viZstD0T5IOU5bM4n7fQxkAF9v2WQx9tpTZC9hbmLs2nPN+oDjm749Mn1Xu0d XOCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rh8DIK5p; 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 h42-20020a0564020eaa00b00499c322d3b9si10571891eda.377.2023.01.13.01.16.28; Fri, 13 Jan 2023 01:16:52 -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=Rh8DIK5p; 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 S240987AbjAMJMs (ORCPT + 99 others); Fri, 13 Jan 2023 04:12:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240995AbjAMJMJ (ORCPT ); Fri, 13 Jan 2023 04:12:09 -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 ESMTPS id D2B93B1D4 for ; Fri, 13 Jan 2023 01:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673600994; 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=MReTfoZEtCBJ7/7PQF8RRjqn13uVX9nIzOsfgV2wfAI=; b=Rh8DIK5pzJeNkL0339/NsSECmyxxLAYNJjGLSSD+jkSQsj0ZONPpJ6XiqlQqtOh5N5SUUf /r5ev2cBSIAZZJuBw8Dr9ok8BOWR4c+fkqUB/pJIEYNMO1rMPUVxjKNtPXd0ckX4Z4jlnN hWrQi5YQY1kiD8FoM/BySgbbhSeDelE= 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-641-d_eDA-nsMrqEu5o1F0dG5A-1; Fri, 13 Jan 2023 04:09:52 -0500 X-MC-Unique: d_eDA-nsMrqEu5o1F0dG5A-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 28E18802C1C; Fri, 13 Jan 2023 09:09:52 +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 ECEA11121315; Fri, 13 Jan 2023 09:09:49 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 5/9] selftests: hid: prepare tests for HID_BPF API change Date: Fri, 13 Jan 2023 10:09:31 +0100 Message-Id: <20230113090935.1763477-6-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 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=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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898274794488087?= X-GMAIL-MSGID: =?utf-8?q?1754898274794488087?= We plan on changing the return value of hid_bpf_attach_prog(). Instead of returning an error code, it will return an fd to a bpf_link. This bpf_link is responsible for the binding between the bpf program and the hid device. Add a fallback mechanism to not break bisections by pinning the program when we run this test against the non changed kernel. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 29 +++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c index 3b204a15e44b..9a262fe99b32 100644 --- a/tools/testing/selftests/hid/hid_bpf.c +++ b/tools/testing/selftests/hid/hid_bpf.c @@ -444,13 +444,21 @@ FIXTURE(hid_bpf) { int hid_id; pthread_t tid; struct hid *skel; + int hid_links[3]; /* max number of programs loaded in a single test */ }; static void detach_bpf(FIXTURE_DATA(hid_bpf) * self) { + int i; + if (self->hidraw_fd) close(self->hidraw_fd); self->hidraw_fd = 0; + for (i = 0; i < ARRAY_SIZE(self->hid_links); i++) { + if (self->hid_links[i]) + close(self->hid_links[i]); + } + hid__destroy(self->skel); self->skel = NULL; } @@ -512,6 +520,9 @@ static void load_programs(const struct test_program programs[], .ctx_size_in = sizeof(args), ); + ASSERT_LE(progs_count, ARRAY_SIZE(self->hid_links)) + TH_LOG("too many programs are to be loaded"); + /* open the bpf file */ self->skel = hid__open(); ASSERT_OK_PTR(self->skel) TEARDOWN_LOG("Error while calling hid__open"); @@ -543,7 +554,10 @@ static void load_programs(const struct test_program programs[], args.hid = self->hid_id; args.insert_head = programs[i].insert_head; err = bpf_prog_test_run_opts(attach_fd, &tattr); - ASSERT_OK(args.retval) TH_LOG("attach_hid(%s): %d", programs[i].name, args.retval); + ASSERT_GE(args.retval, 0) + TH_LOG("attach_hid(%s): %d", programs[i].name, args.retval); + + self->hid_links[i] = args.retval; } self->hidraw_fd = open_hidraw(self->dev_id); @@ -619,10 +633,17 @@ TEST_F(hid_bpf, test_attach_detach) { .name = "hid_second_event" }, }; __u8 buf[10] = {0}; - int err; + int err, link; LOAD_PROGRAMS(progs); + link = self->hid_links[0]; + /* we might not be using the new code path where hid_bpf_attach_prog() + * returns a link. + */ + if (!link) + link = bpf_program__fd(self->skel->progs.hid_first_event); + /* inject one event */ buf[0] = 1; buf[1] = 42; @@ -640,8 +661,8 @@ TEST_F(hid_bpf, test_attach_detach) /* pin the first program and immediately unpin it */ #define PIN_PATH "/sys/fs/bpf/hid_first_event" - err = bpf_program__pin(self->skel->progs.hid_first_event, PIN_PATH); - ASSERT_OK(err) TH_LOG("error while calling bpf_program__pin"); + err = bpf_obj_pin(link, PIN_PATH); + ASSERT_OK(err) TH_LOG("error while calling bpf_obj_pin"); remove(PIN_PATH); #undef PIN_PATH usleep(100000); From patchwork Fri Jan 13 09:09: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: 43103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp167280wrt; Fri, 13 Jan 2023 01:16:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXsP/U2sDVwtCq2OC+BK7ydFherkZjGynrpssvJtt2qkN8xqPxqCBN7lr9siAHa5GiT901LK X-Received: by 2002:a17:906:7244:b0:86b:93ea:3366 with SMTP id n4-20020a170906724400b0086b93ea3366mr103208ejk.3.1673601413470; Fri, 13 Jan 2023 01:16:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601413; cv=none; d=google.com; s=arc-20160816; b=hIo4CGosQiH4yQOzyNme22Tgwqnq14ljzt4lh/cC5MbEZDgojeqJrs/0EVTNax8lp7 lEO7iBdS4I0OLKFxu+dvKIXJtWmKxIFn/SEPux4L/chGNrZY+CN0wsOWMuOEm/l/ZuZY sqsnGbHtCwn7k08B0xnFbUq4T/lICE7dZ909nzcLjPXorEnIfja6G2xS3/m+KDGGmVq8 mroxcwOdeocg+yMVOrDLFYOeTrvfZzF6IFKiJgzRRW+FDZgbqZOvwm2irsahc9WhNG6u AXNTzLc2y79Wil/Q/lSTLpRS2U15WhXayDAsnXymphpdfIz2X7MCI9uqJdQPFu0yP7/6 xn4w== 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=LVb5mv99X03TkOTGFYsj2OWMkCM3gjV8Eptdveyi1aE=; b=xvBgbNowvLhbrrr6fUj88RwvZiQDMg64WGzYEtTbsJt9IIPUyMDe+FLJbpVIS/dL1U oejW1BF+vzTbKHPYSrhlLPR5x3WnjcWOru1Bze6Tn1VCA7bwRnzlJQYk5TMYQbgAzuLX MGnVId+hbPHJ4z9DoXkTpngicNF6tplyJk1hJwZZhUo1jlQxea8wCRtmhVYFPCqUfq+6 6jJTeMlwTAaz7YyFIhwp3PSLOJVxJNIZgn6orttfsBbSKQmdZ44PAImYXnsBRSSkLiWI fmweLk6nVUkoI12sdGvcj4qBMFoV7aB/hFJDZc9r/Ju9A68aD/kaBJWj+aEUi1DlMuKv tjGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X0SXG3+Q; 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 h19-20020a0564020e9300b00461c7ad026csi17979203eda.61.2023.01.13.01.16.28; Fri, 13 Jan 2023 01:16:53 -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=X0SXG3+Q; 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 S241282AbjAMJN3 (ORCPT + 99 others); Fri, 13 Jan 2023 04:13:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234305AbjAMJMS (ORCPT ); Fri, 13 Jan 2023 04:12:18 -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 ESMTPS id A1D60BE0F for ; Fri, 13 Jan 2023 01:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673600998; 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=LVb5mv99X03TkOTGFYsj2OWMkCM3gjV8Eptdveyi1aE=; b=X0SXG3+QUXItCim/Ea1B4BaJeMXCo+1rGHOxDS4DetC169lHeuDOzyapA+mZjQmRqkqBnb n0GU/QUzze1oSe43t3yHe5AgxKbBECffyKHCzHUIbTXZuZi6h5nt5eo+zMffbrM2C5SeUL GQd6dSaU6LcLdwiI7byF+OMutHyZtUY= 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-635-0l8PAK4aN0yc464cH5fNOA-1; Fri, 13 Jan 2023 04:09:55 -0500 X-MC-Unique: 0l8PAK4aN0yc464cH5fNOA-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 9F55885A588; Fri, 13 Jan 2023 09:09:54 +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 6EF401121314; Fri, 13 Jan 2023 09:09:52 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 6/9] HID: bpf: rework how programs are attached and stored in the kernel Date: Fri, 13 Jan 2023 10:09:32 +0100 Message-Id: <20230113090935.1763477-7-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 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=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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898275886774729?= X-GMAIL-MSGID: =?utf-8?q?1754898275886774729?= Previously, HID-BPF was relying on a bpf tracing program to be notified when a program was released from userspace. This is error prone, as LLVM sometimes inline the function and sometimes not. So instead of messing up with the bpf prog ref count, we can use the bpf_link concept which actually matches exactly what we want: - a bpf_link represents the fact that a given program is attached to a given HID device - as long as the bpf_link has fd opened (either by the userspace program still being around or by pinning the bpf object in the bpffs), the program stays attached to the HID device - once every user has closed the fd, we get called by hid_bpf_link_release() that we no longer have any users, and we can disconnect the program to the device in 2 passes: first atomically clear the bit saying that the link is active, and then calling release_work in a scheduled work item. This solves entirely the problems of BPF tracing not showing up and is definitely cleaner. Signed-off-by: Benjamin Tissoires Acked-by: Alexei Starovoitov --- changes in v2: - renamed struct hid_bpf_link->index into struct hid_bpf_link->hid_table_index - renamed prog_idx into prog_table_idx in __hid_bpf_attach_prog() --- Documentation/hid/hid-bpf.rst | 12 ++- drivers/hid/bpf/hid_bpf_dispatch.c | 18 ++-- drivers/hid/bpf/hid_bpf_jmp_table.c | 126 +++++++++++++++------------- include/linux/hid_bpf.h | 7 ++ 4 files changed, 95 insertions(+), 68 deletions(-) diff --git a/Documentation/hid/hid-bpf.rst b/Documentation/hid/hid-bpf.rst index a55f191d49a3..c205f92b7bcc 100644 --- a/Documentation/hid/hid-bpf.rst +++ b/Documentation/hid/hid-bpf.rst @@ -427,12 +427,22 @@ program first:: prog_fd = bpf_program__fd(hid_skel->progs.attach_prog); err = bpf_prog_test_run_opts(prog_fd, &tattrs); - return err; + if (err) + return err; + + return args.retval; /* the fd of the created bpf_link */ } Our userspace program can now listen to notifications on the ring buffer, and is awaken only when the value changes. +When the userspace program doesn't need to listen to events anymore, it can just +close the returned fd from :c:func:`attach_filter`, which will tell the kernel to +detach the program from the HID device. + +Of course, in other use cases, the userspace program can also pin the fd to the +BPF filesystem through a call to :c:func:`bpf_obj_pin`, as with any bpf_link. + Controlling the device ---------------------- diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index 58e608ebf0fa..8d29fd361ab9 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -249,7 +249,9 @@ int hid_bpf_reconnect(struct hid_device *hdev) * @prog_fd: an fd in the user process representing the program to attach * @flags: any logical OR combination of &enum hid_bpf_attach_flags * - * @returns %0 on success, an error code otherwise. + * @returns an fd of a bpf_link object on success (> %0), an error code otherwise. + * Closing this fd will detach the program from the HID device (unless the bpf_link + * is pinned to the BPF file system). */ /* called from syscall */ noinline int @@ -257,7 +259,7 @@ hid_bpf_attach_prog(unsigned int hid_id, int prog_fd, __u32 flags) { struct hid_device *hdev; struct device *dev; - int err, prog_type = hid_bpf_get_prog_attach_type(prog_fd); + int fd, err, prog_type = hid_bpf_get_prog_attach_type(prog_fd); if (!hid_bpf_ops) return -EINVAL; @@ -283,17 +285,19 @@ hid_bpf_attach_prog(unsigned int hid_id, int prog_fd, __u32 flags) return err; } - err = __hid_bpf_attach_prog(hdev, prog_type, prog_fd, flags); - if (err) - return err; + fd = __hid_bpf_attach_prog(hdev, prog_type, prog_fd, flags); + if (fd < 0) + return fd; if (prog_type == HID_BPF_PROG_TYPE_RDESC_FIXUP) { err = hid_bpf_reconnect(hdev); - if (err) + if (err) { + close_fd(fd); return err; + } } - return 0; + return fd; } /** diff --git a/drivers/hid/bpf/hid_bpf_jmp_table.c b/drivers/hid/bpf/hid_bpf_jmp_table.c index 207972b028d9..b7eb5c5e435f 100644 --- a/drivers/hid/bpf/hid_bpf_jmp_table.c +++ b/drivers/hid/bpf/hid_bpf_jmp_table.c @@ -322,16 +322,6 @@ static int hid_bpf_insert_prog(int prog_fd, struct bpf_prog *prog) if (err) goto out; - /* - * The program has been safely inserted, decrement the reference count - * so it doesn't interfere with the number of actual user handles. - * This is safe to do because: - * - we overrite the put_ptr in the prog fd map - * - we also have a cleanup function that monitors when a program gets - * released and we manually do the cleanup in the prog fd map - */ - bpf_prog_sub(prog, 1); - /* return the index */ err = index; @@ -365,14 +355,46 @@ int hid_bpf_get_prog_attach_type(int prog_fd) return prog_type; } +static void hid_bpf_link_release(struct bpf_link *link) +{ + struct hid_bpf_link *hid_link = + container_of(link, struct hid_bpf_link, link); + + __clear_bit(hid_link->hid_table_index, jmp_table.enabled); + schedule_work(&release_work); +} + +static void hid_bpf_link_dealloc(struct bpf_link *link) +{ + struct hid_bpf_link *hid_link = + container_of(link, struct hid_bpf_link, link); + + kfree(hid_link); +} + +static void hid_bpf_link_show_fdinfo(const struct bpf_link *link, + struct seq_file *seq) +{ + seq_printf(seq, + "attach_type:\tHID-BPF\n"); +} + +static const struct bpf_link_ops hid_bpf_link_lops = { + .release = hid_bpf_link_release, + .dealloc = hid_bpf_link_dealloc, + .show_fdinfo = hid_bpf_link_show_fdinfo, +}; + /* called from syscall */ noinline int __hid_bpf_attach_prog(struct hid_device *hdev, enum hid_bpf_prog_type prog_type, int prog_fd, __u32 flags) { + struct bpf_link_primer link_primer; + struct hid_bpf_link *link; struct bpf_prog *prog = NULL; struct hid_bpf_prog_entry *prog_entry; - int cnt, err = -EINVAL, prog_idx = -1; + int cnt, err = -EINVAL, prog_table_idx = -1; /* take a ref on the prog itself */ prog = bpf_prog_get(prog_fd); @@ -381,23 +403,32 @@ __hid_bpf_attach_prog(struct hid_device *hdev, enum hid_bpf_prog_type prog_type, mutex_lock(&hid_bpf_attach_lock); + link = kzalloc(sizeof(*link), GFP_USER); + if (!link) { + err = -ENOMEM; + goto err_unlock; + } + + bpf_link_init(&link->link, BPF_LINK_TYPE_UNSPEC, + &hid_bpf_link_lops, prog); + /* do not attach too many programs to a given HID device */ cnt = hid_bpf_program_count(hdev, NULL, prog_type); if (cnt < 0) { err = cnt; - goto out_unlock; + goto err_unlock; } if (cnt >= hid_bpf_max_programs(prog_type)) { err = -E2BIG; - goto out_unlock; + goto err_unlock; } - prog_idx = hid_bpf_insert_prog(prog_fd, prog); + prog_table_idx = hid_bpf_insert_prog(prog_fd, prog); /* if the jmp table is full, abort */ - if (prog_idx < 0) { - err = prog_idx; - goto out_unlock; + if (prog_table_idx < 0) { + err = prog_table_idx; + goto err_unlock; } if (flags & HID_BPF_FLAG_INSERT_HEAD) { @@ -412,22 +443,32 @@ __hid_bpf_attach_prog(struct hid_device *hdev, enum hid_bpf_prog_type prog_type, /* we steal the ref here */ prog_entry->prog = prog; - prog_entry->idx = prog_idx; + prog_entry->idx = prog_table_idx; prog_entry->hdev = hdev; prog_entry->type = prog_type; /* finally store the index in the device list */ err = hid_bpf_populate_hdev(hdev, prog_type); + if (err) { + hid_bpf_release_prog_at(prog_table_idx); + goto err_unlock; + } + + link->hid_table_index = prog_table_idx; + + err = bpf_link_prime(&link->link, &link_primer); if (err) - hid_bpf_release_prog_at(prog_idx); + goto err_unlock; - out_unlock: mutex_unlock(&hid_bpf_attach_lock); - /* we only use prog as a key in the various tables, so we don't need to actually - * increment the ref count. - */ + return bpf_link_settle(&link_primer); + + err_unlock: + mutex_unlock(&hid_bpf_attach_lock); + bpf_prog_put(prog); + kfree(link); return err; } @@ -460,36 +501,10 @@ void __hid_bpf_destroy_device(struct hid_device *hdev) void call_hid_bpf_prog_put_deferred(struct work_struct *work) { - struct bpf_prog_aux *aux; - struct bpf_prog *prog; - bool found = false; - int i; - - aux = container_of(work, struct bpf_prog_aux, work); - prog = aux->prog; - - /* we don't need locking here because the entries in the progs table - * are stable: - * if there are other users (and the progs entries might change), we - * would simply not have been called. - */ - for (i = 0; i < HID_BPF_MAX_PROGS; i++) { - if (jmp_table.progs[i] == prog) { - __clear_bit(i, jmp_table.enabled); - found = true; - } - } - - if (found) - /* schedule release of all detached progs */ - schedule_work(&release_work); -} - -static void hid_bpf_prog_fd_array_put_ptr(void *ptr) -{ + /* kept around for patch readability, to be dropped in the next commmit */ } -#define HID_BPF_PROGS_COUNT 2 +#define HID_BPF_PROGS_COUNT 1 static struct bpf_link *links[HID_BPF_PROGS_COUNT]; static struct entrypoints_bpf *skel; @@ -528,8 +543,6 @@ void hid_bpf_free_links_and_skel(void) idx++; \ } while (0) -static struct bpf_map_ops hid_bpf_prog_fd_maps_ops; - int hid_bpf_preload_skel(void) { int err, idx = 0; @@ -548,14 +561,7 @@ int hid_bpf_preload_skel(void) goto out; } - /* our jump table is stealing refs, so we should not decrement on removal of elements */ - hid_bpf_prog_fd_maps_ops = *jmp_table.map->ops; - hid_bpf_prog_fd_maps_ops.map_fd_put_ptr = hid_bpf_prog_fd_array_put_ptr; - - jmp_table.map->ops = &hid_bpf_prog_fd_maps_ops; - ATTACH_AND_STORE_LINK(hid_tail_call); - ATTACH_AND_STORE_LINK(hid_bpf_prog_put_deferred); return 0; out: diff --git a/include/linux/hid_bpf.h b/include/linux/hid_bpf.h index 3ca85ab91325..e9afb61e6ee0 100644 --- a/include/linux/hid_bpf.h +++ b/include/linux/hid_bpf.h @@ -3,6 +3,7 @@ #ifndef __HID_BPF_H #define __HID_BPF_H +#include #include #include @@ -138,6 +139,12 @@ struct hid_bpf { spinlock_t progs_lock; /* protects RCU update of progs */ }; +/* specific HID-BPF link when a program is attached to a device */ +struct hid_bpf_link { + struct bpf_link link; + int hid_table_index; +}; + #ifdef CONFIG_HID_BPF u8 *dispatch_hid_bpf_device_event(struct hid_device *hid, enum hid_report_type type, u8 *data, u32 *size, int interrupt); From patchwork Fri Jan 13 09:09: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: 43096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp166716wrt; Fri, 13 Jan 2023 01:15:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXtin5jDCRez+uyNXIo/gHlCDGtufTlRf/vJGDkkjV8TfmQAFGnfHE38//vA//pn+BVKkR5G X-Received: by 2002:a17:906:7fc2:b0:838:9c66:cd2f with SMTP id r2-20020a1709067fc200b008389c66cd2fmr64739463ejs.74.1673601311492; Fri, 13 Jan 2023 01:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601311; cv=none; d=google.com; s=arc-20160816; b=ZJTarJaHER8Tl7lQYn4OaHIPwZxtA6oTFZz71MxydHqPAtgegTTe1JvGBzRvTv2Qh0 xemKTj0aE2IQvbGAv2mHQGftAebauwrOg7Og+lgSNj1BBFD5w5BRVabfNhFD8tNPR1qX TJMRS9ELQaXlPwE+PnLMpYUCt271B5u9U7kASvhPuhF/da4wbvRZe1LEDUUsmu6pLXBI 9D4UXDMz2ZH8FX1WwjNStdniSAIGJM8RCy2zEmGMMieIDhvfzCZ1eYaB7g1MekjJIAZI Mc9xJDkIbetsPfZfabDof/QS/b3QtpFVtc0tnoj4KIMh8HCR31uf2YnLTem8FOPL0AWm yqTA== 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=zSBi9fEVjxMCBgiA3KVP8rZ11VOYsIr1qRPkJekyhzo=; b=xxkaorG6tkehiK0mM9ijZLvloiKawxgHgSlv/VDnWJjyVj43NFOCHPvspZ+MVYLPpx rtpSE4qt5v3VVmoUH2evj+XyFYc4P1CUWiNNsKNyoywK4mLbGeg/wLRki1rL+dsYJZBZ J6fCWWjrsbadNHq9e/juLJe0pm5TioeDeRSU+ULmZk4TZO1q1AzOM2OygI62raMPhJYI zNt/+bkCTqxDZb8RhQqwBPObGtTRNuhNQ/Z/wzcv+82QFBSdTwhRS4+WCYBuEWwJoNc4 3oD5dV4ErZllcI0UqrXri/jEp8eFS4lxQj2xRc/nz8ZiYtkVTX2ZAjv8QHGOJ0caEdqK OvRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KTHI36SQ; 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 ds12-20020a170907724c00b007ea638b5670si19635983ejc.485.2023.01.13.01.14.47; Fri, 13 Jan 2023 01:15:11 -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=KTHI36SQ; 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 S241295AbjAMJNe (ORCPT + 99 others); Fri, 13 Jan 2023 04:13:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241130AbjAMJMW (ORCPT ); Fri, 13 Jan 2023 04:12:22 -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 ESMTPS id D304FF00E for ; Fri, 13 Jan 2023 01:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673601003; 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=zSBi9fEVjxMCBgiA3KVP8rZ11VOYsIr1qRPkJekyhzo=; b=KTHI36SQNcuSlPKQrwiL3wLhjkKg6ACK316ByHRgScm89G3nDD+xXueofY59YGH62nmYKX ne7by3J29BkHhTM97iAWwSXmn6t2HZji2hUZSoW0z3v1d+105bsbB4sl/v3ZG2ytPEsWV1 KRm+bJvLfV4i8NpHBwFfVEPE+HjumgQ= 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-357-sAL87FzoO2mhn9iSm-k3qw-1; Fri, 13 Jan 2023 04:09:57 -0500 X-MC-Unique: sAL87FzoO2mhn9iSm-k3qw-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 24862858F09; Fri, 13 Jan 2023 09:09:57 +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 E530D1121314; Fri, 13 Jan 2023 09:09:54 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 7/9] selftests: hid: enforce new attach API Date: Fri, 13 Jan 2023 10:09:33 +0100 Message-Id: <20230113090935.1763477-8-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898168727586351?= X-GMAIL-MSGID: =?utf-8?q?1754898168727586351?= Now that the new API for hid_bpf_attach_prog() is in place, ensure we get an fd when calling this function. And remove the fallback code. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c index 9a262fe99b32..2cf96f818f25 100644 --- a/tools/testing/selftests/hid/hid_bpf.c +++ b/tools/testing/selftests/hid/hid_bpf.c @@ -638,11 +638,7 @@ TEST_F(hid_bpf, test_attach_detach) LOAD_PROGRAMS(progs); link = self->hid_links[0]; - /* we might not be using the new code path where hid_bpf_attach_prog() - * returns a link. - */ - if (!link) - link = bpf_program__fd(self->skel->progs.hid_first_event); + ASSERT_GT(link, 0) TH_LOG("HID-BPF link not created"); /* inject one event */ buf[0] = 1; From patchwork Fri Jan 13 09:09:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 43099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp166925wrt; Fri, 13 Jan 2023 01:15:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCLDw9719srDQey3RQyvUG6yBxu0vYeysEDymOamFDT1Ht3mjafJ314fidxVoBWU+x9b+p X-Received: by 2002:a17:907:7650:b0:84d:1872:1256 with SMTP id kj16-20020a170907765000b0084d18721256mr24826117ejc.34.1673601347556; Fri, 13 Jan 2023 01:15:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673601347; cv=none; d=google.com; s=arc-20160816; b=fG4Zriuwy5J/Rm43PKXqn+nhOwLDKj6DNDdPIi1aRwcwBCnQBIIyDSi8nGotlGFtdr 09+hoIYA81uEEXCH54KnrqpcXOk8Hp81t/5VrS4HfAOW0EJkjQPS/iqfF15RLSQB7siz tWLAmpUy7M6oIZA3M27RuYXQHmUdkNcMYxMypjySDmJ6MM7OhAJZ68lGn0sHLDFPX4G3 N6feg198eU56D9bKb23a7mJOxmG6egRe7aui343DivdWy+bslXfB8B1VuVh2ve+JhFHt RdGAnslK1pQ/Zx2OFC78rJPCfOvFsuwI87kAEYw1PjYgqYeTRcewOXHorDjAKxzeD/wa HcDg== 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=b87icpl3/0I0/0SJoaZzj0USo5zmLgh57iacasFKKow=; b=CAKpDRcGWQQZq5s53tzlOSXCgsUGl7F6ItZ1h/bM5iORXsqtOtL4BLxQOOaIWpEq07 eyTyuo6ytvKeCHkkb+7kXnF2nCrDNIM7jkEzta7j2eUH5iDxYwEHC9l7FXsI45xYzlnn FTo/byqXxeB6MG7xW4jRzxslOznp/yoo7P0kWxEYM7+DoXesKhhGa0DuK8RHPIFGzzFI mP6I1pOJ33qmh2Y2Rnb8YYpNzPDKNRetUeLjNAdYMYVcrhCFqW0MoKNRlfBd1cl8+J2C UU8H3b4wUDJnVznmmQXt7NX2DOuvUlffVnGKs1uBZksfm3R2OyBp2CFtcCXQm1CZXfgC qBDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="PiPMCX/7"; 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 di20-20020a170906731400b00780e89ce0b0si20977034ejc.600.2023.01.13.01.15.23; Fri, 13 Jan 2023 01:15:47 -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="PiPMCX/7"; 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 S240798AbjAMJOr (ORCPT + 99 others); Fri, 13 Jan 2023 04:14:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241129AbjAMJM3 (ORCPT ); Fri, 13 Jan 2023 04:12:29 -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 ESMTPS id CAEB813DCE for ; Fri, 13 Jan 2023 01:10:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673601005; 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=b87icpl3/0I0/0SJoaZzj0USo5zmLgh57iacasFKKow=; b=PiPMCX/7lCnw1iknJWt+RfcR5QOmW8fZl2+eHLYJcdfpu3LxPVobpIePMNNj01+sp8GEKA QqaGAYADOvvzWLnkptwDqb1Ct0zlp5Z9cojhE73wMjW0w5NMwwmNaYre2LrcGTXnqfxrSe vEaJs5WpzjVNmaDclVo+eryJaVXk/1w= 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-501-tNsXq74rN16z675VHI6u0g-1; Fri, 13 Jan 2023 04:10:00 -0500 X-MC-Unique: tNsXq74rN16z675VHI6u0g-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 BD39985D064; Fri, 13 Jan 2023 09:09:59 +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 6B3161121314; Fri, 13 Jan 2023 09:09:57 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 HID for-next v2 8/9] HID: bpf: clean up entrypoint Date: Fri, 13 Jan 2023 10:09:34 +0100 Message-Id: <20230113090935.1763477-9-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754898206321623797?= X-GMAIL-MSGID: =?utf-8?q?1754898206321623797?= We don't need to watch for calls on bpf_prog_put_deferred(), so remove that from the entrypoints.bpf.c file. Signed-off-by: Benjamin Tissoires Acked-by: Alexei Starovoitov --- changes in v2: - removed unused call_hid_bpf_prog_put_deferred() Reported-by: kernel test robot --- drivers/hid/bpf/entrypoints/entrypoints.bpf.c | 9 - .../hid/bpf/entrypoints/entrypoints.lskel.h | 188 +++++------------- drivers/hid/bpf/hid_bpf_dispatch.c | 1 - drivers/hid/bpf/hid_bpf_dispatch.h | 3 - drivers/hid/bpf/hid_bpf_jmp_table.c | 5 - 5 files changed, 53 insertions(+), 153 deletions(-) diff --git a/drivers/hid/bpf/entrypoints/entrypoints.bpf.c b/drivers/hid/bpf/entrypoints/entrypoints.bpf.c index 7c1895d9e5c0..c22921125a1a 100644 --- a/drivers/hid/bpf/entrypoints/entrypoints.bpf.c +++ b/drivers/hid/bpf/entrypoints/entrypoints.bpf.c @@ -7,8 +7,6 @@ #define HID_BPF_MAX_PROGS 1024 -extern void call_hid_bpf_prog_put_deferred(struct work_struct *work) __ksym; - struct { __uint(type, BPF_MAP_TYPE_PROG_ARRAY); __uint(max_entries, HID_BPF_MAX_PROGS); @@ -24,11 +22,4 @@ int BPF_PROG(hid_tail_call, struct hid_bpf_ctx *hctx) return 0; } -SEC("fentry/bpf_prog_put_deferred") -int BPF_PROG(hid_bpf_prog_put_deferred, struct work_struct *work) -{ - call_hid_bpf_prog_put_deferred(work); - return 0; -} - char LICENSE[] SEC("license") = "GPL"; diff --git a/drivers/hid/bpf/entrypoints/entrypoints.lskel.h b/drivers/hid/bpf/entrypoints/entrypoints.lskel.h index 9ffb991b3e6f..35618051598c 100644 --- a/drivers/hid/bpf/entrypoints/entrypoints.lskel.h +++ b/drivers/hid/bpf/entrypoints/entrypoints.lskel.h @@ -12,11 +12,9 @@ struct entrypoints_bpf { } maps; struct { struct bpf_prog_desc hid_tail_call; - struct bpf_prog_desc hid_bpf_prog_put_deferred; } progs; struct { int hid_tail_call_fd; - int hid_bpf_prog_put_deferred_fd; } links; }; @@ -31,24 +29,12 @@ entrypoints_bpf__hid_tail_call__attach(struct entrypoints_bpf *skel) return fd; } -static inline int -entrypoints_bpf__hid_bpf_prog_put_deferred__attach(struct entrypoints_bpf *skel) -{ - int prog_fd = skel->progs.hid_bpf_prog_put_deferred.prog_fd; - int fd = skel_raw_tracepoint_open(NULL, prog_fd); - - if (fd > 0) - skel->links.hid_bpf_prog_put_deferred_fd = fd; - return fd; -} - static inline int entrypoints_bpf__attach(struct entrypoints_bpf *skel) { int ret = 0; ret = ret < 0 ? ret : entrypoints_bpf__hid_tail_call__attach(skel); - ret = ret < 0 ? ret : entrypoints_bpf__hid_bpf_prog_put_deferred__attach(skel); return ret < 0 ? ret : 0; } @@ -56,7 +42,6 @@ static inline void entrypoints_bpf__detach(struct entrypoints_bpf *skel) { skel_closenz(skel->links.hid_tail_call_fd); - skel_closenz(skel->links.hid_bpf_prog_put_deferred_fd); } static void entrypoints_bpf__destroy(struct entrypoints_bpf *skel) @@ -65,7 +50,6 @@ entrypoints_bpf__destroy(struct entrypoints_bpf *skel) return; entrypoints_bpf__detach(skel); skel_closenz(skel->progs.hid_tail_call.prog_fd); - skel_closenz(skel->progs.hid_bpf_prog_put_deferred.prog_fd); skel_closenz(skel->maps.hid_jmp_table.map_fd); skel_free(skel); } @@ -91,7 +75,7 @@ entrypoints_bpf__load(struct entrypoints_bpf *skel) int err; opts.ctx = (struct bpf_loader_ctx *)skel; - opts.data_sz = 3792; + opts.data_sz = 2856; opts.data = (void *)"\ \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ @@ -126,7 +110,7 @@ entrypoints_bpf__load(struct entrypoints_bpf *skel) \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x9f\xeb\x01\0\ -\x18\0\0\0\0\0\0\0\xa4\x03\0\0\xa4\x03\0\0\x54\x03\0\0\0\0\0\0\0\0\0\x02\x03\0\ +\x18\0\0\0\0\0\0\0\x60\x02\0\0\x60\x02\0\0\x12\x02\0\0\0\0\0\0\0\0\0\x02\x03\0\ \0\0\x01\0\0\0\0\0\0\x01\x04\0\0\0\x20\0\0\x01\0\0\0\0\0\0\0\x03\0\0\0\0\x02\0\ \0\0\x04\0\0\0\x03\0\0\0\x05\0\0\0\0\0\0\x01\x04\0\0\0\x20\0\0\0\0\0\0\0\0\0\0\ \x02\x06\0\0\0\0\0\0\0\0\0\0\x03\0\0\0\0\x02\0\0\0\x04\0\0\0\0\x04\0\0\0\0\0\0\ @@ -139,25 +123,14 @@ entrypoints_bpf__load(struct entrypoints_bpf *skel) \0\0\0\0\0\0\0\x1b\x01\0\0\x12\0\0\0\x40\0\0\0\x1f\x01\0\0\x10\0\0\0\x80\0\0\0\ \x2e\x01\0\0\x14\0\0\0\xa0\0\0\0\0\0\0\0\x15\0\0\0\xc0\0\0\0\x3a\x01\0\0\0\0\0\ \x08\x11\0\0\0\x40\x01\0\0\0\0\0\x01\x04\0\0\0\x20\0\0\0\0\0\0\0\0\0\0\x02\x13\ -\0\0\0\0\0\0\0\0\0\0\x0a\x2d\0\0\0\x4d\x01\0\0\x04\0\0\x06\x04\0\0\0\x5d\x01\0\ +\0\0\0\0\0\0\0\0\0\0\x0a\x1c\0\0\0\x4d\x01\0\0\x04\0\0\x06\x04\0\0\0\x5d\x01\0\ \0\0\0\0\0\x6e\x01\0\0\x01\0\0\0\x80\x01\0\0\x02\0\0\0\x93\x01\0\0\x03\0\0\0\0\ \0\0\0\x02\0\0\x05\x04\0\0\0\xa4\x01\0\0\x16\0\0\0\0\0\0\0\xab\x01\0\0\x16\0\0\ -\0\0\0\0\0\xb0\x01\0\0\0\0\0\x08\x02\0\0\0\0\0\0\0\x01\0\0\x0d\x02\0\0\0\x5f\0\ -\0\0\x0b\0\0\0\xec\x01\0\0\x01\0\0\x0c\x17\0\0\0\0\0\0\0\x01\0\0\x0d\0\0\0\0\ -\x49\x03\0\0\x1a\0\0\0\0\0\0\0\0\0\0\x02\x1b\0\0\0\x8c\x02\0\0\x03\0\0\x04\x20\ -\0\0\0\x98\x02\0\0\x1c\0\0\0\0\0\0\0\x9d\x02\0\0\x22\0\0\0\x40\0\0\0\xa3\x02\0\ -\0\x24\0\0\0\xc0\0\0\0\xa8\x02\0\0\0\0\0\x08\x1d\0\0\0\xb6\x02\0\0\0\0\0\x08\ -\x1e\0\0\0\0\0\0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ff\x01\0\0\x01\0\0\x0f\x04\0\0\0\x19\0\0\0\0\0\0\0\x04\0\0\0\x07\ +\x02\0\0\0\0\0\x07\0\0\0\0\0\x69\x6e\x74\0\x5f\x5f\x41\x52\x52\x41\x59\x5f\x53\ \x49\x5a\x45\x5f\x54\x59\x50\x45\x5f\x5f\0\x74\x79\x70\x65\0\x6d\x61\x78\x5f\ \x65\x6e\x74\x72\x69\x65\x73\0\x6b\x65\x79\x5f\x73\x69\x7a\x65\0\x76\x61\x6c\ \x75\x65\x5f\x73\x69\x7a\x65\0\x68\x69\x64\x5f\x6a\x6d\x70\x5f\x74\x61\x62\x6c\ @@ -182,119 +155,64 @@ entrypoints_bpf__load(struct entrypoints_bpf *skel) \x5f\x5f\x73\x33\x32\0\x30\x3a\x30\0\x09\x62\x70\x66\x5f\x74\x61\x69\x6c\x5f\ \x63\x61\x6c\x6c\x28\x63\x74\x78\x2c\x20\x26\x68\x69\x64\x5f\x6a\x6d\x70\x5f\ \x74\x61\x62\x6c\x65\x2c\x20\x68\x63\x74\x78\x2d\x3e\x69\x6e\x64\x65\x78\x29\ -\x3b\0\x68\x69\x64\x5f\x62\x70\x66\x5f\x70\x72\x6f\x67\x5f\x70\x75\x74\x5f\x64\ -\x65\x66\x65\x72\x72\x65\x64\0\x66\x65\x6e\x74\x72\x79\x2f\x62\x70\x66\x5f\x70\ -\x72\x6f\x67\x5f\x70\x75\x74\x5f\x64\x65\x66\x65\x72\x72\x65\x64\0\x69\x6e\x74\ -\x20\x42\x50\x46\x5f\x50\x52\x4f\x47\x28\x68\x69\x64\x5f\x62\x70\x66\x5f\x70\ -\x72\x6f\x67\x5f\x70\x75\x74\x5f\x64\x65\x66\x65\x72\x72\x65\x64\x2c\x20\x73\ -\x74\x72\x75\x63\x74\x20\x77\x6f\x72\x6b\x5f\x73\x74\x72\x75\x63\x74\x20\x2a\ -\x77\x6f\x72\x6b\x29\0\x09\x63\x61\x6c\x6c\x5f\x68\x69\x64\x5f\x62\x70\x66\x5f\ -\x70\x72\x6f\x67\x5f\x70\x75\x74\x5f\x64\x65\x66\x65\x72\x72\x65\x64\x28\x77\ -\x6f\x72\x6b\x29\x3b\0\x77\x6f\x72\x6b\x5f\x73\x74\x72\x75\x63\x74\0\x64\x61\ -\x74\x61\0\x65\x6e\x74\x72\x79\0\x66\x75\x6e\x63\0\x61\x74\x6f\x6d\x69\x63\x5f\ -\x6c\x6f\x6e\x67\x5f\x74\0\x61\x74\x6f\x6d\x69\x63\x36\x34\x5f\x74\0\x63\x6f\ -\x75\x6e\x74\x65\x72\0\x73\x36\x34\0\x5f\x5f\x73\x36\x34\0\x6c\x6f\x6e\x67\x20\ -\x6c\x6f\x6e\x67\0\x6c\x69\x73\x74\x5f\x68\x65\x61\x64\0\x6e\x65\x78\x74\0\x70\ -\x72\x65\x76\0\x77\x6f\x72\x6b\x5f\x66\x75\x6e\x63\x5f\x74\0\x63\x61\x6c\x6c\ -\x5f\x68\x69\x64\x5f\x62\x70\x66\x5f\x70\x72\x6f\x67\x5f\x70\x75\x74\x5f\x64\ -\x65\x66\x65\x72\x72\x65\x64\0\x63\x68\x61\x72\0\x4c\x49\x43\x45\x4e\x53\x45\0\ -\x2e\x6b\x73\x79\x6d\x73\0\x2e\x6d\x61\x70\x73\0\x6c\x69\x63\x65\x6e\x73\x65\0\ -\x68\x69\x64\x5f\x64\x65\x76\x69\x63\x65\0\x64\x75\x6d\x6d\x79\x5f\x6b\x73\x79\ -\x6d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x10\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x03\ +\x3b\0\x63\x68\x61\x72\0\x4c\x49\x43\x45\x4e\x53\x45\0\x2e\x6d\x61\x70\x73\0\ +\x6c\x69\x63\x65\x6e\x73\x65\0\x68\x69\x64\x5f\x64\x65\x76\x69\x63\x65\0\0\0\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x8a\x04\0\0\0\0\0\0\0\0\0\0\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\0\0\0\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\x5f\ \x5f\x68\x69\x64\x5f\x62\x70\x66\x5f\x74\x61\x69\x6c\x5f\x63\x61\x6c\x6c\0\0\0\ -\0\0\x47\x50\x4c\0\0\0\0\0\x79\x11\0\0\0\0\0\0\x85\x20\0\0\0\0\0\0\xb7\0\0\0\0\ -\0\0\0\x95\0\0\0\0\0\0\0\0\0\0\0\x18\0\0\0\0\0\0\0\x8e\0\0\0\x23\x02\0\0\x05\ -\x70\0\0\x01\0\0\0\x8e\0\0\0\x65\x02\0\0\x02\x78\0\0\x02\0\0\0\x8e\0\0\0\x23\ -\x02\0\0\x05\x70\0\0\x1a\0\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ -\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x68\x69\x64\x5f\x62\x70\x66\x5f\x70\ -\x72\x6f\x67\x5f\x70\x75\0\0\0\0\0\x18\0\0\0\0\0\0\0\x08\0\0\0\0\0\0\0\0\0\0\0\ -\x01\0\0\0\x10\0\0\0\0\0\0\0\0\0\0\0\x03\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ -\0\0\0\0\0\0\0\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\x62\x70\x66\x5f\x70\x72\x6f\x67\ -\x5f\x70\x75\x74\x5f\x64\x65\x66\x65\x72\x72\x65\x64\0\0\0\x63\x61\x6c\x6c\x5f\ -\x68\x69\x64\x5f\x62\x70\x66\x5f\x70\x72\x6f\x67\x5f\x70\x75\x74\x5f\x64\x65\ -\x66\x65\x72\x72\x65\x64\0\0"; - opts.insns_sz = 2056; +\0\0"; + opts.insns_sz = 1192; opts.insns = (void *)"\ \xbf\x16\0\0\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01\0\0\x78\xff\xff\xff\xb7\x02\0\ -\0\x88\0\0\0\xb7\x03\0\0\0\0\0\0\x85\0\0\0\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0\xb7\x01\0\0\x05\0\0\0\x18\x62\0\0\ +\0\0\0\0\0\0\0\0\x80\x0a\0\0\xb7\x03\0\0\x8c\0\0\0\x85\0\0\0\xa6\0\0\0\xbf\x07\ +\0\0\0\0\0\0\x18\x60\0\0\0\0\0\0\0\0\0\0\xf0\x0a\0\0\x61\x01\0\0\0\0\0\0\xd5\ +\x01\x02\0\0\0\0\0\xbf\x19\0\0\0\0\0\0\x85\0\0\0\xa8\0\0\0\xc5\x07\x7f\xff\0\0\ +\0\0\x63\x7a\x80\xff\0\0\0\0\x61\xa1\x78\xff\0\0\0\0\xd5\x01\x02\0\0\0\0\0\xbf\ +\x19\0\0\0\0\0\0\x85\0\0\0\xa8\0\0\0\x61\xa0\x80\xff\0\0\0\0\x63\x06\x28\0\0\0\ +\0\0\x18\x61\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x61\x10\0\0\0\0\0\0\x63\x06\x18\0\0\0\ +\0\0\xb7\0\0\0\0\0\0\0\x95\0\0\0\0\0\0\0"; err = bpf_load_and_run(&opts); if (err < 0) return err; diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index 8d29fd361ab9..26117b4ec016 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -173,7 +173,6 @@ hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr * can use. */ BTF_SET8_START(hid_bpf_kfunc_ids) -BTF_ID_FLAGS(func, call_hid_bpf_prog_put_deferred) BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL) BTF_SET8_END(hid_bpf_kfunc_ids) diff --git a/drivers/hid/bpf/hid_bpf_dispatch.h b/drivers/hid/bpf/hid_bpf_dispatch.h index 2eeab1f746dd..63dfc8605cd2 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.h +++ b/drivers/hid/bpf/hid_bpf_dispatch.h @@ -22,7 +22,4 @@ int hid_bpf_reconnect(struct hid_device *hdev); struct bpf_prog; -/* HID-BPF internal kfuncs API */ -void call_hid_bpf_prog_put_deferred(struct work_struct *work); - #endif diff --git a/drivers/hid/bpf/hid_bpf_jmp_table.c b/drivers/hid/bpf/hid_bpf_jmp_table.c index b7eb5c5e435f..eca34b7372f9 100644 --- a/drivers/hid/bpf/hid_bpf_jmp_table.c +++ b/drivers/hid/bpf/hid_bpf_jmp_table.c @@ -499,11 +499,6 @@ void __hid_bpf_destroy_device(struct hid_device *hdev) schedule_work(&release_work); } -void call_hid_bpf_prog_put_deferred(struct work_struct *work) -{ - /* kept around for patch readability, to be dropped in the next commmit */ -} - #define HID_BPF_PROGS_COUNT 1 static struct bpf_link *links[HID_BPF_PROGS_COUNT]; From patchwork Fri Jan 13 09:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 43104 Return-Path: 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 + 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 ); 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 ; 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 To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Dmitry Torokhov 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 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 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: 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?= 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 Acked-by: Alexei Starovoitov --- no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; }