[PATCH v1 11/18] arm64/hibernate: Disable NMIs while hibernating
Mark Brown
broonie at kernel.org
Fri Nov 4 16:54:46 PDT 2022
We disable interrupts during the final stages of hibernation to ensure we
preserve a consistent image, 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/hibernate.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
index af5df48ba915..71b8979eb2f2 100644
--- a/arch/arm64/kernel/hibernate.c
+++ b/arch/arm64/kernel/hibernate.c
@@ -26,6 +26,7 @@
#include <asm/memory.h>
#include <asm/mmu_context.h>
#include <asm/mte.h>
+#include <asm/nmi.h>
#include <asm/sections.h>
#include <asm/smp.h>
#include <asm/smp_plat.h>
@@ -338,6 +339,14 @@ int swsusp_arch_suspend(void)
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);
+
if (__cpu_suspend_enter(&state)) {
/* make the crash dump kernel image visible/saveable */
crash_prepare_suspend();
@@ -386,6 +395,9 @@ int swsusp_arch_suspend(void)
spectre_v4_enable_mitigation(NULL);
}
+ if (system_uses_nmi())
+ sysreg_clear_set(sctlr_el1, 0, SCTLR_EL1_NMI);
+
local_daif_restore(flags);
return ret;
--
2.30.2
More information about the linux-arm-kernel
mailing list