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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FDAEEB64D8 for ; Thu, 22 Jun 2023 09:48:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231556AbjFVJsf (ORCPT ); Thu, 22 Jun 2023 05:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232017AbjFVJsQ (ORCPT ); Thu, 22 Jun 2023 05:48:16 -0400 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.