Skip to content

Commit ae6bb71

Browse files
committed
Merge tag 'powerpc-6.1-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Fix oops in 32-bit BPF tail call tests - Add missing declaration for machine_check_early_boot() Thanks to Christophe Leroy and Naveen N. Rao. * tag 'powerpc-6.1-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/64s: Add missing declaration for machine_check_early_boot() powerpc/bpf/32: Fix Oops on tail call tests
2 parents 50f36c5 + 2e7ec19 commit ae6bb71

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

arch/powerpc/include/asm/interrupt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ ____##func(struct pt_regs *regs)
602602
/* kernel/traps.c */
603603
DECLARE_INTERRUPT_HANDLER_NMI(system_reset_exception);
604604
#ifdef CONFIG_PPC_BOOK3S_64
605+
DECLARE_INTERRUPT_HANDLER_RAW(machine_check_early_boot);
605606
DECLARE_INTERRUPT_HANDLER_ASYNC(machine_check_exception_async);
606607
#endif
607608
DECLARE_INTERRUPT_HANDLER_NMI(machine_check_exception);

arch/powerpc/net/bpf_jit_comp32.c

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,19 @@ void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
113113
{
114114
int i;
115115

116-
/* First arg comes in as a 32 bits pointer. */
117-
EMIT(PPC_RAW_MR(bpf_to_ppc(BPF_REG_1), _R3));
118-
EMIT(PPC_RAW_LI(bpf_to_ppc(BPF_REG_1) - 1, 0));
116+
/* Initialize tail_call_cnt, to be skipped if we do tail calls. */
117+
EMIT(PPC_RAW_LI(_R4, 0));
118+
119+
#define BPF_TAILCALL_PROLOGUE_SIZE 4
120+
119121
EMIT(PPC_RAW_STWU(_R1, _R1, -BPF_PPC_STACKFRAME(ctx)));
120122

121-
/*
122-
* Initialize tail_call_cnt in stack frame if we do tail calls.
123-
* Otherwise, put in NOPs so that it can be skipped when we are
124-
* invoked through a tail call.
125-
*/
126123
if (ctx->seen & SEEN_TAILCALL)
127-
EMIT(PPC_RAW_STW(bpf_to_ppc(BPF_REG_1) - 1, _R1,
128-
bpf_jit_stack_offsetof(ctx, BPF_PPC_TC)));
129-
else
130-
EMIT(PPC_RAW_NOP());
124+
EMIT(PPC_RAW_STW(_R4, _R1, bpf_jit_stack_offsetof(ctx, BPF_PPC_TC)));
131125

132-
#define BPF_TAILCALL_PROLOGUE_SIZE 16
126+
/* First arg comes in as a 32 bits pointer. */
127+
EMIT(PPC_RAW_MR(bpf_to_ppc(BPF_REG_1), _R3));
128+
EMIT(PPC_RAW_LI(bpf_to_ppc(BPF_REG_1) - 1, 0));
133129

134130
/*
135131
* We need a stack frame, but we don't necessarily need to
@@ -170,24 +166,24 @@ static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx
170166
for (i = BPF_PPC_NVR_MIN; i <= 31; i++)
171167
if (bpf_is_seen_register(ctx, i))
172168
EMIT(PPC_RAW_LWZ(i, _R1, bpf_jit_stack_offsetof(ctx, i)));
173-
}
174-
175-
void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
176-
{
177-
EMIT(PPC_RAW_MR(_R3, bpf_to_ppc(BPF_REG_0)));
178-
179-
bpf_jit_emit_common_epilogue(image, ctx);
180-
181-
/* Tear down our stack frame */
182169

183170
if (ctx->seen & SEEN_FUNC)
184171
EMIT(PPC_RAW_LWZ(_R0, _R1, BPF_PPC_STACKFRAME(ctx) + PPC_LR_STKOFF));
185172

173+
/* Tear down our stack frame */
186174
EMIT(PPC_RAW_ADDI(_R1, _R1, BPF_PPC_STACKFRAME(ctx)));
187175

188176
if (ctx->seen & SEEN_FUNC)
189177
EMIT(PPC_RAW_MTLR(_R0));
190178

179+
}
180+
181+
void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
182+
{
183+
EMIT(PPC_RAW_MR(_R3, bpf_to_ppc(BPF_REG_0)));
184+
185+
bpf_jit_emit_common_epilogue(image, ctx);
186+
191187
EMIT(PPC_RAW_BLR());
192188
}
193189

@@ -244,7 +240,6 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o
244240
EMIT(PPC_RAW_RLWINM(_R3, b2p_index, 2, 0, 29));
245241
EMIT(PPC_RAW_ADD(_R3, _R3, b2p_bpf_array));
246242
EMIT(PPC_RAW_LWZ(_R3, _R3, offsetof(struct bpf_array, ptrs)));
247-
EMIT(PPC_RAW_STW(_R0, _R1, bpf_jit_stack_offsetof(ctx, BPF_PPC_TC)));
248243

249244
/*
250245
* if (prog == NULL)
@@ -255,19 +250,14 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o
255250

256251
/* goto *(prog->bpf_func + prologue_size); */
257252
EMIT(PPC_RAW_LWZ(_R3, _R3, offsetof(struct bpf_prog, bpf_func)));
258-
259-
if (ctx->seen & SEEN_FUNC)
260-
EMIT(PPC_RAW_LWZ(_R0, _R1, BPF_PPC_STACKFRAME(ctx) + PPC_LR_STKOFF));
261-
262253
EMIT(PPC_RAW_ADDIC(_R3, _R3, BPF_TAILCALL_PROLOGUE_SIZE));
263-
264-
if (ctx->seen & SEEN_FUNC)
265-
EMIT(PPC_RAW_MTLR(_R0));
266-
267254
EMIT(PPC_RAW_MTCTR(_R3));
268255

269256
EMIT(PPC_RAW_MR(_R3, bpf_to_ppc(BPF_REG_1)));
270257

258+
/* Put tail_call_cnt in r4 */
259+
EMIT(PPC_RAW_MR(_R4, _R0));
260+
271261
/* tear restore NVRs, ... */
272262
bpf_jit_emit_common_epilogue(image, ctx);
273263

0 commit comments

Comments
 (0)