public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail•com>
To: linuxppc-dev@ozlabs•org
Cc: Nicholas Piggin <npiggin@gmail•com>,
	Mahesh Salgaonkar <mahesh@linux•vnet.ibm.com>,
	"Shreyas B . Prabhu" <shreyas@linux•vnet.ibm.com>,
	Stewart Smith <stewart@linux•vnet.ibm.com>
Subject: [PATCH 2/2] powerpc/pseries: PACA save area fix for MCE vs MCE
Date: Wed, 10 Aug 2016 20:48:43 +1000	[thread overview]
Message-ID: <1470826123-14699-3-git-send-email-npiggin@gmail.com> (raw)
In-Reply-To: <1470826005-14520-1-git-send-email-npiggin@gmail.com>

MCE must not enable MSR_RI until PACA_EXMC is no longer being used.
---
 arch/powerpc/kernel/exceptions-64s.S | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 4174c4e..e20ad27 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -500,7 +500,23 @@ machine_check_fwnmi:
 	EXCEPTION_PROLOG_0(PACA_EXMC)
 machine_check_pSeries_0:
 	EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200)
-	EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD)
+	/*
+	 * The following is essentially EXCEPTION_PROLOG_PSERIES_1 with the
+	 * difference that MSR_RI is not enabled, because PACA_EXMC is being
+	 * used, so nested machine check corrupts it. machine_check_common
+	 * enables MSR_RI.
+	 */
+	ld	r12,PACAKBASE(r13)
+	ld	r10,PACAKMSR(r13)
+	xori	r10,r10,MSR_RI
+	mfspr	r11,SPRN_SRR0
+	LOAD_HANDLER(r12, machine_check_common)
+	mtspr	SPRN_SRR0,r12
+	mfspr	r12,SPRN_SRR1
+	mtspr	SPRN_SRR1,r10
+	rfid
+	b	.	/* prevent speculative execution */
+
 	KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
 	KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
 	KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
@@ -992,6 +1008,9 @@ machine_check_common:
 	RECONCILE_IRQ_STATE(r10, r11)
 	ld	r3,PACA_EXMC+EX_DAR(r13)
 	lwz	r4,PACA_EXMC+EX_DSISR(r13)
+	/* Enable MSR_RI when finished with PACA_EXMC */
+	li	r10,MSR_RI
+	mtmsrd 	r10,1
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 	bl	save_nvgprs
-- 
2.8.1

      parent reply	other threads:[~2016-08-10 10:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 10:46 [RFC][PATCH 0/2] powerpc/pseries machine check reentrancy fixes Nicholas Piggin
2016-08-10 10:48 ` [PATCH 1/2] powerpc/pseries: PACA save area fix for general exception vs MCE Nicholas Piggin
2016-08-11  6:45   ` Mahesh Jagannath Salgaonkar
2016-08-10 10:48 ` Nicholas Piggin [this message]

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=1470826123-14699-3-git-send-email-npiggin@gmail.com \
    --to=npiggin@gmail$(echo .)com \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=mahesh@linux$(echo .)vnet.ibm.com \
    --cc=shreyas@linux$(echo .)vnet.ibm.com \
    --cc=stewart@linux$(echo .)vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox