Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2594070rdb; Fri, 8 Dec 2023 12:46:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHASElDiSazIebSMUwjqvC/jZQVzzTse28adxchtxz1Jghj/WRmnoI5ZkeuK8WVxT1RjxiU X-Received: by 2002:a17:90b:4a87:b0:28a:3c6:d861 with SMTP id lp7-20020a17090b4a8700b0028a03c6d861mr598467pjb.73.1702068391097; Fri, 08 Dec 2023 12:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702068391; cv=none; d=google.com; s=arc-20160816; b=mhoFjT2MZXcNGzhuiJNOz8AwayFsIBOIets3xENj2/j5KhDZ08/27xmkXsdxIdBFqX sUvTHRG6+0cf6+un4PTanfSI5c0zP9m17kz24+IKUlSaxIYO2iiIgCloX2Acfv62GSZP NzAcDHL/JlJM2fV7rD7q2QbSfY6Iho9I9lf/OI66a/RGJtJoRp5paSmJZFTsE4XbLnmq BNq+jzA4dt3vNalRGwxdIDifQIDJpe282v8HLgTp2H7FPzPdLchz0f2olKhO+6agnxsX D3stMop/uUD9g+3VqMoPVHwwIOSZbUDqxBxPiDWulaILZvabm0ouaoCrefZGNx6SbW19 GxMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jlXQF//AUsnwP+nKFBoybb7LMYNoRVOQuSpa/LCcRfc=; fh=fQgCWRvTCP/t++nK1ImfffmCDgAeoMpK4D1rM2RjSwU=; b=xp7XQ4chKIQ9GRm4EHCjlvRrqPqcHWaJEfilDVq2afUJYA1GZa5mNBXH4EkyOir4f2 ajSYChLrci0+bcEiNqu2T9VuEBzLHgD95GlQkqyBNPVurQRyZ/0yb3+J8sqNijH/wzpU hrTaJldbI1KcvLa2tUgwbWuws0CiecOZcWD8TwEVL+j7AC9zrMZF15iLCn0gc3pks9nb 7F1OgtNyjL/reib80JjBUnKd7yDfePMLnZ1NbQaJn4jaNxxN+Exk9a6aMQv5rSma4xAK aAAMQUBnu5TiICSROo7GTIQZe2X4E34RQsz9/c+YlS8ZH7FffobuPrQzMG58oHqLlkkO 7f5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jrNzYc0p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id nn16-20020a17090b38d000b00286bba72e5fsi3534209pjb.16.2023.12.08.12.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 12:46:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jrNzYc0p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 28E7B81F964F; Fri, 8 Dec 2023 12:46:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234276AbjLHUqG (ORCPT + 99 others); Fri, 8 Dec 2023 15:46:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574749AbjLHUp7 (ORCPT ); Fri, 8 Dec 2023 15:45:59 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F1B2171F; Fri, 8 Dec 2023 12:46:04 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3332f1512e8so2251245f8f.2; Fri, 08 Dec 2023 12:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702068363; x=1702673163; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jlXQF//AUsnwP+nKFBoybb7LMYNoRVOQuSpa/LCcRfc=; b=jrNzYc0pkY3bULNGlQPZ2lwdx0VJOCSAb5ChltHPy5hu8S+WwIeKGHOGv38nueJZD1 uqb6vocK5sV7fU0MSUX7UGM2TrHWB9NBKUOU07dJSHR4ybqEw07MP9ThP5Zcj4THj6kE QixdSW/hgX/v6/MYW06oxWSFdyyMJkD+VxASGxuhshR7iwruKEWIPCCq4soTGFX1ussO lvpFUUe7s18gfWt81/5SF7lAKyyVsPi9xa5/Bj00miNzBOPfX02G+3ddHtWf/upaij0g Bagu/jzHD1DYsGSimLKc2azsckmWOB0jggBVYz7xuSfPrK8TZzp+VdnYKNkszVoyFw9m zwsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702068363; x=1702673163; h=content-transfer-encoding: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=jlXQF//AUsnwP+nKFBoybb7LMYNoRVOQuSpa/LCcRfc=; b=uf2EuK5KW8B/gAH6NdaP2xD7h40ZkoJEE+8tOY0uBiF+4SvCyZOyz9wd6c2Ef9d8iZ XEbZnYJjvSxZSZrgstnsWSFmeT6nEyKYxDHqCe+XAKCwbM0+2fqniR3YgbbPI3LFu7DO qok/sCBGcjH/n93aHqU4iFxVPqOQhu+n+Iu0fjj3WUd6d1gi6iurjhhSQZtrGxID3MnZ nXv+LHLmazPW3NSxZOlG47mONjCIpuitAtbEc9LjSmmM7MtRuLJhZB1LxQN9zUoBhlSU NChMSTvBtXo/Fmx9tlpnbUjMhmxJasiPzz6X1shTZxtPgyjYR2GuiS/UcIqE5vDssCbG kezg== X-Gm-Message-State: AOJu0Ywl4AZSbm7MU0BZdoW3HvEygJgvhLc055IY7sZ8KbgZLGbV5LYJ WkaTHFRNPtlqk4snqDDhGOP0th+UGO4Zt+GXr4Y= X-Received: by 2002:a5d:457b:0:b0:333:129d:239 with SMTP id a27-20020a5d457b000000b00333129d0239mr393721wrc.0.1702068362601; Fri, 08 Dec 2023 12:46:02 -0800 (PST) MIME-Version: 1.0 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> <20231208201819.GE36716@noisy.programming.kicks-ass.net> In-Reply-To: <20231208201819.GE36716@noisy.programming.kicks-ass.net> From: Alexei Starovoitov Date: Fri, 8 Dec 2023 12:45:51 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] x86/cfi,bpf: Fix BPF JIT call To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 12:46:27 -0800 (PST) On Fri, Dec 8, 2023 at 12:18=E2=80=AFPM Peter Zijlstra wrote: > > On Fri, Dec 08, 2023 at 11:32:07AM -0800, Alexei Starovoitov wrote: > > On Fri, Dec 8, 2023 at 5:41=E2=80=AFAM 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 w= hat > > > > signature to use there. > > > > > > > @@ -119,6 +119,7 @@ int bpf_struct_ops_test_run(struct bpf_p > > > > op_idx =3D prog->expected_attach_type; > > > > err =3D bpf_struct_ops_prepare_trampoline(tlinks, link, > > > > &st_ops->func_models[= op_idx], > > > > + /* XXX */ NULL, > > > > image, image + PAGE_S= IZE); > > > > 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. I mean we don't need to store a pointer to a func in stubs. Can it be, roughly: extern void bpf_tcp_ca_cong_avoid(struct sock *sk, u32 ack, u32 acked); KCFI_MACRO(hash_of_cong_avoid, bpf_tcp_ca_cong_avoid); u32 __array_of_kcfi_hash[] =3D {hash_of_cong_avoid, hash_of_set_state,...}; .bpf_ops_stubs =3D __array_of_kcfi_hash,