powerpc: misc interrupt and context tracking
Subsystems (2)
Nicholas Piggin
reviewerPATCH v2 2/2 powerpc/64/interrupt: Prevent NMI PMI causing a dangerous warning
In reply to Nicholas PigginNMI PMIs really should not return using the normal interrupt_return function. If such a PMI hits in code returning to user with the context switched to user mode, this warning can fire. This was enough to cause crashes when reproducing on 64s, because another perf interrupt would hit while reporting bug, and that would cause another bug, and so on until smashing the stack.
Work around that particular crash for now by just disabling that context warning for PMIs. This is a hack and not a complete fix, there could be other such problems lurking in corners. But it does fix the known crash.
--- arch/powerpc/kernel/exceptions-64e.S | 7 +++++++ arch/powerpc/kernel/exceptions-64s.S | 7 +++++++ arch/powerpc/kernel/interrupt.c | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-)
arch/powerpc/kernel/exceptions-64e.S +7 -0
@@ -813,6 +813,13 @@ kernel_dbg_exc: EXCEPTION_COMMON(0x260) CHECK_NAPPING() addi r3,r1,STACK_FRAME_OVERHEAD + /* + * XXX: Returning from performance_monitor_exception taken as a + * soft-NMI (Linux irqs disabled) may be risky to use interrupt_return + * and could cause bugs in return or elsewhere. That case should just + * restore registers and return. There is a workaround for one known + * problem in interrupt_exit_kernel_prepare(). + */ bl performance_monitor_exception b interrupt_return
arch/powerpc/kernel/exceptions-64s.S +7 -0
@@ -2357,6 +2357,13 @@ EXC_VIRT_END(performance_monitor, 0x4f00, 0x20) EXC_COMMON_BEGIN(performance_monitor_common) GEN_COMMON performance_monitor addi r3,r1,STACK_FRAME_OVERHEAD + /* + * XXX: Returning from performance_monitor_exception taken as a + * soft-NMI (Linux irqs disabled) may be risky to use interrupt_return + * and could cause bugs in return or elsewhere. That case should just + * restore registers and return. There is a workaround for one known + * problem in interrupt_exit_kernel_prepare(). + */ bl performance_monitor_exception b interrupt_return_srr
arch/powerpc/kernel/interrupt.c +9 -3
@@ -374,10 +374,16 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)if (regs_is_unrecoverable (regs))unrecoverable_exception (regs);/* -* CT_WARN_ON comes here via program_check_exception, -* so avoid recursion. +* CT_WARN_ON comes here via program_check_exception, so avoid +* recursion. +* +* Skip the assertion on PMIs to work around a problem caused by NMI +* PMIs incorrectly taking this interrupt return path, it's possible +* for this to hit after interrupt exit to user switches context to +* user. See also the comment in the performance monitor handler in +* exceptions-64e/s.S */ -if (TRAP (regs) !=INTERRUPT_PROGRAM ) +if (TRAP (regs) !=INTERRUPT_PROGRAM &&TRAP (regs) !=INTERRUPT_PERFMON )CT_WARN_ON (ct_state () ==CONTEXT_USER ); kuap =kuap_get_and_assert_locked ();
Signature · 1 line
2.37.2
Nicholas Piggin
reviewerv2 cover powerpc: misc interrupt and context tracking
These are several fixes for regressions and crash bugs. Since v1 I cut down the fixes to a minimum.
Thanks,
Nick
Nicholas Piggin (2):
KVM: PPC: BookS PR-KVM and BookE do not support context tracking powerpc/64/interrupt: Prevent NMI PMI causing a dangerous warning
arch/powerpc/kernel/exceptions-64e.S | 7 +++++++ arch/powerpc/kernel/exceptions-64s.S | 7 +++++++ arch/powerpc/kernel/interrupt.c | 12 +++++++++--- arch/powerpc/kvm/Kconfig | 4 ++++ 4 files changed, 27 insertions(+), 3 deletions(-)
Signature · 1 line
2.37.2
Nicholas Piggin
reviewerPATCH v2 1/2 KVM: PPC: BookS PR-KVM and BookE do not support context tracking
The context tracking code in PR-KVM and BookE implementations is not complete, and can cause host crashes if context tracking is enabled.
Make these implementations depend on !CONTEXT_TRACKING_USER.
--- arch/powerpc/kvm/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/kvm/Kconfig +4 -0
@@ -51,6 +51,7 @@ config KVM_BOOK3S_HV_POSSIBLE config KVM_BOOK3S_32 tristate "KVM support for PowerPC book3s_32 processors" depends on PPC_BOOK3S_32 && !SMP && !PTE_64BIT + depends on !CONTEXT_TRACKING_USER select KVM select KVM_BOOK3S_32_HANDLER select KVM_BOOK3S_PR_POSSIBLE
@@ -105,6 +106,7 @@ config KVM_BOOK3S_64_HV config KVM_BOOK3S_64_PR tristate "KVM support without using hypervisor mode in host" depends on KVM_BOOK3S_64 + depends on !CONTEXT_TRACKING_USER select KVM_BOOK3S_PR_POSSIBLE help Support running guest kernels in virtual machines on processors
@@ -190,6 +192,7 @@ config KVM_EXIT_TIMING config KVM_E500V2 bool "KVM support for PowerPC E500v2 processors" depends on PPC_E500 && !PPC_E500MC + depends on !CONTEXT_TRACKING_USER select KVM select KVM_MMIO select MMU_NOTIFIER
@@ -205,6 +208,7 @@ config KVM_E500V2 config KVM_E500MC bool "KVM support for PowerPC E500MC/E5500/E6500 processors" depends on PPC_E500MC + depends on !CONTEXT_TRACKING_USER select KVM select KVM_MMIO select KVM_BOOKE_HV
Signature · 1 line
2.37.2
Michael Ellerman
AppliedQuoted 11 lines · Nicholas Piggin
These are several fixes for regressions and crash bugs. Since v1 I cut down the fixes to a minimum.
Thanks,
NickNicholas Piggin (2):
KVM: PPC: BookS PR-KVM and BookE do not support context tracking powerpc/64/interrupt: Prevent NMI PMI causing a dangerous warning[...]
Applied to powerpc/fixes.
[1/2] KVM: PPC: BookS PR-KVM and BookE do not support context tracking
https://git.kernel.org/powerpc/c/e59b3399fde5e173b026d4952b215043e77b4521 [2/2] powerpc/64/interrupt: Prevent NMI PMI causing a dangerous warning https://git.kernel.org/powerpc/c/a073672eb09670540e95a2a4aa1c46f5da74159f
cheers