[PATCH v1 12/18] arm64/suspend: Disable NMIs while suspending

Mark Brown broonie at kernel.org
Fri Nov 4 16:54:47 PDT 2022


We disable interrupts during the final stages of suspend to ensure we don't
have any code changing state, ensure that NMIs are also masked. Rather than
masking using ALLINT.ALLINT do this by disabling NMIs in SCTLR so that we
don't need to worry about an additional optionally present register in the
assembly sections of code.

Signed-off-by: Mark Brown <broonie at kernel.org>
---
 arch/arm64/kernel/suspend.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index 8b02d310838f..e209ad091648 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -105,6 +105,14 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 	 */
 	flags = local_daif_save();
 
+	/*
+	 * Disable NMIs in SCTLR rather than masking ALLINT so we
+	 * don't have to worry about the state of the FEAT_NMI
+	 * specific register in the asm code.
+	 */
+	if (system_uses_nmi())
+		sysreg_clear_set(sctlr_el1, SCTLR_EL1_NMI, 0);
+
 	/*
 	 * Function graph tracer state gets inconsistent when the kernel
 	 * calls functions that never return (aka suspend finishers) hence
@@ -139,6 +147,9 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 
 	unpause_graph_tracing();
 
+	if (system_uses_nmi())
+		sysreg_clear_set(sctlr_el1, 0, SCTLR_EL1_NMI);
+
 	/*
 	 * Restore pstate flags. OS lock and mdscr have been already
 	 * restored, so from this point onwards, debugging is fully
-- 
2.30.2




More information about the linux-arm-kernel mailing list