Commit 6cc3f91b authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc/64s: Fix may_hard_irq_enable() for PMI soft masking

The soft IRQ masking code has to hard-disable interrupts in cases
where the exception is not cleared by the masked handler. External
interrupts used this approach for soft masking. Now recently PMU
interrupts do the same thing.

The soft IRQ masking code additionally allowed for interrupt handlers
to hard-enable interrupts after soft-disabling them. The idea is to
allow PMU interrupts through to profile interrupt handlers.

So when interrupts are being replayed when there is a pending
interrupt that requires hard-disabling, there is a test to prevent
those handlers from hard-enabling them if there is a pending external
interrupt. may_hard_irq_enable() handles this.

After f442d004 ("powerpc/64s: Add support to mask perf interrupts
and replay them"), may_hard_irq_enable() could prematurely enable
MSR[EE] when a PMU exception exists, which would result in the
interrupt firing again while masked, and MSR[EE] being disabled again.

I haven't seen that this could cause a serious problem, but it's
more consistent to handle these soft-masked interrupts in the same
way. So introduce a define for all types of interrupts that require
MSR[EE] masking in their soft-disable handlers, and use that in
may_hard_irq_enable().

Fixes: f442d004 ("powerpc/64s: Add support to mask perf interrupts and replay them")
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Reviewed-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 5c11d1e5
...@@ -29,6 +29,16 @@ ...@@ -29,6 +29,16 @@
#define PACA_IRQ_HMI 0x20 #define PACA_IRQ_HMI 0x20
#define PACA_IRQ_PMI 0x40 #define PACA_IRQ_PMI 0x40
/*
* Some soft-masked interrupts must be hard masked until they are replayed
* (e.g., because the soft-masked handler does not clear the exception).
*/
#ifdef CONFIG_PPC_BOOK3S
#define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE|PACA_IRQ_PMI)
#else
#define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE)
#endif
/* /*
* flags for paca->irq_soft_mask * flags for paca->irq_soft_mask
*/ */
...@@ -244,7 +254,7 @@ static inline bool lazy_irq_pending(void) ...@@ -244,7 +254,7 @@ static inline bool lazy_irq_pending(void)
static inline void may_hard_irq_enable(void) static inline void may_hard_irq_enable(void)
{ {
get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS; get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
if (!(get_paca()->irq_happened & PACA_IRQ_EE)) if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK))
__hard_irq_enable(); __hard_irq_enable();
} }
......
...@@ -943,6 +943,8 @@ kernel_dbg_exc: ...@@ -943,6 +943,8 @@ kernel_dbg_exc:
/* /*
* An interrupt came in while soft-disabled; We mark paca->irq_happened * An interrupt came in while soft-disabled; We mark paca->irq_happened
* accordingly and if the interrupt is level sensitive, we hard disable * accordingly and if the interrupt is level sensitive, we hard disable
* hard disable (full_mask) corresponds to PACA_IRQ_MUST_HARD_MASK, so
* keep these in synch.
*/ */
.macro masked_interrupt_book3e paca_irq full_mask .macro masked_interrupt_book3e paca_irq full_mask
......
...@@ -1426,7 +1426,7 @@ EXC_COMMON_BEGIN(soft_nmi_common) ...@@ -1426,7 +1426,7 @@ EXC_COMMON_BEGIN(soft_nmi_common)
* triggered and won't automatically refire. * triggered and won't automatically refire.
* - If it was a HMI we return immediately since we handled it in realmode * - If it was a HMI we return immediately since we handled it in realmode
* and it won't refire. * and it won't refire.
* - else we hard disable and return. * - Else it is one of PACA_IRQ_MUST_HARD_MASK, so hard disable and return.
* This is called with r10 containing the value to OR to the paca field. * This is called with r10 containing the value to OR to the paca field.
*/ */
#define MASKED_INTERRUPT(_H) \ #define MASKED_INTERRUPT(_H) \
...@@ -1441,8 +1441,8 @@ masked_##_H##interrupt: \ ...@@ -1441,8 +1441,8 @@ masked_##_H##interrupt: \
ori r10,r10,0xffff; \ ori r10,r10,0xffff; \
mtspr SPRN_DEC,r10; \ mtspr SPRN_DEC,r10; \
b MASKED_DEC_HANDLER_LABEL; \ b MASKED_DEC_HANDLER_LABEL; \
1: andi. r10,r10,(PACA_IRQ_DBELL|PACA_IRQ_HMI); \ 1: andi. r10,r10,PACA_IRQ_MUST_HARD_MASK; \
bne 2f; \ beq 2f; \
mfspr r10,SPRN_##_H##SRR1; \ mfspr r10,SPRN_##_H##SRR1; \
xori r10,r10,MSR_EE; /* clear MSR_EE */ \ xori r10,r10,MSR_EE; /* clear MSR_EE */ \
mtspr SPRN_##_H##SRR1,r10; \ mtspr SPRN_##_H##SRR1,r10; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment