Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2320614rdb; Mon, 20 Nov 2023 08:00:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwiD0QaDzwDguZBOnEWveblJJva6YKNnwtuZlbOxbjuoJntVEd2iemModVJKYnPNwioOn6 X-Received: by 2002:a17:90b:1e46:b0:285:3482:5cb8 with SMTP id pi6-20020a17090b1e4600b0028534825cb8mr1170585pjb.4.1700496034384; Mon, 20 Nov 2023 08:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700496034; cv=none; d=google.com; s=arc-20160816; b=i+SdzZlS/5DQDEGvUX65vZeVQYHg27Xp8/wgg0HevqeKOaLcy2C4N48q/6fsfhm/+j kJKslpWkFjHaR4OeT9P/5ewt4/AFDNTdY+mA8Mj2FRSS8ijFSfoSEN7OH4V46fJZYNDG knewDr67eAiGseYS5yjj3OnyFrzlQ4SwddvAce+pibzYzDhrJlUvWXV3qV2ZcyqvaGfI 6lkfpEje7FpEs2r5EI8b7s6HzhpgQj9yN8Ke52MpRrLDBkIIEF9/x09xOQPutQOw09QY +oXfYJr0BggP8AjjVmakS6eMdSoN2GeQSf6+LqY+WVdoZG1+DVj7aUP5xFZe2pzP/LhC 3Rpg== 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-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=oGHosGSu29j4EnbPxYYEuFvEX0yrbNZzWjtFhlk/JMQ=; fh=NRG8GCaFwMrJ2x4GQ7m8HL+kd5U6kcGgye6JBjOvgnU=; b=j7S3f5sqP152R785kBNNEfBsz4uzodVy1dYiQilI9XiCvf/4AoA0fXjeCG2dWTdtw2 c3oSQkE2h2uA/wRfkqdRmhNFGwPLuqmRNH14o/74uNaJvDjgKQT/psOqP7v+zKBCQZD8 gI1CwmDIYayN0uTMC4n41M+4FOuKaJJV06XEUhzEKGLlvO7Iov4oQ3XVG0FSaU8PUQjU x3xiZWpkBdxPMqmSklpq4b7dcyB+XkHMHE3gE80uE99QJTrgmjQ3bd8dQlWpNjEE12KC QmU0VPqn6YHLzswikYqqzi7s50nf6+gg4fL/GcYpZJkSwiRiWcmMLbkuiwFx2SE5ATfK fV5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=i9gIV6rV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id si16-20020a17090b529000b00285157db48dsi4616333pjb.181.2023.11.20.08.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:00:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=i9gIV6rV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id A0F9D8051908; Mon, 20 Nov 2023 08:00:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233171AbjKTQAM (ORCPT + 99 others); Mon, 20 Nov 2023 11:00:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233195AbjKTQAK (ORCPT ); Mon, 20 Nov 2023 11:00:10 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF78AA7; Mon, 20 Nov 2023 08:00:06 -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-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oGHosGSu29j4EnbPxYYEuFvEX0yrbNZzWjtFhlk/JMQ=; b=i9gIV6rVlwloPazJ+Gh33k97ew 0wPexOGHhjKWYUEwEjw1POG5MXviv3p2Dkvb2qeyXjSmlnnhHgHlBH+E7R8wKUCIzo2/zvmWBMwaJ fnXYE9gSYCylpexiN4VQRb9khJeYh02DF7L3xvwuLFQIekfP8h0jfeyN7yOA24TMykQrnAtO1dxjT w8fLibW3mVqjCwfQgrygjUGG+Ox1dfH2SY75SrJll27kTkmzlprK0V4r78PEDoQzaXMa8t/reXbqC zEO66Gkhz80gnyn6hUOT5Nvx3XJIyrBd1wGclGsUZ3VFpdhb8EaNx3A4tJXn7nb8jf8SBgd0f0YpF lkG7cDbw==; 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 1r56gS-004iwW-P0; Mon, 20 Nov 2023 15:59:36 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 6677D300419; Mon, 20 Nov 2023 16:59:36 +0100 (CET) Date: Mon, 20 Nov 2023 16:59:36 +0100 From: Peter Zijlstra To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, davem@davemloft.net, dsahern@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, Arnd Bergmann , samitolvanen@google.com, keescook@chromium.org, nathan@kernel.org, ndesaulniers@google.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arch@vger.kernel.org, llvm@lists.linux.dev, jpoimboe@kernel.org, joao@overdrivepizza.com, mark.rutland@arm.com Subject: Re: [PATCH 2/2] x86/cfi,bpf: Fix BPF JIT call Message-ID: <20231120155936.GY8262@noisy.programming.kicks-ass.net> References: <20231120144642.591358648@infradead.org> <20231120154948.708762225@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231120154948.708762225@infradead.org> 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 08:00:29 -0800 (PST) On Mon, Nov 20, 2023 at 03:46:44PM +0100, Peter Zijlstra wrote: > @@ -2935,9 +3009,9 @@ struct bpf_prog *bpf_int_jit_compile(str > jit_data->header = header; > jit_data->rw_header = rw_header; > } > - prog->bpf_func = (void *)image; > + prog->bpf_func = (void *)image + ctx.prog_offset; > prog->jited = 1; > - prog->jited_len = proglen; > + prog->jited_len = proglen - ctx.prog_offset; // XXX? > } else { > prog = orig_prog; > } Note the XXX there, I wasn't sure what the desired semantics of proglen was. As implemented it is the length from where bpf_func points to the end, not including the pre-preamble -- as indicated by offset.