Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2582588rdb; Fri, 8 Dec 2023 12:19:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbWw5BeHxdM8gPQ5vwcELPIIUfSyoN2N9EDLiR1Ez0K0LL1o7RYhkI3Nn1Xyox+Wa4Hxqg X-Received: by 2002:a17:90a:d790:b0:286:7da5:6555 with SMTP id z16-20020a17090ad79000b002867da56555mr637340pju.50.1702066758861; Fri, 08 Dec 2023 12:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702066758; cv=none; d=google.com; s=arc-20160816; b=xEeJ/ANK+URXqWSLwWFcmDrHt6c6ZGUMMFALbnNsQoeh5q1vbcZ5OxYbwWgwMmaH7E 8mFEJ0xLKB7EJw1QMQ3crPGhPTqYf9ybDhrU/3+UATuFIkB0F8W/VHK/UAFMJrTOwIPb a47JyAAAC41U3JK3i3/dee0+F1jEDGEj69QTWA3p18nQWFGkqtJuHREUi16eT3ORRogr fIenG+0d8vpC+e5mK39J19kLkruLhcjdT0e4CKXkHa/bEeM7KaOg7cX72Cq8Ru9t1ebz 3W4a+2h8nujScvf89Ru1ewVhRwGRxAhK3r8iH/hRbTLhbJJ8EPBwrY7mb8eC9ANz+fI7 35BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rRfUKKpVJaX2GBwm20UFJtXdCC5Gt18eCCN9NLFBXGg=; fh=31pHNESfIDSRXSirSss2cSA7Q2Y3tA2WaWyHSS2Dgno=; b=awy+rMaOKsWdAv3Rt22+FkgLgV4TyI/90VTMV1hF6iIvnmAbg6mM/KDb6YenRxZppH Qcptmjp2gajwfpJr+oqrS2g7wJ4cWejwdseh2/BOfWe4+BZZd9I26xMlATAYc7SNVUQD tyz0IXBQjlgW/DGfyoD/pOKvLfSE5UGyMup9haF6UBsVUphyI9JQCKlbuSQmi1ZHb33f 6SKGim6N3WgQA9QDFup5BrhN0hiobJmBFfGqgn3c18o4dpa6tK6TLwqsSzQewoTibiYf LYFg14bv6DcECsSWwH/lcBVU0lww/wOkyKc55v0TbAPWLCwM3Hf5zNFixx+cbqy5cy9d VaaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=S1ntypyX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id iq9-20020a17090afb4900b00286b27599desi3430578pjb.15.2023.12.08.12.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 12:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=S1ntypyX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9D55C83B64C7; Fri, 8 Dec 2023 12:19:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233919AbjLHUTE (ORCPT + 99 others); Fri, 8 Dec 2023 15:19:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjLHUTD (ORCPT ); Fri, 8 Dec 2023 15:19:03 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B82C123; Fri, 8 Dec 2023 12:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=rRfUKKpVJaX2GBwm20UFJtXdCC5Gt18eCCN9NLFBXGg=; b=S1ntypyXXnH5/Zhmllff4W7CqE zvKEGCwpJiV6CNOuMqcAx4RdNPWtDIz2wWfgO64jF9VTQsJPihe7ZgsJ5Aui0fouYWgOcD9MnMek/ Qw0qaDYlc8wkXBNuBNMpvKGH1proCkWQ7owqEVwrXCdttqYkXESI6larGqgZwhg9OBfBUOQtOI/29 x071uzp8HcuHIXHZAB0KuEs0TbzqucgbaSkUc/nB5qIR+l6CS7NooXMW1vzUQHxDz0ebc3/9JpYtW cVJqlZa1MBgZfaxao7Q0joX1+LKJW8Lf1KS/RKmyC2puCXnf8JHhnhKq7CsotPXpzzlAbIkfFuetu UOGg6Fiw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1rBhIi-006Ud2-EY; Fri, 08 Dec 2023 20:18:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 5BE5B3003F0; Fri, 8 Dec 2023 21:18:19 +0100 (CET) Date: Fri, 8 Dec 2023 21:18:19 +0100 From: Peter Zijlstra To: Alexei Starovoitov Cc: Jiri Olsa , Song Liu , Song Liu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , "David S. Miller" , David Ahern , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Arnd Bergmann , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , linux-riscv , LKML , Network Development , bpf , linux-arch , clang-built-linux , Josh Poimboeuf , Joao Moreira , Mark Rutland Subject: Re: [PATCH v2 2/2] x86/cfi,bpf: Fix BPF JIT call Message-ID: <20231208201819.GE36716@noisy.programming.kicks-ass.net> References: <20231204183354.GC7299@noisy.programming.kicks-ass.net> <20231206163814.GB36423@noisy.programming.kicks-ass.net> <20231206183713.GA35897@noisy.programming.kicks-ass.net> <20231207093105.GA28727@noisy.programming.kicks-ass.net> <20231208102940.GB28727@noisy.programming.kicks-ass.net> <20231208134041.GD28727@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 08 Dec 2023 12:19:16 -0800 (PST) On Fri, Dec 08, 2023 at 11:32:07AM -0800, Alexei Starovoitov wrote: > On Fri, Dec 8, 2023 at 5:41 AM Peter Zijlstra wrote: > > > > On Fri, Dec 08, 2023 at 11:29:40AM +0100, Peter Zijlstra wrote: > > > The only problem I now have is the one XXX, I'm not entirely sure what > > > signature to use there. > > > > > @@ -119,6 +119,7 @@ int bpf_struct_ops_test_run(struct bpf_p > > > op_idx = prog->expected_attach_type; > > > err = bpf_struct_ops_prepare_trampoline(tlinks, link, > > > &st_ops->func_models[op_idx], > > > + /* XXX */ NULL, > > > image, image + PAGE_SIZE); > > > if (err < 0) > > > goto out; > > > > Duh, that should ofcourse be something of dummy_ops_test_ret_fn type. > > Let me go fix that. > > Right. That should work. > A bit wasteful to generate real code just to read hash from it > via cfi_get_func_hash(), but it's a neat idea. Right, bit wasteful. But the advantage is that I get a structure with pointers that exactly mirrors the structure we're writing. > I guess it's hard to get kcfi from __ADDRESSABLE in plain C > and sprinkling asm("cfi_xxx: .long __kcfi_typeid..."); is worse? > Even if it's a macro ? I can try this, but I'm not sure it'll be pretty. Even if I wrap it in a decent macro, I still get to define a ton of variables and then wrap the lot into a structure -- one that expects function pointers. I'll see how horrible it will become.