aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/net/bpf_jit_comp64.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/net/bpf_jit_comp64.c')
-rw-r--r--arch/powerpc/net/bpf_jit_comp64.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index a66e64b0b251..46d74e81aff1 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -69,7 +69,7 @@ static inline bool bpf_has_stack_frame(struct codegen_context *ctx)
69static int bpf_jit_stack_local(struct codegen_context *ctx) 69static int bpf_jit_stack_local(struct codegen_context *ctx)
70{ 70{
71 if (bpf_has_stack_frame(ctx)) 71 if (bpf_has_stack_frame(ctx))
72 return STACK_FRAME_MIN_SIZE + MAX_BPF_STACK; 72 return STACK_FRAME_MIN_SIZE + ctx->stack_size;
73 else 73 else
74 return -(BPF_PPC_STACK_SAVE + 16); 74 return -(BPF_PPC_STACK_SAVE + 16);
75} 75}
@@ -82,8 +82,9 @@ static int bpf_jit_stack_tailcallcnt(struct codegen_context *ctx)
82static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg) 82static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg)
83{ 83{
84 if (reg >= BPF_PPC_NVR_MIN && reg < 32) 84 if (reg >= BPF_PPC_NVR_MIN && reg < 32)
85 return (bpf_has_stack_frame(ctx) ? BPF_PPC_STACKFRAME : 0) 85 return (bpf_has_stack_frame(ctx) ?
86 - (8 * (32 - reg)); 86 (BPF_PPC_STACKFRAME + ctx->stack_size) : 0)
87 - (8 * (32 - reg));
87 88
88 pr_err("BPF JIT is asking about unknown registers"); 89 pr_err("BPF JIT is asking about unknown registers");
89 BUG(); 90 BUG();
@@ -134,7 +135,7 @@ static void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
134 PPC_BPF_STL(0, 1, PPC_LR_STKOFF); 135 PPC_BPF_STL(0, 1, PPC_LR_STKOFF);
135 } 136 }
136 137
137 PPC_BPF_STLU(1, 1, -BPF_PPC_STACKFRAME); 138 PPC_BPF_STLU(1, 1, -(BPF_PPC_STACKFRAME + ctx->stack_size));
138 } 139 }
139 140
140 /* 141 /*
@@ -161,7 +162,7 @@ static void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
161 /* Setup frame pointer to point to the bpf stack area */ 162 /* Setup frame pointer to point to the bpf stack area */
162 if (bpf_is_seen_register(ctx, BPF_REG_FP)) 163 if (bpf_is_seen_register(ctx, BPF_REG_FP))
163 PPC_ADDI(b2p[BPF_REG_FP], 1, 164 PPC_ADDI(b2p[BPF_REG_FP], 1,
164 STACK_FRAME_MIN_SIZE + MAX_BPF_STACK); 165 STACK_FRAME_MIN_SIZE + ctx->stack_size);
165} 166}
166 167
167static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx) 168static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx)
@@ -183,7 +184,7 @@ static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx
183 184
184 /* Tear down our stack frame */ 185 /* Tear down our stack frame */
185 if (bpf_has_stack_frame(ctx)) { 186 if (bpf_has_stack_frame(ctx)) {
186 PPC_ADDI(1, 1, BPF_PPC_STACKFRAME); 187 PPC_ADDI(1, 1, BPF_PPC_STACKFRAME + ctx->stack_size);
187 if (ctx->seen & SEEN_FUNC) { 188 if (ctx->seen & SEEN_FUNC) {
188 PPC_BPF_LL(0, 1, PPC_LR_STKOFF); 189 PPC_BPF_LL(0, 1, PPC_LR_STKOFF);
189 PPC_MTLR(0); 190 PPC_MTLR(0);
@@ -1013,6 +1014,9 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
1013 1014
1014 memset(&cgctx, 0, sizeof(struct codegen_context)); 1015 memset(&cgctx, 0, sizeof(struct codegen_context));
1015 1016
1017 /* Make sure that the stack is quadword aligned. */
1018 cgctx.stack_size = round_up(fp->aux->stack_depth, 16);
1019
1016 /* Scouting faux-generate pass 0 */ 1020 /* Scouting faux-generate pass 0 */
1017 if (bpf_jit_build_body(fp, 0, &cgctx, addrs)) { 1021 if (bpf_jit_build_body(fp, 0, &cgctx, addrs)) {
1018 /* We hit something illegal or unsupported. */ 1022 /* We hit something illegal or unsupported. */