diff mbox series

Fix "[v3, 12/32] powerpc/64s/exception: move KVM test to common code"

Message ID 20200401011241.991141-1-npiggin@gmail.com (mailing list archive)
State Accepted
Headers show
Series Fix "[v3, 12/32] powerpc/64s/exception: move KVM test to common code" | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (c6624071c338732402e8c726df6a4074473eaa0e)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (7074695ac6fb965d478f373b95bc5c636e9f21b0)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (29d9f30d4ce6c7a38745a54a8cddface10013490)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (1d0c32ec3b860a32df593a22bad0d1dbc5546a59)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (3eb7cccdb3ae41ebb6a2f5f1ccd2821550c61fe1)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Nicholas Piggin April 1, 2020, 1:12 a.m. UTC
Moving KVM test to the common entry code missed the case of HMI and MCE,
which do not do __GEN_COMMON_ENTRY (because they don't want to switch
to virt mode).

This means a MCE or HMI exception that is taken while KVM is running a
guest context will not be switched out of that context, and KVM won't
be notified. Found by running sigfuz in guest with patched host on
POWER9 DD2.3, which causes some TM related HMI interrupts (which are
expected and supposed to be handled by KVM).

This fix adds a __GEN_REALMODE_COMMON_ENTRY for those handlers to add
the KVM test. This makes them look a little more like other handlers
that all use __GEN_COMMON_ENTRY.

Conflicts with later patches in series:
- powerpc/64s/exception: remove confusing IEARLY option
  Fix: Remove mfspr (H)SRR, keep __GEN_REALMODE_COMMON_ENTRY

- powerpc/64s/exception: trim unused arguments from KVMTEST macro
  Fix: Trim IHSRR IVEC args from the KVMTEST in __GEN_REALMODE_COMMON_ENTRY

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 74809f1b521d..1bc73acceb9a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -451,7 +451,9 @@  END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948)
 
 /*
  * __GEN_COMMON_ENTRY is required to receive the branch from interrupt
- * entry, except in the case of the IEARLY handlers.
+ * entry, except in the case of the real-mode handlers which require
+ * __GEN_REALMODE_COMMON_ENTRY.
+ *
  * This switches to virtual mode and sets MSR[RI].
  */
 .macro __GEN_COMMON_ENTRY name
@@ -487,6 +489,18 @@  DEFINE_FIXED_SYMBOL(\name\()_common_virt)
 	.endif /* IVIRT */
 .endm
 
+/*
+ * Don't switch to virt mode. Used for early MCE and HMI handlers that
+ * want to run in real mode.
+ */
+.macro __GEN_REALMODE_COMMON_ENTRY name
+DEFINE_FIXED_SYMBOL(\name\()_common_real)
+\name\()_common_real:
+	.if IKVM_REAL
+		KVMTEST \name IHSRR IVEC
+	.endif
+.endm
+
 .macro __GEN_COMMON_BODY name
 	.if IMASK
 		lbz	r10,PACAIRQSOFTMASK(r13)
@@ -976,6 +990,8 @@  EXC_COMMON_BEGIN(machine_check_early_common)
 	mfspr	r11,SPRN_SRR0
 	mfspr	r12,SPRN_SRR1
 
+	__GEN_REALMODE_COMMON_ENTRY machine_check_early
+
 	/*
 	 * Switch to mc_emergency stack and handle re-entrancy (we limit
 	 * the nested MCE upto level 4 to avoid stack overflow).
@@ -1831,6 +1847,9 @@  EXC_VIRT_NONE(0x4e60, 0x20)
 EXC_COMMON_BEGIN(hmi_exception_early_common)
 	mfspr	r11,SPRN_HSRR0		/* Save HSRR0 */
 	mfspr	r12,SPRN_HSRR1		/* Save HSRR1 */
+
+	__GEN_REALMODE_COMMON_ENTRY hmi_exception_early
+
 	mr	r10,r1			/* Save r1 */
 	ld	r1,PACAEMERGSP(r13)	/* Use emergency stack for realmode */
 	subi	r1,r1,INT_FRAME_SIZE	/* alloc stack frame		*/