Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2030378rwb; Wed, 30 Nov 2022 01:04:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7SJgBc1gtF8HJ9lSNXB7+s3R+ezkZwp2dnDTHLz98Ld7rFloFFLDVhFxessaszipjkvIEX X-Received: by 2002:a05:6402:2409:b0:45c:935b:ae15 with SMTP id t9-20020a056402240900b0045c935bae15mr32580178eda.357.1669799055154; Wed, 30 Nov 2022 01:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669799055; cv=none; d=google.com; s=arc-20160816; b=PWBozzKx8cQW6q1qJOMhF0YujaW5NNXizDG3vfm0WyhnyuYK+oAMYhDZ46Ghk7fzOO 4HMG7XiLZUrTuW8ZMvbJWE8+C8QIxzVR+4livGgDZudc7NoAl6bewn5vB/6WSgY5WX0I atWsJmSyq5O71iI3RXP46JQk6p/SVtRQcByGxRuFctNuez5ezaLtqQhlbIJkAIw6/ZLX Dpjzf+hPK6d0VTOztEDXxj8bhn5cs6F3LdzzYMLHRcC9gLpnzU80b4qeCN9Jw5lKHk78 ilq7+kMPdCvHAJzMhOZRZ/2Z+pMxic98cqYF0dILsOghaHJs39i4aDHZ8139eNugXPcb +DXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xANXvbQ7iywMEyVlB4xJE5gylEi2EmdID1HL+8vvXPE=; b=slsl+TKf4mQfc71owiwjqT6vWLqHaOWXDTmbcd9+3yEBByPTFKMdPIUkxJRUIzgOR7 wvtjNHe7ykR+m5yVkj2aXTmnzCxYHFdsdjHyPvYhP+gGHi/6Q4uD9u1uQLMy9QN3ocZH UEA26dIsCuAxswhe58DQL4s/aUCao3sBr0gMprBPhLw5gW/yMU8b6ptkrAE22xp62bZ0 b3+fXC2FQ/OfvhHf8mVq7PPR9bJCU1R9sHG5hFDiFzPWiiwFZcIacJ/tYDv8V+vKoqng EOHuENJoxJsPWZZ4pglQErBRzwN5LujH6MhfQAh5lVxfRP9AiIRTljpsVBjRQAwO3hDg SfUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="PxZyN/eC"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a170906b00d00b0077fc66b581esi561555ejy.688.2022.11.30.01.03.53; Wed, 30 Nov 2022 01:04:15 -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="PxZyN/eC"; 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 S234406AbiK3Iu2 (ORCPT + 85 others); Wed, 30 Nov 2022 03:50:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234464AbiK3IuZ (ORCPT ); Wed, 30 Nov 2022 03:50:25 -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 E74BA2981D for ; Wed, 30 Nov 2022 00:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669798169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xANXvbQ7iywMEyVlB4xJE5gylEi2EmdID1HL+8vvXPE=; b=PxZyN/eC3+mCkrwvSLGUbQ8yNBTLufUh1mglHN4SGUmv1OWG4g4LQt8p+FSPRvgAqMZpvm 2R0jUc1dIPgCCgmuWw/DdpPQuCIXowQpYrvqtbjcd9zeb4eTH1pSXoGpWcBL7cOEuPypBL tsW1zz0bJ7r1+0Gfnuqwcbgu6xwUa9Y= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-638-zZI-usHNPLqw4EYCeP0LoA-1; Wed, 30 Nov 2022 03:49:28 -0500 X-MC-Unique: zZI-usHNPLqw4EYCeP0LoA-1 Received: by mail-il1-f197.google.com with SMTP id x10-20020a056e021bca00b00302b6c0a683so14963911ilv.23 for ; Wed, 30 Nov 2022 00:49:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xANXvbQ7iywMEyVlB4xJE5gylEi2EmdID1HL+8vvXPE=; b=Fso4f0CBC2xAj2a44EEVRpSYqNiw1gD/ACra8Xht33Ju/cXabjHRFge6WNN34vZFC5 q4wT5tvkmyOxAq7C+f4FZzVaKVxhOpvH0wYqhIS/oYU2eTcY1j82mbfsKddecVMyxWXQ o2pnG6396dPnWzD5SLKf4kSYKL3Fh8VzBAQxvFITqu8Q0MIbHIGNxdpxaaEvdfnOM5/Q soAwzkgo+rgaAR8OU9a4I+ax4mwtw6yhp3ugEoCisN2lqJ/9kGV5Jqen5/2ZbzKADPVv ecVjGh3QioLxds0nhi9GEnxcb5loOy0gvUEZ5HpdSiwsIkntCq2CuYbewWlHO+vwZ8Gd gsig== X-Gm-Message-State: ANoB5pmr1Di+vFXKJBq2nMk1SrT2rAHCbPFC1rHYz/QvwtJmZ1i84lP6 5zbZZnS3cwEYuOaTUJFVeEPx5UXD0t41sXq2hi6ed0lBvORVFm8jMz55cTkD/U9TdrsGsu81Mun kJ5Sa37wYERcl3YWOY8xwWDi0R5nDxvTnUzp/wOZB X-Received: by 2002:a02:c737:0:b0:375:1c5f:3127 with SMTP id h23-20020a02c737000000b003751c5f3127mr19645304jao.251.1669798167861; Wed, 30 Nov 2022 00:49:27 -0800 (PST) X-Received: by 2002:a02:c737:0:b0:375:1c5f:3127 with SMTP id h23-20020a02c737000000b003751c5f3127mr19645276jao.251.1669798167237; Wed, 30 Nov 2022 00:49:27 -0800 (PST) MIME-Version: 1.0 References: <20221103155756.687789-1-benjamin.tissoires@redhat.com> <20221103155756.687789-4-benjamin.tissoires@redhat.com> In-Reply-To: From: Benjamin Tissoires Date: Wed, 30 Nov 2022 09:49:16 +0100 Message-ID: Subject: Re: [PATCH hid v12 03/15] HID: initial BPF implementation To: Florent Revest Cc: Alexei Starovoitov , Mark Rutland , KP Singh , Jon Hunter , Greg KH , Jiri Kosina , Jonathan Corbet , Shuah Khan , Tero Kristo , LKML , "open list:HID CORE LAYER" , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" , "linux-tegra@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 29, 2022 at 7:00 PM Florent Revest wrote: > > On Thu, Nov 24, 2022 at 4:50 PM Benjamin Tissoires > wrote: > > > > On Wed, Nov 23, 2022 at 9:14 PM Alexei Starovoitov > > wrote: > > > > > > On Wed, Nov 23, 2022 at 6:53 AM Benjamin Tissoires > > > wrote: > > > > > > > > Hi Jon, > > > > > > > > On Wed, Nov 23, 2022 at 2:25 PM Jon Hunter wrote: > > > > > > > > > > We have a kernel test that checks for new warning and error messages on > > > > > boot and with this change I am now seeing the following error message on > > > > > our Tegra platforms ... > > > > > > > > > > WARNING KERN hid_bpf: error while preloading HID BPF dispatcher: -13 > > > > > > > > > > I have a quick look at the code, but I can't say I am familiar with > > > > > this. So I wanted to ask if a way to fix this or avoid this? I see the > > > > > code returns 0, so one option would be to make this an informational or > > > > > debug print. > > > > > > > > I am not in favor of debug in that case, because I suspect it'll hide > > > > too much when getting a bug report. Informational could do, yes. > > > > > > > > However, before that, I'd like to dig a little bit more on why it is > > > > failing. I thought arm64 now has support of tracing bpf programs, so I > > > > would not expect this to fail. > > We have BPF trampolines on arm64 already but no ftrace direct calls > right now. (so trampolines get jitted but don't get called eheh :)) So > indeed BPF tracing programs (fentry/fexit/fmod_ret) do not work on > arm64 at the moment. Oh, OK. Thanks for the explanation. > > > > Unfortunately the patches to add support for such tracing bpf progs got stuck. > > > Florent/Mark can probably share the latest status. > > We are working on an implementation of ftrace direct calls that would > fit within the constraints of arm64 and play nice with the other users > of the ftrace call site. Hopefully we have a patch to share in the > next couple of weeks I'd say! yay! > > > Oh... I noticed Jon's config was lacking CONFIG_FTRACE. So should I > > also add a depends on CONFIG_FTRACE to enable HID-BPF? > > If HID-BPF fundamentally depends on a fmod_ret program being attached > to function, it seems to me that it should depend on both: > CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS (CONFIG_FTRACE or even > CONFIG_DYNAMIC_FTRACE aren't enough, there can be architectures that > do not support direct calls. here you noticed it on arm64 which > luckily should get fixed someday soon but there could be other > architectures with that issue too) > and OK > CONFIG_FUNCTION_ERROR_INJECTION (since [1] error injection needs > to be explicitly opted-in, it's easy to miss it and fail to attach > fmod_ret programs in mysterious ways) Ok as well. > > I'm thinking that maybe encoding these two dependencies in the > CONFIG_HID_BPF is leaking too much of the bpf tracing abstraction to > the user. Maybe the BPF Kconfig could provide "proxy" configs like > HAVE_BPF_FENTRY_FEXIT, HAVE_BPF_FMOD_RET (naming is hard) to expose > these dependencies better ? That would be nice, but requires some sort of synchronization between our 2 trees, so I'll take the 2 configs in the HID tree, and try to submit a patch for the bpf tree with the macro. Then I can reattach to that macro when it hits Linus'. > > 1: https://lore.kernel.org/lkml/20221121104403.1545f9b5@gandalf.local.home/ > That thread is a little bit worrying to me. HID-BPF relies on CONFIG_FUNCTION_ERROR_INJECTION, and I would definitely like to see HID-BPF in production kernels. I don't really care about cloud servers, but chromebooks are something I'd like to have enabled. We'll see how this thread goes I guess. Anyway, thanks a lot for the deep explanation and understanding of my code :) Cheers, Benjamin