Skip to content

Commit 9b69d48

Browse files
npigginmpe
authored andcommitted
powerpc/64e: remove implicit soft-masking and interrupt exit restart logic
The implicit soft-masking to speed up interrupt return was going to be used by 64e as well, but it has not been extensively tested on that platform and is not considered ready. It was intended to be disabled before merge. Disable it for now. Most of the restart code is common with 64s, so with more correctness and performance testing this could be re-enabled again by adding the extra soft-mask checks to interrupt handlers and flipping exit_must_hard_disable(). Fixes: 9d1988c ("powerpc/64: treat low kernel text as irqs soft-masked") Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fce01ac commit 9b69d48

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

arch/powerpc/include/asm/interrupt.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,34 @@
7373
#include <asm/kprobes.h>
7474
#include <asm/runlatch.h>
7575

76-
#ifdef CONFIG_PPC64
76+
#ifdef CONFIG_PPC_BOOK3S_64
7777
extern char __end_soft_masked[];
7878
unsigned long search_kernel_restart_table(unsigned long addr);
79-
#endif
8079

81-
#ifdef CONFIG_PPC_BOOK3S_64
8280
DECLARE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
8381

82+
static inline bool is_implicit_soft_masked(struct pt_regs *regs)
83+
{
84+
if (regs->msr & MSR_PR)
85+
return false;
86+
87+
if (regs->nip >= (unsigned long)__end_soft_masked)
88+
return false;
89+
90+
return true;
91+
}
92+
8493
static inline void srr_regs_clobbered(void)
8594
{
8695
local_paca->srr_valid = 0;
8796
local_paca->hsrr_valid = 0;
8897
}
8998
#else
99+
static inline bool is_implicit_soft_masked(struct pt_regs *regs)
100+
{
101+
return false;
102+
}
103+
90104
static inline void srr_regs_clobbered(void)
91105
{
92106
}
@@ -150,11 +164,13 @@ static inline void interrupt_enter_prepare(struct pt_regs *regs, struct interrup
150164
*/
151165
if (TRAP(regs) != INTERRUPT_PROGRAM) {
152166
CT_WARN_ON(ct_state() != CONTEXT_KERNEL);
153-
BUG_ON(regs->nip < (unsigned long)__end_soft_masked);
167+
BUG_ON(is_implicit_soft_masked(regs));
154168
}
169+
#ifdef CONFIG_PPC_BOOK3S
155170
/* Move this under a debugging check */
156171
if (arch_irq_disabled_regs(regs))
157172
BUG_ON(search_kernel_restart_table(regs->nip));
173+
#endif
158174
}
159175
#endif
160176

@@ -244,10 +260,9 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte
244260
local_paca->irq_soft_mask = IRQS_ALL_DISABLED;
245261
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
246262

