Re: [PATCH v4 04/16] powerpc/64s/exceptions: machine check reconcile irq state

2020-05-09 Thread Nicholas Piggin
Excerpts from Michael Ellerman's message of May 8, 2020 11:39 pm:
> Nicholas Piggin  writes:
> 
>> pseries fwnmi machine check code pops the soft-irq checks in rtas_call
>> (after the previous patch to remove rtas_token from this call path).
>  ^
>  I changed this to "next" which I think is what you meant?

Yes I rearranged them, so yes.

Thanks,
Nick


Re: [PATCH v4 04/16] powerpc/64s/exceptions: machine check reconcile irq state

2020-05-08 Thread Michael Ellerman
Nicholas Piggin  writes:

> pseries fwnmi machine check code pops the soft-irq checks in rtas_call
> (after the previous patch to remove rtas_token from this call path).
 ^
 I changed this to "next" which I think is what you meant?

cheers

> Rather than play whack a mole with these and forever having fragile
> code, it seems better to have the early machine check handler perform
> the same kind of reconcile as the other NMI interrupts.
>
>   WARNING: CPU: 0 PID: 493 at arch/powerpc/kernel/irq.c:343
>   CPU: 0 PID: 493 Comm: a Tainted: GW
>   NIP:  c001ed2c LR: c0042c40 CTR: 
>   REGS: c001fffd38b0 TRAP: 0700   Tainted: GW
>   MSR:  80021003   CR: 28000488  XER: 
>   CFAR: c001ec90 IRQMASK: 0
>   GPR00: c0043820 c001fffd3b40 c12ba300 
>   GPR04: 48000488   deadbeef
>   GPR08: 0080   1001
>   GPR12:  c14a  
>   GPR16:    
>   GPR20:    
>   GPR24:    
>   GPR28:  0001 c1360810 
>   NIP [c001ed2c] arch_local_irq_restore.part.0+0xac/0x100
>   LR [c0042c40] unlock_rtas+0x30/0x90
>   Call Trace:
>   [c001fffd3b40] [c1360810] 0xc1360810 (unreliable)
>   [c001fffd3b60] [c0043820] rtas_call+0x1c0/0x280
>   [c001fffd3bb0] [c00dc328] fwnmi_release_errinfo+0x38/0x70
>   [c001fffd3c10] [c00dcd8c] 
> pseries_machine_check_realmode+0x1dc/0x540
>   [c001fffd3cd0] [c003fe04] machine_check_early+0x54/0x70
>   [c001fffd3d00] [c0008384] machine_check_early_common+0x134/0x1f0
>   --- interrupt: 200 at 0x13f1307c8
>   LR = 0x7fff888b8528
>   Instruction dump:
>   6000 7d2000a6 71298000 41820068 3922 7d210164 4b9c 6000
>   6000 7d2000a6 71298000 4c820020 <0fe0> 4e800020 6000 6000
>
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/kernel/exceptions-64s.S | 19 +++
>  1 file changed, 19 insertions(+)
>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S 
> b/arch/powerpc/kernel/exceptions-64s.S
> index a42b73efb1a9..072772803b7c 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1116,11 +1116,30 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
>   li  r10,MSR_RI
>   mtmsrd  r10,1
>  
> + /*
> +  * Set IRQS_ALL_DISABLED and save PACAIRQHAPPENED (see
> +  * system_reset_common)
> +  */
> + li  r10,IRQS_ALL_DISABLED
> + stb r10,PACAIRQSOFTMASK(r13)
> + lbz r10,PACAIRQHAPPENED(r13)
> + std r10,RESULT(r1)
> + ori r10,r10,PACA_IRQ_HARD_DIS
> + stb r10,PACAIRQHAPPENED(r13)
> +
>   addir3,r1,STACK_FRAME_OVERHEAD
>   bl  machine_check_early
>   std r3,RESULT(r1)   /* Save result */
>   ld  r12,_MSR(r1)
>  
> + /*
> +  * Restore soft mask settings.
> +  */
> + ld  r10,RESULT(r1)
> + stb r10,PACAIRQHAPPENED(r13)
> + ld  r10,SOFTE(r1)
> + stb r10,PACAIRQSOFTMASK(r13)
> +
>  #ifdef CONFIG_PPC_P7_NAP
>   /*
>* Check if thread was in power saving mode. We come here when any
> -- 
> 2.23.0


[PATCH v4 04/16] powerpc/64s/exceptions: machine check reconcile irq state

2020-05-07 Thread Nicholas Piggin
pseries fwnmi machine check code pops the soft-irq checks in rtas_call
(after the previous patch to remove rtas_token from this call path).
Rather than play whack a mole with these and forever having fragile
code, it seems better to have the early machine check handler perform
the same kind of reconcile as the other NMI interrupts.

  WARNING: CPU: 0 PID: 493 at arch/powerpc/kernel/irq.c:343
  CPU: 0 PID: 493 Comm: a Tainted: GW
  NIP:  c001ed2c LR: c0042c40 CTR: 
  REGS: c001fffd38b0 TRAP: 0700   Tainted: GW
  MSR:  80021003   CR: 28000488  XER: 
  CFAR: c001ec90 IRQMASK: 0
  GPR00: c0043820 c001fffd3b40 c12ba300 
  GPR04: 48000488   deadbeef
  GPR08: 0080   1001
  GPR12:  c14a  
  GPR16:    
  GPR20:    
  GPR24:    
  GPR28:  0001 c1360810 
  NIP [c001ed2c] arch_local_irq_restore.part.0+0xac/0x100
  LR [c0042c40] unlock_rtas+0x30/0x90
  Call Trace:
  [c001fffd3b40] [c1360810] 0xc1360810 (unreliable)
  [c001fffd3b60] [c0043820] rtas_call+0x1c0/0x280
  [c001fffd3bb0] [c00dc328] fwnmi_release_errinfo+0x38/0x70
  [c001fffd3c10] [c00dcd8c] 
pseries_machine_check_realmode+0x1dc/0x540
  [c001fffd3cd0] [c003fe04] machine_check_early+0x54/0x70
  [c001fffd3d00] [c0008384] machine_check_early_common+0x134/0x1f0
  --- interrupt: 200 at 0x13f1307c8
  LR = 0x7fff888b8528
  Instruction dump:
  6000 7d2000a6 71298000 41820068 3922 7d210164 4b9c 6000
  6000 7d2000a6 71298000 4c820020 <0fe0> 4e800020 6000 6000

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/kernel/exceptions-64s.S | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index a42b73efb1a9..072772803b7c 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1116,11 +1116,30 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
li  r10,MSR_RI
mtmsrd  r10,1
 
+   /*
+* Set IRQS_ALL_DISABLED and save PACAIRQHAPPENED (see
+* system_reset_common)
+*/
+   li  r10,IRQS_ALL_DISABLED
+   stb r10,PACAIRQSOFTMASK(r13)
+   lbz r10,PACAIRQHAPPENED(r13)
+   std r10,RESULT(r1)
+   ori r10,r10,PACA_IRQ_HARD_DIS
+   stb r10,PACAIRQHAPPENED(r13)
+
addir3,r1,STACK_FRAME_OVERHEAD
bl  machine_check_early
std r3,RESULT(r1)   /* Save result */
ld  r12,_MSR(r1)
 
+   /*
+* Restore soft mask settings.
+*/
+   ld  r10,RESULT(r1)
+   stb r10,PACAIRQHAPPENED(r13)
+   ld  r10,SOFTE(r1)
+   stb r10,PACAIRQSOFTMASK(r13)
+
 #ifdef CONFIG_PPC_P7_NAP
/*
 * Check if thread was in power saving mode. We come here when any
-- 
2.23.0