All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH v2 11/44] powerpc/64s/exception: machine check restructure to reuse common macros
Date: Fri,  2 Aug 2019 20:56:36 +1000	[thread overview]
Message-ID: <20190802105709.27696-12-npiggin@gmail.com> (raw)
In-Reply-To: <20190802105709.27696-1-npiggin@gmail.com>

Follow the pattern of sreset and HMI handlers more closely: use
EXCEPTION_PROLOG_COMMON_1 rather than open-coding it, and run the
handler at the relocated location.

This helps later simplification and code sharing.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 71 ++++++++++++++--------------
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index b83379cb6d23..527a76aa0832 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -934,17 +934,23 @@ EXC_COMMON_BEGIN(system_reset_common)
 
 EXC_REAL_BEGIN(machine_check, 0x200, 0x100)
 	EXCEPTION_PROLOG_0 PACA_EXMC
-	b	machine_check_common_early
+	EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 1, 1, 0
+	mfctr	r10			/* save ctr, even for !RELOCATABLE */
+	BRANCH_TO_C000(r11, machine_check_early_common)
+	/*
+	 * MSR_RI is not enabled, because PACA_EXMC is being used, so a
+	 * nested machine check corrupts it. machine_check_common enables
+	 * MSR_RI.
+	 */
 EXC_REAL_END(machine_check, 0x200, 0x100)
 EXC_VIRT_NONE(0x4200, 0x100)
-TRAMP_REAL_BEGIN(machine_check_common_early)
-	EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 0, 0, 0
+
+EXC_COMMON_BEGIN(machine_check_early_common)
+	mtctr	r10			/* Restore ctr */
+	mfspr	r11,SPRN_SRR0
+	mfspr	r12,SPRN_SRR1
+
 	/*
-	 * Register contents:
-	 * R13		= PACA
-	 * R9		= CR
-	 * Original R9 to R13 is saved on PACA_EXMC
-	 *
 	 * Switch to mc_emergency stack and handle re-entrancy (we limit
 	 * the nested MCE upto level 4 to avoid stack overflow).
 	 * Save MCE registers srr1, srr0, dar and dsisr and then set ME=1
@@ -965,32 +971,30 @@ TRAMP_REAL_BEGIN(machine_check_common_early)
 	 * the machine check is handled then the idle wakeup code is called
 	 * to restore state.
 	 */
-	mr	r11,r1			/* Save r1 */
 	lhz	r10,PACA_IN_MCE(r13)
 	cmpwi	r10,0			/* Are we in nested machine check */
-	bne	0f			/* Yes, we are. */
-	/* First machine check entry */
-	ld	r1,PACAMCEMERGSP(r13)	/* Use MC emergency stack */
-0:	subi	r1,r1,INT_FRAME_SIZE	/* alloc stack frame */
+	cmpwi	cr1,r10,MAX_MCE_DEPTH	/* Are we at maximum nesting */
 	addi	r10,r10,1		/* increment paca->in_mce */
 	sth	r10,PACA_IN_MCE(r13)
+
+	mr	r10,r1			/* Save r1 */
+	bne	1f
+	/* First machine check entry */
+	ld	r1,PACAMCEMERGSP(r13)	/* Use MC emergency stack */
+1:	subi	r1,r1,INT_FRAME_SIZE	/* alloc stack frame */
 	/* Limit nested MCE to level 4 to avoid stack overflow */
-	cmpwi	r10,MAX_MCE_DEPTH
-	bgt	2f			/* Check if we hit limit of 4 */
-	std	r11,GPR1(r1)		/* Save r1 on the stack. */
-	std	r11,0(r1)		/* make stack chain pointer */
-	mfspr	r11,SPRN_SRR0		/* Save SRR0 */
-	std	r11,_NIP(r1)
-	mfspr	r11,SPRN_SRR1		/* Save SRR1 */
-	std	r11,_MSR(r1)
-	mfspr	r11,SPRN_DAR		/* Save DAR */
-	std	r11,_DAR(r1)
-	mfspr	r11,SPRN_DSISR		/* Save DSISR */
-	std	r11,_DSISR(r1)
-	std	r9,_CCR(r1)		/* Save CR in stackframe */
+	bge	cr1,2f			/* Check if we hit limit of 4 */
+
+	EXCEPTION_PROLOG_COMMON_1()
 	/* We don't touch AMR here, we never go to virtual mode */
-	/* Save r9 through r13 from EXMC save area to stack frame. */
 	EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
+	EXCEPTION_PROLOG_COMMON_3(0x200)
+
+	ld	r3,PACA_EXMC+EX_DAR(r13)
+	lwz	r4,PACA_EXMC+EX_DSISR(r13)
+	std	r3,_DAR(r1)
+	std	r4,_DSISR(r1)
+
 	mfmsr	r11			/* get MSR value */
 BEGIN_FTR_SECTION
 	ori	r11,r11,MSR_ME		/* turn on ME bit */
@@ -1016,8 +1020,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
 
 #ifdef CONFIG_PPC_PSERIES
 TRAMP_REAL_BEGIN(machine_check_fwnmi)
+	/* See comment at machine_check exception, don't turn on RI */
 	EXCEPTION_PROLOG_0 PACA_EXMC
-	b	machine_check_common_early
+	EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 1, 1, 0
+	mfctr	r10		/* save ctr */
+	BRANCH_TO_C000(r11, machine_check_early_common)
 #endif
 
 TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
@@ -1088,8 +1095,6 @@ EXC_COMMON_BEGIN(machine_check_idle_common)
 	 * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack.
 	 */
 EXC_COMMON_BEGIN(machine_check_handle_early)
