Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10668474rwd; Thu, 22 Jun 2023 03:13:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ybaVlQwhqQYswS4R76LPwjg8PhnGdvB3oKVRW61px+hNpdoA4lxJz5Icm+2WNvwkPlwof X-Received: by 2002:a17:90a:4145:b0:23f:9445:318e with SMTP id m5-20020a17090a414500b0023f9445318emr24009624pjg.3.1687428782542; Thu, 22 Jun 2023 03:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687428782; cv=none; d=google.com; s=arc-20160816; b=xMH5bjcr19D7uDqI22ERvUeYX/lGUKRIRsFMxSTXPDcMI8IGSNGvtHziMTHNKJi9+J vlYGurMrTtQu14MxWXiuelteWhj/xtVOACfSLSNcZh49kKQijhqnXe5A/YbMkKtn0Huy dYAQ7vJthsFzHFs4uFsLnXr1dXtZX0e79/XFLTHri9+qHZLfpBaj8vljuenGm0Y8Bgss 42eBYxdCkVQ1qcEG3ukPHC5k0N8wK7/O30VmuUYPJyM3NRGmTUDcnLIZTLtUtav8Yebn kY6m1yIOpBUz2UApk1X8ePHFMH2H+cLelDK90Bjfd//0oxLDWKPfvr3Z2fZZd1D60tBq hQeA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TLqdPWvgg7iQgES+qMTtHgbxyfAKQRSEJP9u/exdBwk=; b=n/V8fBBHucsub3OK4CtALQUG/IyLWWFLWiiwGgJbUbFcfLs/+vPPpVwZOtgi+1YJJS aqKEH+dh/WP6SSphYWqG9A70kov/oqm9mDtt9jEs2AAaCLFYUG24XSSzzn1K6ceSJ8F2 m0gImwLmSroQqGux0vsNcJTa2z8FrNF6WGeSGlpymvVK/vM+piT3g3VQWygwOOI2/LPQ CXD6qx2O2ndWIK7bHEWvKG5JRcHBSNKnQKCigG7gFNZJFFSBoHOrFb/eTl0fTFvziLmu YGFWz+r/r6mZdZgMtEXCZ7mhsVm/+qjUAFRsFrbe00WQuTHtdG6RG5dlWs+em3vueGfF ct2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ep5-20020a17090ae64500b002536c5eb7cfsi13430353pjb.58.2023.06.22.03.12.50; Thu, 22 Jun 2023 03:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231931AbjFVJse (ORCPT + 99 others); Thu, 22 Jun 2023 05:48:34 -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: 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 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.