netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Murzin <murzin.v@gmail.com>
To: netdev@vger.kernel.org
Cc: av1474@comtv.ru, Vladimir Murzin <murzin.v@gmail.com>,
	Jan Seiffert <kaffeemonster@googlemail.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Daniel Borkmann <dborkman@redhat.com>,
	Matt Evans <matt@ozlabs.org>
Subject: [PATCH 1/3] net: bpf jit: ppc: optimize choose_load_func error path
Date: Tue,  8 Oct 2013 20:31:48 +0400	[thread overview]
Message-ID: <1381249910-17338-1-git-send-email-murzin.v@gmail.com> (raw)

Macro CHOOSE_LOAD_FUNC returns handler for "any offset" if checks for K
were not passed. At the same time handlers for "any offset" cases make
the same checks against r_addr at run-time, that will always lead to
bpf_error.

Run-time checks are still necessary for indirect load operations, but
error path for absolute and mesh loads are worth to optimize during bpf
compile time.

Signed-off-by: Vladimir Murzin <murzin.v@gmail.com>

Cc: Jan Seiffert <kaffeemonster@googlemail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Daniel Borkmann <dborkman@redhat.com>
Cc: Matt Evans <matt@ozlabs.org>

---
 arch/powerpc/net/bpf_jit_comp.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index bf56e33..754320a 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -132,7 +132,7 @@ static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
 }
 
 #define CHOOSE_LOAD_FUNC(K, func) \
-	((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
+	((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : NULL) : func##_positive_offset)
 
 /* Assemble the body code between the prologue & epilogue. */
 static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
@@ -427,6 +427,11 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
 		case BPF_S_LD_B_ABS:
 			func = CHOOSE_LOAD_FUNC(K, sk_load_byte);
 		common_load:
+			if (!func) {
+				PPC_LI(r_ret, 0);
+				PPC_JMP(exit_addr);
+				break;
+			}
 			/* Load from [K]. */
 			ctx->seen |= SEEN_DATAREF;
 			PPC_LI64(r_scratch1, func);
-- 
1.7.10.4

             reply	other threads:[~2013-10-08 17:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08 16:31 Vladimir Murzin [this message]
2013-10-08 22:50 ` [PATCH 1/3] net: bpf jit: ppc: optimize choose_load_func error path Jan Seiffert
2013-10-13 14:26   ` Vladimir Murzin
     [not found] ` <1381249910-17338-2-git-send-email-murzin.v@gmail.com>
2013-10-11 18:56   ` [PATCH 2/3] net: bpf jit: x86: " David Miller
2013-10-13 14:21     ` Vladimir Murzin
2013-10-13 14:25       ` malc
2013-10-13 14:31         ` Vladimir Murzin
2013-10-13 14:54   ` Vladimir Murzin
2013-10-13 14:54     ` Vladimir Murzin
2013-10-13 16:36       ` Eric Dumazet
2013-10-14  2:55         ` Vladimir Murzin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1381249910-17338-1-git-send-email-murzin.v@gmail.com \
    --to=murzin.v@gmail.com \
    --cc=av1474@comtv.ru \
    --cc=benh@kernel.crashing.org \
    --cc=dborkman@redhat.com \
    --cc=kaffeemonster@googlemail.com \
    --cc=matt@ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).