247-
if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && !(regs->msr & MSR_PR) &&
248-
regs->nip < (unsigned long)__end_soft_masked) {
249-
// Kernel code running below __end_soft_masked is
250-
// implicitly soft-masked.
263+
if (is_implicit_soft_masked(regs)) {
264+
// Adjust regs->softe soft implicit soft-mask, so
265+
// arch_irq_disabled_regs(regs) behaves as expected.
251266
regs->softe = IRQS_ALL_DISABLED;
252267
}
253268

@@ -282,14 +297,14 @@ static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct inter
282297
*/
283298

284299
#ifdef CONFIG_PPC64
300+
#ifdef CONFIG_PPC_BOOK3S
285301
if (arch_irq_disabled_regs(regs)) {
286302
unsigned long rst = search_kernel_restart_table(regs->nip);
287303
if (rst)
288304
regs_set_return_ip(regs, rst);
289305
}
290306
#endif
291307

292-
#ifdef CONFIG_PPC64
293308
if (nmi_disables_ftrace(regs))
294309
this_cpu_set_ftrace_enabled(state->ftrace_enabled);
295310

arch/powerpc/kernel/exceptions-64e.S

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,7 @@ ret_from_mc_except:
342342
#define PROLOG_ADDITION_MASKABLE_GEN(n) \
343343
lbz r10,PACAIRQSOFTMASK(r13); /* are irqs soft-masked? */ \
344344
andi. r10,r10,IRQS_DISABLED; /* yes -> go out of line */ \
345-
bne masked_interrupt_book3e_##n; \
346-
/* Kernel code below __end_soft_masked is implicitly masked */ \
347-
andi. r10,r11,MSR_PR; \
348-
bne 1f; /* user -> not masked */ \
349-
std r14,PACA_EXGEN+EX_R14(r13); \
350-
LOAD_REG_IMMEDIATE_SYM(r14, r10, __end_soft_masked); \
351-
mfspr r10,SPRN_SRR0; \
352-
cmpld r10,r14; \
353-
ld r14,PACA_EXGEN+EX_R14(r13); \
354-
blt masked_interrupt_book3e_##n; \
355-
1:
345+
bne masked_interrupt_book3e_##n
356346

357347
/*
358348
* Additional regs must be re-loaded from paca before EXCEPTION_COMMON* is

arch/powerpc/kernel/interrupt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static inline bool exit_must_hard_disable(void)
3636
#else
3737
static inline bool exit_must_hard_disable(void)
3838
{
39-
return IS_ENABLED(CONFIG_PPC32);
39+
return true;
4040
}
4141
#endif
4242

arch/powerpc/kernel/interrupt_64.S

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ _ASM_NOKPROBE_SYMBOL(system_call_vectored_emulate)
231231
li r10,IRQS_ALL_DISABLED
232232
stb r10,PACAIRQSOFTMASK(r13)
233233
b system_call_vectored_common
234-
#endif
234+
#endif /* CONFIG_PPC_BOOK3S */
235235

236236
.balign IFETCH_ALIGN_BYTES
237237
.globl system_call_common_real
@@ -320,10 +320,12 @@ END_BTB_FLUSH_SECTION
320320
li r5,0 /* !scv */
321321
bl syscall_exit_prepare
322322
std r1,PACA_EXIT_SAVE_R1(r13) /* save r1 for restart */
323+
#ifdef CONFIG_PPC_BOOK3S
323324
.Lsyscall_rst_start:
324325
lbz r11,PACAIRQHAPPENED(r13)
325326
andi. r11,r11,(~PACA_IRQ_HARD_DIS)@l
326327
bne- syscall_restart
328+
#endif
327329
li r11,IRQS_ENABLED
328330
stb r11,PACAIRQSOFTMASK(r13)
329331
li r11,0
@@ -396,6 +398,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
396398
b .Lsyscall_restore_regs_cont
397399
.Lsyscall_rst_end:
398400

401+
#ifdef CONFIG_PPC_BOOK3S
399402
syscall_restart:
400403
GET_PACA(r13)
401404
ld r1,PACA_EXIT_SAVE_R1(r13)
@@ -409,6 +412,7 @@ syscall_restart:
409412
b .Lsyscall_rst_start
410413

411414
RESTART_TABLE(.Lsyscall_rst_start, .Lsyscall_rst_end, syscall_restart)
415+
#endif
412416

413417
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
414418
tabort_syscall:
@@ -504,10 +508,12 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return_\srr\())
504508
bne- .Lrestore_nvgprs_\srr
505509
.Lrestore_nvgprs_\srr\()_cont:
506510
std r1,PACA_EXIT_SAVE_R1(r13) /* save r1 for restart */
511+
#ifdef CONFIG_PPC_BOOK3S
507512
.Linterrupt_return_\srr\()_user_rst_start:
508513
lbz r11,PACAIRQHAPPENED(r13)
509514
andi. r11,r11,(~PACA_IRQ_HARD_DIS)@l
510515
bne- interrupt_return_\srr\()_user_restart
516+
#endif
511517
li r11,IRQS_ENABLED
512518
stb r11,PACAIRQSOFTMASK(r13)
513519
li r11,0
@@ -590,6 +596,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
590596
REST_NVGPRS(r1)
591597
b .Lrestore_nvgprs_\srr\()_cont
592598

599+
#ifdef CONFIG_PPC_BOOK3S
593600
interrupt_return_\srr\()_user_restart:
594601
GET_PACA(r13)
595602
ld r1,PACA_EXIT_SAVE_R1(r13)
@@ -602,6 +609,7 @@ interrupt_return_\srr\()_user_restart:
602609
b .Linterrupt_return_\srr\()_user_rst_start
603610

604611
RESTART_TABLE(.Linterrupt_return_\srr\()_user_rst_start, .Linterrupt_return_\srr\()_user_rst_end, interrupt_return_\srr\()_user_restart)
612+
#endif
605613

606614
.balign IFETCH_ALIGN_BYTES
607615
.Lkernel_interrupt_return_\srr\():
@@ -615,9 +623,11 @@ RESTART_TABLE(.Linterrupt_return_\srr\()_user_rst_start, .Linterrupt_return_\srr
615623
cmpwi r11,IRQS_ENABLED
616624
stb r11,PACAIRQSOFTMASK(r13)
617625
bne 1f
626+
#ifdef CONFIG_PPC_BOOK3S
618627
lbz r11,PACAIRQHAPPENED(r13)
619628
andi. r11,r11,(~PACA_IRQ_HARD_DIS)@l
620629
bne- interrupt_return_\srr\()_kernel_restart
630+
#endif
621631
li r11,0
622632
stb r11,PACAIRQHAPPENED(r13) # clear out possible HARD_DIS
623633
1:
@@ -717,6 +727,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
717727
b . /* prevent speculative execution */
718728
.Linterrupt_return_\srr\()_kernel_rst_end:
719729

730+
#ifdef CONFIG_PPC_BOOK3S
720731
interrupt_return_\srr\()_kernel_restart:
721732
GET_PACA(r13)
722733
ld r1,PACA_EXIT_SAVE_R1(r13)
@@ -729,14 +740,15 @@ interrupt_return_\srr\()_kernel_restart:
729740
b .Linterrupt_return_\srr\()_kernel_rst_start
730741

731742
RESTART_TABLE(.Linterrupt_return_\srr\()_kernel_rst_start, .Linterrupt_return_\srr\()_kernel_rst_end, interrupt_return_\srr\()_kernel_restart)
743+
#endif
732744

733745
.endm
734746

735747
interrupt_return_macro srr
736748
#ifdef CONFIG_PPC_BOOK3S
737749
interrupt_return_macro hsrr
738-
#endif /* CONFIG_PPC_BOOK3S */
739750

740751
.globl __end_soft_masked
741752
__end_soft_masked:
742753
DEFINE_FIXED_SYMBOL(__end_soft_masked)
754+
#endif /* CONFIG_PPC_BOOK3S */

0 commit comments

Comments
 (0)