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 E5A6FC43461 for ; Mon, 14 Sep 2020 18:38:28 +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 8C92C208DB for ; Mon, 14 Sep 2020 18:38:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WYQjjilh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KKdrh2C8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C92C208DB 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=JEhqr4VGIftqOQ80SylzFZ80kVLIUuhbsKQIEThldXg=; b=WYQjjilhQmvROfd+JHKpxAKe9 UBdsbMFby5YGGeUil4WCSWQmjpUv+OgHWVpgRL+jNjSBa5vsP5guCRTyjBEa9/v905/yWhjg3Qsv+ prku/KGW6agNxr8irXRWmmsAx50v6YopXtdEiXsOfnmODmT4IGwLelEU0BWgWYPByujK1FUdZRb4D pa+67RddWDRA5bTeMG9uDjOw2vSsNZSWEhlnq9udS6FGjtYuoobjoZOGl0kUHgzu5ruLn2/2zuDBo 1D7t4GAsb9g9/snmk2EvdDvc9sxF/a4hOhSO1NNpwbmUkQB5OJL+0S9ZFuJEY5cJfa8X7uyqv9A2S enQj6QFpQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHtLb-00056X-9p; Mon, 14 Sep 2020 18:37:03 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHtLY-000567-EU for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 18:37:01 +0000 Received: by mail-wr1-x442.google.com with SMTP id j2so694835wrx.7 for ; Mon, 14 Sep 2020 11:36:59 -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:content-transfer-encoding:in-reply-to; bh=bcg5MkV7GMo2scuAb1zfDS6UH6+o9K/re2iSmd6wbvs=; b=KKdrh2C8zETXi47pwmmq3wEd9qac/F6YSAv5uRZ7jSCDYcAyhLJcuJqobL/R53Cd+D zj7B6TEZd79dp1G678VQ4G6l4FHSijlJx63WwgYXA3+jU/gjp7p/QKtcBTs82AWmrXQW gPeFKkdlD4YfWcgM8M2RFiyGHuBmwqzAtIlqCDDu3/mHD8CZOUKG3LpYGoc28yIFIQEi niIvmnDw084uEREF6MVGDESR4+9AUVPpl9vCTXuQiO/m75I14vLk34qYthRLr6pAlglv bkEqpn9VoYtEzwuC0yc0JLTKPTLz+IDS5A0H8T5gYkgD56BWA1uoZ6sD5uWGzarAgKE4 ogwg== 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:content-transfer-encoding :in-reply-to; bh=bcg5MkV7GMo2scuAb1zfDS6UH6+o9K/re2iSmd6wbvs=; b=txQCJDeSFNKpAanuPrsPw3LBXK0SV4KaN0x+YxYYWLtUklKox1hngOVVw3nC5n2IJ/ GH6ccp4G1X6m5v/16Js4zeBplERGRlvLf7KuGgu9PTFSjPcxdhuv8diOVS8wfIwe/tsX 08or6o3FnMtVr8DRsUwYgQvZYuSFMWKDK/35vlk1b9/fRpkV1ijyc1DqNWVhsJymmu0d wxHOPsVfSKDtN3652nyPCwZ5BijaDBXq8ywBh6FMmAMUMyNluK7aJePdK8Hkh89ooJNc eGvUcrWkXHbDMi3rce2KMgTK4i0uULCEAtOzXIM8S4BSgXRo83Jhs0Cu1yl4uzvGPgzQ +obg== X-Gm-Message-State: AOAM533NY0yV/9KN8fbsr77ZZBKX2P5EwIcfRaKa25Y6XVuzWxjj8fia cggjZMNANtFizoArYOGb9JGeNQ== X-Google-Smtp-Source: ABdhPJy0gpOVhE8x8dTv7A+XKUHITZMMmF32ReDMzwzwrkbFovspL6Bq2nYmj1jvbsD2AfiXK7cJoA== X-Received: by 2002:adf:f492:: with SMTP id l18mr18076356wro.280.1600108619101; Mon, 14 Sep 2020 11:36:59 -0700 (PDT) Received: from apalos.home (athedsl-246545.home.otenet.gr. [85.73.10.175]) by smtp.gmail.com with ESMTPSA id s11sm21977314wrt.43.2020.09.14.11.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 11:36:58 -0700 (PDT) Date: Mon, 14 Sep 2020 21:36:55 +0300 From: Ilias Apalodimas To: Luke Nelson Subject: Re: [PATCH] arm64: bpf: Fix branch offset in JIT Message-ID: <20200914183655.GA22481@apalos.home> References: <20200914122042.GA24441@willie-the-truck> <20200914123504.GA124316@apalos.home> <20200914132350.GA126552@apalos.home> <20200914140114.GG24441@willie-the-truck> <20200914181234.0f1df8ba@carbon> <20200914170205.GA20549@apalos.home> <20200914175516.GA21832@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_143700_600677_87C4564C X-CRM114-Status: GOOD ( 26.29 ) 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 , Xi Wang , Jesper Dangaard Brouer , Jesper Dangaard Brouer , Yonghong Song , KP Singh , linux-arm-kernel@lists.infradead.org, Yauheni Kaliuta , Networking , Linux Kernel Mailing List , "David S. Miller" , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , bpf , Martin KaFai Lau Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Luke, = On Mon, Sep 14, 2020 at 11:21:58AM -0700, Luke Nelson wrote: > On Mon, Sep 14, 2020 at 11:08 AM Xi Wang wrote: > > I don't think there's some consistent semantics of "offsets" across > > the JITs of different architectures (maybe it's good to clean that > > up). RV64 and RV32 JITs are doing something similar to arm64 with > > respect to offsets. CCing Bj=F6rn and Luke. > = > As I understand it, there are two strategies JITs use to keep track of > the ctx->offset table. > = > Some JITs (RV32, RV64, arm32, arm64 currently, x86-32) track the end > of each instruction (e.g., ctx->offset[i] marks the beginning of > instruction i + 1). > This requires care to handle jumps to the first instruction to avoid > using ctx->offset[-1]. The RV32 and RV64 JITs have special handling > for this case, > while the arm32, arm64, and x86-32 JITs appear not to. The arm32 and > x32 probably need to be fixed for the same reason arm64 does. > = > The other strategy is for ctx->offset[i] to track the beginning of > instruction i. The x86-64 JIT currently works this way. > This can be easier to use (no need to special case -1) but looks to be > trickier to construct. This patch changes the arm64 JIT to work this > way. > = > I don't think either strategy is inherently better, both can be > "correct" as long as the JIT uses ctx->offset in the right way. > This might be a good opportunity to change the JITs to be consistent > about this (especially if the arm32, arm64, and x32 JITs all need to > be fixed anyways). > Having all JITs agree on the meaning of ctx->offset could help future > readers debug / understand the code, and could help to someday verify > the > ctx->offset construction. > = > Any thoughts? The common strategy does make a lot of sense and yes, both patches will wo= rks = assuming the ctx->offset ends up being what the JIT engine expects it to be= . = As I mentioned earlier we did consider both, but ended up using the later, = since as you said, removes the need for handling the special (-1) case. Cheers /Ilias > = > - Luke _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel