All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org, James Morse <james.morse@arm.com>
Cc: andre.przywara@arm.com, ardb@kernel.org, catalin.marinas@arm.com,
	joey.gouly@arm.com, mark.rutland@arm.com, suzuki.poulose@arm.com,
	will@kernel.org
Subject: [PATCH 4/4] arm64: patching: mask exceptions in patch_machine()
Date: Fri,  3 Dec 2021 10:47:23 +0000	[thread overview]
Message-ID: <20211203104723.3412383-5-mark.rutland@arm.com> (raw)
In-Reply-To: <20211203104723.3412383-1-mark.rutland@arm.com>

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 --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;
 }
 
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2021-12-03 10:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 10:47 [PATCH 0/4] arm64: ensure CPUs are quiescent before patching Mark Rutland
2021-12-03 10:47 ` [PATCH 1/4] arm64: alternative: wait for other CPUs " Mark Rutland
2021-12-10 14:49   ` Catalin Marinas
2021-12-13 13:01     ` Mark Rutland
2021-12-13 13:27       ` Will Deacon
2021-12-13 13:31   ` Will Deacon
2021-12-13 13:41     ` Will Deacon
2021-12-13 13:54       ` Mark Rutland
2021-12-14 16:01         ` Will Deacon
2021-12-13 13:49     ` Mark Rutland
2021-12-03 10:47 ` [PATCH 2/4] arm64: insn: " Mark Rutland
2021-12-03 10:47 ` [PATCH 3/4] arm64: patching: unify stop_machine() patch synchronization Mark Rutland
2021-12-03 10:47 ` Mark Rutland [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211203104723.3412383-5-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.