From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA165C43461 for ; Mon, 14 Sep 2020 19:25:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 856AF206DC for ; Mon, 14 Sep 2020 19:25:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E2osNeXw"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NufJBOf/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 856AF206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=V2yno3gAJYCkN7WRUY+Hb7l+EH/25g/CJ1Zi8EH2/UM=; b=E2osNeXwNOdx9/IBRUJzOWfY4 MbiojpUkA0OXZcTqBJXumLnFTszplhjS6/bLV8dRTI/SOKZA4bHWuXQEH1OmV6+LR+T4GxSAuvFNI jB17MIAVYuCa9fmRiIatXKPzubSKJ2ZG/bN2IYTDGaCzB9Ug+zeLCYL7/Q8CmfAORrCFeevEOSePU vqh3A/8gsc4y2BZG8BmnYKo5/y8cslKJQaBd2tCAeudTxYNnFryroH0l1KJs0acBk1l5tZh4pe7M7 1uAnno2JQtKyekeTJpx+LKO1sH7CgQiAIhTnElCLs/CnQumAaPunrcEGJ+BHlqfTYja5TT6IiKpXG 0pdpRpO+w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHu5G-0000x8-8y; Mon, 14 Sep 2020 19:24:14 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHu5E-0000wY-2a for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 19:24:13 +0000 Received: by mail-wm1-x342.google.com with SMTP id w2so1120017wmi.1 for ; Mon, 14 Sep 2020 12:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GGDNGPz53jgjUxkKKetTXhXWNvLgdULWZECcE+Svp2E=; b=NufJBOf/E8NSsdIG8e8b5H0IeV+0Slk/9hNZeoq5bbabzJZedrlt3VEn7pryX3kMkq +CH15314AzGYpQ6LrnFATXjZn5Pm6aVxlW7PkWhz4ImJs2nMciZs1JvFIyaQD29ggZJd I1RJ1DN+nAGX09eAWy0dLmqgoD60IGFQounoNTK0xpMvyv5iIz6MJuykjkPIhdWd0DcZ aw28WXewFpIMSzpAzy19jH1FgcSfiPvObOlqxIwaPBiF18gBIGwn+dOHURzao4zB7tkC I6NPDhfdUfoTDmBa7yNqzajtnMFw8yB50Nx6PkUrm3YqYnsD5WRFEEyYw6gBOGnLKscn haMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GGDNGPz53jgjUxkKKetTXhXWNvLgdULWZECcE+Svp2E=; b=mfjhajcO3iMFTBqUwXojvW7iqbu6LDk/9fOhz+EccACxbUL4K+VRiTNkrtLQ2/i6YW c1cCjoXjnU3lMofmYvSMzWXlK13OhpumTVEZL+Smk4/uiQuqnunxaGmUGN8egqh8td0E JGc+L8bWrnTammxT8cWf1p01PGUKBalp2pTNoUHtNKgOM5GuMIPSWTOBw2dp4fjNjgZy Rcfu1b/ikX2U7Z3GQ5l8/u7km9MWGIlnAtFWOWFFFL4jjU37z3S1SsI7JhBoIsYr7quk VJgXFOG3cyXZS15KnYp5wVDSXH3wqbXXYBKG3lgxyo1yCWcR4aFBboGk8KZlgB6Wnrp/ NRhw== X-Gm-Message-State: AOAM533FmPyAdu99u3CmiXrao7raxjwtL4Yuyn7tZSFSstkO1X9OzAlA /3EC4DIGM91nobIlBjAinRscsg== X-Google-Smtp-Source: ABdhPJwoKyKG7QEPLSdyBzQxXAayezkFW+nM2ot6KrfPzWSu+EEBDrVGIsCiLs7Rg1qzM5hkOewswA== X-Received: by 2002:a1c:c90d:: with SMTP id f13mr881140wmb.25.1600111450968; Mon, 14 Sep 2020 12:24:10 -0700 (PDT) Received: from apalos.home (athedsl-246545.home.otenet.gr. [85.73.10.175]) by smtp.gmail.com with ESMTPSA id t15sm20771064wmj.15.2020.09.14.12.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 12:24:10 -0700 (PDT) Date: Mon, 14 Sep 2020 22:24:07 +0300 From: Ilias Apalodimas To: Xi Wang Subject: Re: [PATCH] arm64: bpf: Fix branch offset in JIT Message-ID: <20200914192407.GB22481@apalos.home> References: <20200914123504.GA124316@apalos.home> <20200914132350.GA126552@apalos.home> <20200914140114.GG24441@willie-the-truck> <20200914181234.0f1df8ba@carbon> <20200914170205.GA20549@apalos.home> <20200914175516.GA21832@apalos.home> <20200914182756.GA22294@apalos.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_152412_384295_16F4D060 X-CRM114-Status: GOOD ( 23.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , Catalin Marinas , Alexei Starovoitov , Will Deacon , ardb@kernel.org, Jean-Philippe Brucker , Anders Roxell , Daniel Borkmann , naresh.kamboju@linaro.org, John Fastabend , Zi Shen Lim , Jakub Kicinski , Andrii Nakryiko , Jesper Dangaard Brouer , Luke Nelson , Jesper Dangaard Brouer , Yonghong Song , KP Singh , linux-arm-kernel@lists.infradead.org, Yauheni Kaliuta , netdev@vger.kernel.org, Linux Kernel Mailing List , "David S. Miller" , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , bpf@vger.kernel.org, Martin KaFai Lau Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 14, 2020 at 11:52:16AM -0700, Xi Wang wrote: > On Mon, Sep 14, 2020 at 11:28 AM Ilias Apalodimas > wrote: > > Even if that's true, is any reason at all why we should skip the first element > > of the array, that's now needed since 7c2e988f400 to jump back to the first > > instruction? > > Introducing 2 extra if conditions and hotfix the array on the fly (and for > > every future invocation of that), seems better to you? > > My point was that there's no inherently correct/wrong way to construct > offsets. As Luke explained in his email, 1) there are two different > strategies used by the JITs and 2) there are likely similar bugs > beyond arm64. > > Each strategy has pros and cons, and I'm fine with either. I like the > strategy used in your patch because it's more intuitive (offset[i] is > the start of the emitted instructions for BPF instruction i, rather > than the end), though the changes to the construction process are > trickier. > Well the arm64 was literally a 'save the idx before building the instruction', and add another element on the array. So it's not that trickier, especially if we document it properly. I haven't checked the rest of the architectures tbh (apart from x86). I assumed the tracking used in arm64 at that point, was a result of how eBPF worked before bounded loops were introduced. Maybe I was wrong. It felt a bit more natural to track the beginning of the emitted instructions rather than the end. > If we decide to patch the arm64 JIT the way you proposed, we should > consider whether to change other JITs consistently. I think this is a good idea. Following the code is not exactly a stroll in the park, so we can at least make it consistent across architectures. Thanks /Ilias _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel