diff mbox series

[4/4] arm64: patching: mask exceptions in patch_machine()

Message ID 20211203104723.3412383-5-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: ensure CPUs are quiescent before patching | expand

Commit Message

Mark Rutland Dec. 3, 2021, 10:47 a.m. UTC
To ensure that CPUs remain quiescent during patching, they must not take
exceptions. Ensure this by masking DAIF during the code patch_machine()
logic.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/patching.c | 6 ++++++
 1 file changed, 6 insertions(+)

James, I think w need something similar for SDEI here, but I wasn't sure
what I should use for a save..restore sequence. Any thoughts?

Thanks,
Mark.
diff mbox series

Patch

diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c
index 04497dbf14e2..797bca33a13d 100644
--- a/arch/arm64/kernel/patching.c
+++ b/arch/arm64/kernel/patching.c
@@ -7,6 +7,7 @@ 
 #include <linux/uaccess.h>
 
 #include <asm/cacheflush.h>
+#include <asm/daifflags.h>
 #include <asm/fixmap.h>
 #include <asm/insn.h>
 #include <asm/kprobes.h>
@@ -127,9 +128,12 @@  struct patch_machine_info {
 static int noinstr do_patch_machine(void *arg)
 {
 	struct patch_machine_info *pmi = arg;
+	unsigned long flags;
 	int cpu = smp_processor_id();
 	int ret = 0;
 
+	flags = local_daif_save();
+
 	if (pmi->cpu == cpu) {
 		while (arch_atomic_read(&pmi->active))
 			cpu_relax();
@@ -142,6 +146,8 @@  static int noinstr do_patch_machine(void *arg)
 		isb();
 	}
 
+	local_daif_restore(flags);
+
 	return ret;
 }