From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29AF03AA91 for ; Thu, 22 Jun 2023 09:38:11 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A20763583; Thu, 22 Jun 2023 02:37:47 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 841161042; Thu, 22 Jun 2023 02:37:34 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.25.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CEE3F3F663; Thu, 22 Jun 2023 02:36:48 -0700 (PDT) Date: Thu, 22 Jun 2023 10:36:45 +0100 From: Mark Rutland To: Puranjay Mohan Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, catalin.marinas@arm.com, bpf@vger.kernel.org, kpsingh@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next v3 3/3] bpf, arm64: use bpf_jit_binary_pack_alloc Message-ID: References: <20230619100121.27534-1-puranjay12@gmail.com> <20230619100121.27534-4-puranjay12@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net On Thu, Jun 22, 2023 at 10:47:08AM +0200, Puranjay Mohan wrote: > On Thu, Jun 22, 2023 at 10:23 AM Mark Rutland wrote: > > On Wed, Jun 21, 2023 at 10:57:20PM +0200, Puranjay Mohan wrote: > > > When I move the call to bpf_flush_icache() after > > > bpf_jit_binary_pack_finalize() (this does the copy to ro_header), the > > > boot issue is fixed. Would this change be enough to make this work or I > > > would need to do more with the data cache as well to catch other edge > > > cases? > > > > AFAICT, bpf_flush_icache() calls flush_icache_range(). Despite its name, > > flush_icache_range() has d-cache maintenance, i-cache maintenance, and context > > synchronization (i.e. it does everything necessary). > > > > As long as you call that with the VAs the code will be executed from, that > > should be sufficient, and you don't need to do any other work. > > Thanks for explaining this. > After reading your explanation, I feel this should work. > > bpf_jit_binary_pack_finalize() will copy the instructions from > rw_header to ro_header. > After the copy, calling bpf_flush_icache(ro_header, ctx.ro_image + > ctx.idx); will invalidate the caches > for the VAs in the ro_header, this is where the code will be executed from. > > I will send the v4 patchset with this change. Sure -- I'll be happy to review that. Mark. 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEA20EB64DA for ; Thu, 22 Jun 2023 09:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=hf/ODm9WGKHUABTJCOFtdCOjDFW+dvOKG4kKl8Wask0=; b=cOscTinD7a0Ned /5Yl46OIBdO+JwQ/TV3s2MOe+ZrrkseC537586KiDMUOTzOY+4y9V7ImUI7EAAd0qS/3Wvt79uqhV qs20+ncCWEXSoc/0t+OOVbg6vrApLZeayzwrhX0IrfYYF6Zd+iZE5v0QXcxnH2Hqlx8/ovh4beHyT 2yIhXBnvIh1x9t8eVg9o97flPD7K01z/rW0K3OWykcEIVHtGPR/0hxJ56FckafmWnJaZ8bmZ1gPW/ cLhfBa+CggWalcgteE5JtQT7L5f2iAkTyL7UHJ/1nJH7ZAmmV1dmrfXweZLCAwfR/LZBdc+u/IUDT BFI1tClkxCdOppzfCsMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCGkM-0001ov-0z; Thu, 22 Jun 2023 09:36:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCGkI-0001nC-1h for linux-arm-kernel@lists.infradead.org; Thu, 22 Jun 2023 09:36:56 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 841161042; Thu, 22 Jun 2023 02:37:34 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.25.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CEE3F3F663; Thu, 22 Jun 2023 02:36:48 -0700 (PDT) Date: Thu, 22 Jun 2023 10:36:45 +0100 From: Mark Rutland To: Puranjay Mohan Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, catalin.marinas@arm.com, bpf@vger.kernel.org, kpsingh@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next v3 3/3] bpf, arm64: use bpf_jit_binary_pack_alloc Message-ID: References: <20230619100121.27534-1-puranjay12@gmail.com> <20230619100121.27534-4-puranjay12@gmail.com> 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-20230622_023654_617300_A2E8C020 X-CRM114-Status: GOOD ( 20.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org T24gVGh1LCBKdW4gMjIsIDIwMjMgYXQgMTA6NDc6MDhBTSArMDIwMCwgUHVyYW5qYXkgTW9oYW4g d3JvdGU6Cj4gT24gVGh1LCBKdW4gMjIsIDIwMjMgYXQgMTA6MjPigK9BTSBNYXJrIFJ1dGxhbmQg PG1hcmsucnV0bGFuZEBhcm0uY29tPiB3cm90ZToKPiA+IE9uIFdlZCwgSnVuIDIxLCAyMDIzIGF0 IDEwOjU3OjIwUE0gKzAyMDAsIFB1cmFuamF5IE1vaGFuIHdyb3RlOgoKPiA+ID4gV2hlbiBJIG1v dmUgdGhlIGNhbGwgdG8gYnBmX2ZsdXNoX2ljYWNoZSgpIGFmdGVyCj4gPiA+IGJwZl9qaXRfYmlu YXJ5X3BhY2tfZmluYWxpemUoKSAodGhpcyBkb2VzIHRoZSBjb3B5IHRvIHJvX2hlYWRlciksIHRo ZQo+ID4gPiBib290IGlzc3VlIGlzIGZpeGVkLiBXb3VsZCB0aGlzIGNoYW5nZSBiZSBlbm91Z2gg dG8gbWFrZSB0aGlzIHdvcmsgb3IgSQo+ID4gPiB3b3VsZCBuZWVkIHRvIGRvIG1vcmUgd2l0aCB0 aGUgZ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