Skip to content

Commit c0d7dcf

Browse files
npigginmpe
authored andcommitted
powerpc/64/kuap: Move kuap checks out of MSR[RI]=0 regions of exit code
Any kind of WARN causes a program check that will crash with unrecoverable exception if it occurs when RI is clear. Fixes: 68b3458 ("powerpc/64/sycall: Implement syscall entry/exit logic in C") Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0094368 commit c0d7dcf

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

arch/powerpc/kernel/syscall_64.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ notrace long system_call_exception(long r3, long r4, long r5,
3535
BUG_ON(!FULL_REGS(regs));
3636
BUG_ON(regs->softe != IRQS_ENABLED);
3737

38+
kuap_check_amr();
39+
3840
account_cpu_user_entry();
3941

4042
#ifdef CONFIG_PPC_SPLPAR
@@ -47,8 +49,6 @@ notrace long system_call_exception(long r3, long r4, long r5,
4749
}
4850
#endif
4951

50-
kuap_check_amr();
51-
5252
/*
5353
* This is not required for the syscall exit path, but makes the
5454
* stack frame look nicer. If this was initialised in the first stack
@@ -117,6 +117,8 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
117117
unsigned long ti_flags;
118118
unsigned long ret = 0;
119119

120+
kuap_check_amr();
121+
120122
regs->result = r3;
121123

122124
/* Check whether the syscall is issued inside a restartable sequence */
@@ -204,8 +206,6 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
204206
local_paca->tm_scratch = regs->msr;
205207
#endif
206208

207-
kuap_check_amr();
208-
209209
account_cpu_user_exit();
210210

211211
return ret;
@@ -228,6 +228,8 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs, unsigned
228228
BUG_ON(!FULL_REGS(regs));
229229
BUG_ON(regs->softe != IRQS_ENABLED);
230230

231+
kuap_check_amr();
232+
231233
local_irq_save(flags);
232234

233235
again:
@@ -292,8 +294,6 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs, unsigned
292294
local_paca->tm_scratch = regs->msr;
293295
#endif
294296

295-
kuap_check_amr();
296-
297297
account_cpu_user_exit();
298298

299299
return ret;
@@ -313,6 +313,8 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign
313313
BUG_ON(regs->msr & MSR_PR);
314314
BUG_ON(!FULL_REGS(regs));
315315

316+
kuap_check_amr();
317+
316318
if (unlikely(*ti_flagsp & _TIF_EMULATE_STACK_STORE)) {
317319
clear_bits(_TIF_EMULATE_STACK_STORE, ti_flagsp);
318320
ret = 1;

0 commit comments

Comments
 (0)