Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2052839iob; Fri, 20 May 2022 00:12:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ8ItX236YLVy0FnWWoX412QvQkjtp1r6cUf+g25mQ6XvmsVfN/B/J3oH0mtFcDU/Jt6zc X-Received: by 2002:a05:6402:3485:b0:427:cde4:2097 with SMTP id v5-20020a056402348500b00427cde42097mr9458666edc.264.1653030752025; Fri, 20 May 2022 00:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653030752; cv=none; d=google.com; s=arc-20160816; b=eMM3T4AaweM9dkUMf+PAnd91szIMHA2uN3ibiXoJsZuJ+x4CVN3e3TWHNNo89EDLS/ lb+KAWZlVgTNHOGz1taHLE4L0B9pcCrCXwpmQy/4HLkHHrpskethzEad9VeCoZjuXk/o Ex04iJeg2CEV1UMEXNH/RB/ZPIqT+AisjQdLh6VgIdRg5OYCFJ5Dal98erhhWh9EY51g Y4C/AgFBA8zs1unDVyEJAfbssx3L/ogikqDBOvjJpj8z31Pr6LibRO7qZg/OitANjAog YOUzPtjPwVYXWYE6jyFhx8y5lIcGDvQoLWQP9F7ubnzKj8F9LRHyNTCQ5Uoz70nivmYQ fdeg== 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=GSpkaZjpG+wr9/klHZRZ2SJRW1tcfr1HJfk966Tzpq8=; b=N/A4YGdt5SYqvBhMHfo5JhfDcioSv87ZXg6zm6jCNoFbp6b7rkssfJbqWoidhnu7Lq 16aQh+cH2lYaHHHtN/gULwIHkPkbAgGZsrL9HgwJz2uYBTW++KMf/g/1FjnoQmQVc6fs A+c03pYbIGSxaqmQFjPDkfpATkrExLIRnF+Gcj/kujyJOeEhIfo6SGwV6e4t4jGHOXL7 LYCYVa8Ek0g5HGaxNVYOBy95L+K2+XdVxqvFT9sjBI8XHoze1mfr8e3+5SB0hoRoReC1 WKoKv74eew1cZTwLZrDhGxNOsFh25fKo1V5+Cosb9aw2gRwvuXhTYKm1nDVJsr6/wfiS 5/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OLe8A5nm; 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 l17-20020a056402255100b0042aeb920563si1653361edb.43.2022.05.20.00.12.05; Fri, 20 May 2022 00:12:32 -0700 (PDT) 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=OLe8A5nm; 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 S237596AbiESLqu (ORCPT + 99 others); Thu, 19 May 2022 07:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229878AbiESLqi (ORCPT ); Thu, 19 May 2022 07:46:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB06D60A95 for ; Thu, 19 May 2022 04:46:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652960793; 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=GSpkaZjpG+wr9/klHZRZ2SJRW1tcfr1HJfk966Tzpq8=; b=OLe8A5nmF45CHu9F560R5KMoJMuMVa5+SSAJxO94FCsAXAYI6UujmpHw81Jij5WiiU7lHg F5CLeFO2JyoZ1Da/IpLKkBbDGSNuQo23WZLZ0SJO3hAJf/cuyqNKJ2EhVsbi/JbckGDqKH VYPhPM94BvylVR7WdTN3BSqqF83CqAo= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-JS2AgIvqPlyl38ixthzUdA-1; Thu, 19 May 2022 07:46:32 -0400 X-MC-Unique: JS2AgIvqPlyl38ixthzUdA-1 Received: by mail-pl1-f200.google.com with SMTP id x23-20020a170902b41700b0015ea144789fso2486319plr.13 for ; Thu, 19 May 2022 04:46:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GSpkaZjpG+wr9/klHZRZ2SJRW1tcfr1HJfk966Tzpq8=; b=WfIS/N+GAMv+LoVLPtfH4j1Vzdp4BdenpqXSH6ZAkpLjaGBcdYaeDACMm5eF7UYzo+ p3UwLAJIhTEJdwTuhgdVNBvn50LWq1J8VxfL6PrFueOYf42xr9Rsz2kp3pcOLZD4PqXR V5AAUmq/4qlYgcUezmGrKLI+GlaRSj3Yz/yFplndhC9ZRPv/LEvurTZFjX9QeLGIMybT zdFTPL6bJQJlWtLSZsQ2D4ba5/X5B/M1T+hDebbR7ASHyLizy/y0UMC2Z6zWHxk2gqYH hY1Qru+28QhADeZDdwjoMS0Z59ndVUA2ikmPvA3Ov8qHMSmMOV/6dyaIjCNmS2LQ8pgU w9Tg== X-Gm-Message-State: AOAM532NSt69KBe95ctuKSoawokxrcVIqLlTM0iLhn8CzUIty6gUjq+D /WtS5g969tWOUVu3D7r86j33jx4bQiaRg/Nzb8TlHYdDFQrVa1xziyr8NzzOrbIQqkagxOxA0M4 4FvOCvoZ+dMrwtzU/Xtn3C/UatZiSeDI8qi7YcCJ3 X-Received: by 2002:a17:903:22c6:b0:15f:14e1:1518 with SMTP id y6-20020a17090322c600b0015f14e11518mr4389715plg.116.1652960791499; Thu, 19 May 2022 04:46:31 -0700 (PDT) X-Received: by 2002:a17:903:22c6:b0:15f:14e1:1518 with SMTP id y6-20020a17090322c600b0015f14e11518mr4389693plg.116.1652960791232; Thu, 19 May 2022 04:46:31 -0700 (PDT) MIME-Version: 1.0 References: <20220518205924.399291-1-benjamin.tissoires@redhat.com> In-Reply-To: From: Benjamin Tissoires Date: Thu, 19 May 2022 13:46:19 +0200 Message-ID: Subject: Re: [PATCH bpf-next v5 00/17] Introduce eBPF support for HID devices To: Greg KH Cc: Christoph Hellwig , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Jonathan Corbet , Tero Kristo , lkml , "open list:HID CORE LAYER" , Networking , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Doc Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Thu, May 19, 2022 at 12:32 PM Greg KH wrote: > > On Thu, May 19, 2022 at 01:38:58AM -0700, Christoph Hellwig wrote: > > On Thu, May 19, 2022 at 10:20:35AM +0200, Greg KH wrote: > > > > are written using a hip new VM? > > > > > > Ugh, don't mention UDI, that's a bad flashback... > > > > But that is very much what we are doing here. > > > > > I thought the goal here was to move a lot of the quirk handling and > > > "fixup the broken HID decriptors in this device" out of kernel .c code > > > and into BPF code instead, which this patchset would allow. > > > > > > So that would just be exception handling. I don't think you can write a > > > real HID driver here at all, but I could be wrong as I have not read the > > > new patchset (older versions of this series could not do that.) > > > > And that "exception handling" is most of the driver. > > For a number of "small" drivers, yes, that's all there is as the > hardware is "broken" and needs to be fixed up in order to work properly > with the hid core code. An example of that would be hid-samsung.c which > rewrites the descriptors to be sane and maps the mouse buttons properly. > > But that's it, after initialization that driver gets out of the way and > doesn't actually control anything. From what I can tell, this patchset > would allow us to write those "fixup the mappings and reports before the > HID driver takes over" into ebpf programs. > > It would not replace "real" HID drivers like hid-rmi.c that has to > handle the events and do other "real" work here. > > Or I could be reading this code all wrong, Benjamin? You get it right. hid-rmi is a good example of something that can not sanely be done with eBPF. We can do some filtering on the events (dropping one event, changing one other), but anything outside that would not be possible. This driver does a lot of scheduling, synchronisation, and various setup that would require a lot of back and forth between userspace and BPF/kernel, which makes it definitively not fit for a BPF implementation. > > But even if it would allow us to write HID drivers as ebpf, what is > wrong with that? It's not a licensing issue (this api is only allowed > for GPL ebpf programs), it should allow us to move a bunch of in-kernel > drivers into smaller ebpf programs instead. The one thing I also like with eBPF is that it is safe. When you declare an array of bytes, the verifier enforces we don't go outside of the boundaries. I know rust is coming, but compared to plain C, that is much better, even if more restrictive. And it will also prevent some potential bugs where we have a report fixup that writes outside of the reserved memory. > > It's not like this ebpf HID driver would actually work on any other > operating system, right? I guess Microsoft could create a gpl-licensed > ebpf HID layer as well? As Windows allows vendors to do all of this > horrible HID fixups in userspace today anyway, I strongly doubt they > would go through the effort to add a new api like this for no valid > reason. OTOH, managing to push Microsoft to implement HID-BPF would be some achievement :) (just kidding). Cheers, Benjamin