arm64: bpf: fix JIT frame pointer setup
authorYang Shi <yang.shi@linaro.org>
Thu, 12 Nov 2015 21:57:00 +0000 (13:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Nov 2015 19:38:42 +0000 (14:38 -0500)
BPF fp should point to the top of the BPF prog stack. The original
implementation made it point to the bottom incorrectly.
Move A64_SP to fp before reserve BPF prog stack space.

CC: Zi Shen Lim <zlim.lnx@gmail.com>
CC: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Yang Shi <yang.shi@linaro.org>
Reviewed-by: Zi Shen Lim <zlim.lnx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/arm64/net/bpf_jit_comp.c

index a44e5293c6f58adb288e9c0d0549fcbe26c98daa..ac8b548ce4939fa949a9d2473bf580f383e296e2 100644 (file)
@@ -161,12 +161,12 @@ static void build_prologue(struct jit_ctx *ctx)
        if (ctx->tmp_used)
                emit(A64_PUSH(tmp1, tmp2, A64_SP), ctx);
 
-       /* Set up BPF stack */
-       emit(A64_SUB_I(1, A64_SP, A64_SP, stack_size), ctx);
-
        /* Set up frame pointer */
        emit(A64_MOV(1, fp, A64_SP), ctx);
 
+       /* Set up BPF stack */
+       emit(A64_SUB_I(1, A64_SP, A64_SP, stack_size), ctx);
+
        /* Clear registers A and X */
        emit_a64_mov_i64(ra, 0, ctx);
        emit_a64_mov_i64(rx, 0, ctx);