Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2602335rdb; Fri, 8 Dec 2023 13:04:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1my4ce/ueCQXNl003c4bgwCeDZCBVeWFvc+O45m15INHBj8PTugSCaczdlpVfRCn2U/nz X-Received: by 2002:a17:902:f68b:b0:1cf:cd35:f823 with SMTP id l11-20020a170902f68b00b001cfcd35f823mr754619plg.65.1702069489519; Fri, 08 Dec 2023 13:04:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702069489; cv=none; d=google.com; s=arc-20160816; b=TMY7cYMxmX//NDoNaIspWMYdBErZGzTI/tgQ1tRFGCYA6082QmngHz0zBesL7fvV+j Oz+M+ISQsBFc4c3FHpoW6FoLr/51Q2mRLzFI8lqtsJJ/2Y5/rcOz8ev6cPz9kkMs60Ve juuZELFDkyGczdABbkzScda4QJvMjmINHfekTpEsukZzzlpi5ohojTWeHBVYfvkQgpEw w6IkeoOGl2NX9EgCXIK2ApCj+J0pHmrJNlUZq8yuOG3+ZK0LeNI7V/97wlpiuWog5eq6 KLbsTb66jvogCbvYc8feKBl6648rMvuve1d5WVuP395o3sbxl3Xc+OpmDJRzMSiHdav+ 3dww== 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=D6NtR+oTUIOd2AHKXBfJVs3VbzXFOw3VtZb1y+6tew0=; fh=fQgCWRvTCP/t++nK1ImfffmCDgAeoMpK4D1rM2RjSwU=; b=EzsWPDpfnZMP4dvVRmpqxOLDVTmacz51OVO4OS8OlyGhUn1SukIXNLF5U4kSXAbZol hCKlGgnxb2Sc9HWNFkSoDAeNyVkHZFEkgWJeM7k2T2dlapHsKysBsDm5nOqG+9ClPxLM kdcXfrpAtJMgMI0oTwRqNgwzetNS7fzwOC4hmkkrz8Jjw71Af6kBxEIZf6EZXYKezb7S a0rDHBC+cNyuDOnf77FM77yxz6fFqfVzXyKA8X5nMwxAp4+J75N4EfkeSzIjPvNCDV5C TKIYWQVNRMtM4D5RgensGW0EkhEDZ/tYIG175DNocS2ZBsWnZNAtX+fEth/G4JD+Tb84 NdRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a6D3M7CD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w17-20020a170902e89100b001cf75b042fesi2225384plg.52.2023.12.08.13.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 13:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a6D3M7CD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id A94F38359384; Fri, 8 Dec 2023 13:04:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574757AbjLHVEa (ORCPT + 99 others); Fri, 8 Dec 2023 16:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjLHVE3 (ORCPT ); Fri, 8 Dec 2023 16:04:29 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D3DBD; Fri, 8 Dec 2023 13:04:35 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40c19467a63so28048995e9.3; Fri, 08 Dec 2023 13:04:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702069474; x=1702674274; 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=D6NtR+oTUIOd2AHKXBfJVs3VbzXFOw3VtZb1y+6tew0=; b=a6D3M7CDcqiuZtCqTSvzJ7k8oed6Ew4yV2mX/vdl94cgE9gPgYLYvw3M61+WxNlU5E cZlq3U14wS/5i54nyxlv2fHwZAQ9RZXXZQOXlkpfxxyUZn+FEU68FzJIOjwD3yT3ykQQ Y/J7NK4NNiemwdlUFFmmlIVBalIESJaUhv49VoxhXvPBg+d45bLAVNkEbOQ0brasAwyz 6Fz2QzllfTtYVOnEeWDW1fo8mIeVzXVJ42wmS/mXiSgUW/SxsXzYPnpX9/jjRFg40v3m 5ZoWSCzeSv4FUfH7leiB6ZnnNU8rGP18gtGDmkn+bYluKJFa9FzEGRwSA+eJDXTOG/eG FOQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702069474; x=1702674274; 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=D6NtR+oTUIOd2AHKXBfJVs3VbzXFOw3VtZb1y+6tew0=; b=QI+Q0/by4A4Jak8lYYiz9Lqx5MxRshGmOxdRsdfZIWm4RdhM/62ZPJt1vpEZ687sIN xGz+u6+tZVVArL6zoeQAk114zIDB0SY7ISo/Y9zYCpnxZxkcDCNlOi94zyR8DLF9Ps66 9wyB8UoIjOtcbe80usyy7CYc7FV1Gb9X2QUxDNNsxSxlOCi5RrUFuhjmiB3lKpXxobQM RfEnKrYgkINkneEu7c6Tu74UG0oQt982xSpnpu+RwFwyZB/uRP7wQF8eP7/4Oj5FO/Vu XkPIJr6Z/RvIk2WImVcvd2BVO2/RgmxZ1Fto3kdDfkPeBP1rHk5xcTeH3ZBvSunX93EF 9eSg== X-Gm-Message-State: AOJu0Yz8j5O7YcuPMDor7aFvpeXW4qhcXjAsmAak+zt9ii7c13KhdfqR kGOf0HDQn1lDbIaDGRVrM2LyzgGjY+LQpXhQxwI= X-Received: by 2002:a1c:4c0a:0:b0:40c:2ad3:1aed with SMTP id z10-20020a1c4c0a000000b0040c2ad31aedmr288910wmf.35.1702069473424; Fri, 08 Dec 2023 13:04:33 -0800 (PST) MIME-Version: 1.0 References: <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> <20231208205647.GL28727@noisy.programming.kicks-ass.net> In-Reply-To: <20231208205647.GL28727@noisy.programming.kicks-ass.net> From: Alexei Starovoitov Date: Fri, 8 Dec 2023 13:04:22 -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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 08 Dec 2023 13:04:42 -0800 (PST) On Fri, Dec 8, 2023 at 12:56=E2=80=AFPM Peter Zijlstra wrote: > > On Fri, Dec 08, 2023 at 12:45:51PM -0800, Alexei Starovoitov wrote: > > > 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, > > But then how do I index this array? The bpf_ops_stubs thing having the > same layout at the target struct made it easy and we could use 'moff' > for both. > > That also remains working if someone adds a member to the struct or > moves some members around. I was thinking to just moff/2 assuming u32 array will have the same order, but I missed the fact that init() and release() in tcp_congestion_ops come after some variables. And you're right it's more fragile when things change in tcp_congestion_ops= . Storing u32 hash as (void *) into function pointers is just ugly. Let's go with your initial approach.