From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752662AbdFLLGd (ORCPT ); Mon, 12 Jun 2017 07:06:33 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:37372 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752024AbdFLLGb (ORCPT ); Mon, 12 Jun 2017 07:06:31 -0400 Date: Mon, 12 Jun 2017 12:06:11 +0100 From: Russell King - ARM Linux To: Daniel Borkmann Cc: Kees Cook , Shubham Bansal , Network Development , "David S. Miller" , Alexei Starovoitov , "linux-arm-kernel@lists.infradead.org" , LKML , Andrew Lunn Subject: Re: [PATCH v2] arm: eBPF JIT compiler Message-ID: <20170612110611.GC4902@n2100.armlinux.org.uk> References: <1495754003-21099-1-git-send-email-illusionist.neo@gmail.com> <593E6B0F.8070901@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <593E6B0F.8070901@iogearbox.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 12, 2017 at 12:21:03PM +0200, Daniel Borkmann wrote: > On 05/30/2017 09:19 PM, Kees Cook wrote: > >On Thu, May 25, 2017 at 4:13 PM, Shubham Bansal > > wrote: > >>+static int validate_code(struct jit_ctx *ctx) > >>+{ > >>+ int i; > >>+ > >>+ for (i = 0; i < ctx->idx; i++) { > >>+ u32 a32_insn = le32_to_cpu(ctx->target[i]); > > Given __opcode_to_mem_arm(ARM_INST_UDF) is used to fill the image, > perhaps use the __mem_to_opcode_arm() helper for the check? > > >>+ if (a32_insn == ARM_INST_UDF) The following is probably better: if (ctx->target[i] == __opcode_to_mem_arm(ARM_INST_UDF)) since then you can take advantage of the compiler optimising the constant rather than having to do a byte swap on an unknown 32-bit value. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King - ARM Linux Subject: Re: [PATCH v2] arm: eBPF JIT compiler Date: Mon, 12 Jun 2017 12:06:11 +0100 Message-ID: <20170612110611.GC4902@n2100.armlinux.org.uk> References: <1495754003-21099-1-git-send-email-illusionist.neo@gmail.com> <593E6B0F.8070901@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Kees Cook , Shubham Bansal , Network Development , "David S. Miller" , Alexei Starovoitov , "linux-arm-kernel@lists.infradead.org" , LKML , Andrew Lunn To: Daniel Borkmann Return-path: Content-Disposition: inline In-Reply-To: <593E6B0F.8070901@iogearbox.net> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Mon, Jun 12, 2017 at 12:21:03PM +0200, Daniel Borkmann wrote: > On 05/30/2017 09:19 PM, Kees Cook wrote: > >On Thu, May 25, 2017 at 4:13 PM, Shubham Bansal > > wrote: > >>+static int validate_code(struct jit_ctx *ctx) > >>+{ > >>+ int i; > >>+ > >>+ for (i = 0; i < ctx->idx; i++) { > >>+ u32 a32_insn = le32_to_cpu(ctx->target[i]); > > Given __opcode_to_mem_arm(ARM_INST_UDF) is used to fill the image, > perhaps use the __mem_to_opcode_arm() helper for the check? > > >>+ if (a32_insn == ARM_INST_UDF) The following is probably better: if (ctx->target[i] == __opcode_to_mem_arm(ARM_INST_UDF)) since then you can take advantage of the compiler optimising the constant rather than having to do a byte swap on an unknown 32-bit value. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. From mboxrd@z Thu Jan 1 00:00:00 1970 From: linux@armlinux.org.uk (Russell King - ARM Linux) Date: Mon, 12 Jun 2017 12:06:11 +0100 Subject: [PATCH v2] arm: eBPF JIT compiler In-Reply-To: <593E6B0F.8070901@iogearbox.net> References: <1495754003-21099-1-git-send-email-illusionist.neo@gmail.com> <593E6B0F.8070901@iogearbox.net> Message-ID: <20170612110611.GC4902@n2100.armlinux.org.uk> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Jun 12, 2017 at 12:21:03PM +0200, Daniel Borkmann wrote: > On 05/30/2017 09:19 PM, Kees Cook wrote: > >On Thu, May 25, 2017 at 4:13 PM, Shubham Bansal > > wrote: > >>+static int validate_code(struct jit_ctx *ctx) > >>+{ > >>+ int i; > >>+ > >>+ for (i = 0; i < ctx->idx; i++) { > >>+ u32 a32_insn = le32_to_cpu(ctx->target[i]); > > Given __opcode_to_mem_arm(ARM_INST_UDF) is used to fill the image, > perhaps use the __mem_to_opcode_arm() helper for the check? > > >>+ if (a32_insn == ARM_INST_UDF) The following is probably better: if (ctx->target[i] == __opcode_to_mem_arm(ARM_INST_UDF)) since then you can take advantage of the compiler optimising the constant rather than having to do a byte swap on an unknown 32-bit value. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.