From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="S1ntypyX" 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> Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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.