-	std	r0,GPR0(r1)	/* Save r0 */
-	EXCEPTION_PROLOG_COMMON_3(0x200)
 	bl	save_nvgprs
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	bl	machine_check_early
@@ -1180,14 +1185,10 @@ BEGIN_FTR_SECTION
 	mtspr	SPRN_CFAR,r10
 END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 	MACHINE_CHECK_HANDLER_WINDUP
+	/* See comment at machine_check exception, don't turn on RI */
 	EXCEPTION_PROLOG_0 PACA_EXMC
 	EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0
 	EXCEPTION_PROLOG_2_REAL machine_check_common, EXC_STD, 0
-	/*
-	 * MSR_RI is not enabled, because PACA_EXMC is being used, so a
-	 * nested machine check corrupts it. machine_check_common enables
-	 * MSR_RI.
-	 */
 
 EXC_COMMON_BEGIN(unrecover_mce)
 	/* Invoke machine_check_exception to print MCE event and panic. */
-- 
2.22.0


  parent reply	other threads:[~2019-08-02 11:27 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 10:56 [PATCH v2 00/44] powerpc/64s/exception: cleanup and macrofiy, Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 01/44] powerpc/64s/exception: machine check fwnmi remove HV case Nicholas Piggin
2019-09-02  3:29   ` Michael Ellerman
2019-08-02 10:56 ` [PATCH v2 02/44] powerpc/64s/exception: machine check remove bitrotted comment Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 03/44] powerpc/64s/exception: machine check fix KVM guest test Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 04/44] powerpc/64s/exception: machine check adjust RFI target Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 05/44] powerpc/64s/exception: machine check pseries should always run the early handler Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 06/44] powerpc/64s/exception: machine check remove machine_check_pSeries_0 branch Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 07/44] powerpc/64s/exception: machine check use correct cfar for late handler Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 08/44] powerpc/64s/powernv: machine check dump SLB contents Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 09/44] powerpc/64s/pseries: machine check convert to use common event code Nicholas Piggin
2019-08-08  5:01   ` kbuild test robot
2019-08-16 22:25     ` Michael Ellerman
2019-08-19 13:09       ` Nicholas Piggin
2019-08-08  5:50   ` kbuild test robot
2019-08-02 10:56 ` [PATCH v2 10/44] powerpc/64s/exception: machine check pseries should skip the late handler for kernel MCEs Nicholas Piggin
2019-08-02 10:56 ` Nicholas Piggin [this message]
2019-08-02 10:56 ` [PATCH v2 12/44] powerpc/64s/exception: machine check move tramp code Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 13/44] powerpc/64s/exception: simplify machine check early path Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 14/44] powerpc/64s/exception: machine check move unrecoverable handling out of line Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 15/44] powerpc/64s/exception: untangle early machine check handler branch Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 16/44] powerpc/64s/exception: machine check improve labels and comments Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 17/44] powerpc/64s/exception: Fix DAR load for handle_page_fault error case Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 18/44] powerpc/64s/exception: move head-64.h exception code to exception-64s.S Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 19/44] powerpc/64s/exception: Add EXC_HV_OR_STD, which selects HSRR if HVMODE Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 20/44] powerpc/64s/exception: Fix performance monitor virt handler Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 21/44] powerpc/64s/exception: remove 0xb00 handler Nicholas Piggin
2019-08-21 12:18   ` Michael Ellerman
2019-08-02 10:56 ` [PATCH v2 22/44] powerpc/64s/exception: Replace PROLOG macros and EXC helpers with a gas macro Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 23/44] powerpc/64s/exception: remove EXCEPTION_PROLOG_0/1, rename _2 Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 24/44] powerpc/64s/exception: Add the virt variant of the denorm interrupt handler Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 25/44] powerpc/64s/exception: INT_HANDLER support HDAR/HDSISR and use it in HDSI Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 26/44] powerpc/64s/exception: Add INT_KVM_HANDLER gas macro Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 27/44] powerpc/64s/exception: KVM_HANDLER reorder arguments to match other macros Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 28/44] powerpc/64s/exception: Merge EXCEPTION_PROLOG_COMMON_2/3 Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 29/44] powerpc/64s/exception: Add INT_COMMON gas macro to generate common exception code Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 30/44] powerpc/64s/exception: Expand EXCEPTION_COMMON macro into caller Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 31/44] powerpc/64s/exception: Expand EXCEPTION_PROLOG_COMMON_1 and 2 " Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 32/44] powerpc/64s/exception: INT_COMMON add DAR, DSISR, reconcile options Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 33/44] powerpc/64s/exception: move interrupt entry code above the common handler Nicholas Piggin
2019-08-02 10:56 ` [PATCH v2 34/44] powerpc/64s/exception: program check handler do not branch into a macro Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 35/44] powerpc/64s/exception: Remove pointless KVM handler name bifurcation Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 36/44] powerpc/64s/exception: reduce page fault unnecessary loads Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 37/44] powerpc/64s/exception: Introduce INT_DEFINE parameter block for code generation Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 38/44] powerpc/64s/exception: Add GEN_COMMON macro that uses INT_DEFINE parameters Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 39/44] powerpc/64s/exception: Add GEN_KVM " Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 40/44] powerpc/64s/exception: Expand EXC_COMMON and EXC_COMMON_ASYNC macros Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 41/44] powerpc/64s/exception: Move all interrupt handlers to new style code gen macros Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 42/44] powerpc/64s/exception: Remove old INT_ENTRY macro Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 43/44] powerpc/64s/exception: Remove old INT_COMMON macro Nicholas Piggin
2019-08-02 10:57 ` [PATCH v2 44/44] powerpc/64s/exception: Remove old INT_KVM_HANDLER Nicholas Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190802105709.27696-12-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.