From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/9] arm64: introduce an order for exceptions
Date: Wed, 24 May 2017 17:57:59 +0100 [thread overview]
Message-ID: <20170524165806.29866-3-james.morse@arm.com> (raw)
In-Reply-To: <20170524165806.29866-1-james.morse@arm.com>
Lets define an order for masking and unmasking exceptions. 'dai' is
memorable and effectively what we have today.
Masking debug exceptions should cause all other exceptions to be masked
too. Masking SError should mask irq, but not debug exception. Masking
irqs has no side effects for other flags. Keeping to this order makes it
easier for entry.S to know which exceptions should be unmasked.
FIQ is never expected, but we mask it when we mask debug exceptions, and
unmask it at all other times.
Given masking debug exceptions masks everything, we don't need macros
to save/restore that bit independently. Remove them and switch the last
caller over to {en,dis}able_daif().
Signed-off-by: James Morse <james.morse@arm.com>
---
arch/arm64/include/asm/irqflags.h | 33 +++++++++++++--------------------
arch/arm64/kernel/debug-monitors.c | 4 ++--
2 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/arch/arm64/include/asm/irqflags.h b/arch/arm64/include/asm/irqflags.h
index 937e5615e690..e8dd74cbb91a 100644
--- a/arch/arm64/include/asm/irqflags.h
+++ b/arch/arm64/include/asm/irqflags.h
@@ -21,6 +21,19 @@
#include <asm/ptrace.h>
/*
+ * Aarch64 has flags for masking: Debug, Asynchronous (serror), Interrupts and
+ * FIQ exceptions, in the 'daif' register. We mask and unmask them in 'dai'
+ * order:
+ * Masking debug exceptions should causes all other exceptions to be masked
+ * too. Masking SError should mask irq, but not debug exceptions. Masking
+ * irqs has no side effects for other flags. Keeping to this order makes it
+ * easier for entry.S to know which exceptions should be unmasked.
+ *
+ * FIQ is never expected, but we mask it when we mask debug exceptions, and
+ * unmask it at all other times.
+ */
+
+/*
* CPU interrupt mask handling.
*/
static inline unsigned long arch_local_irq_save(void)
@@ -91,26 +104,6 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
}
/*
- * save and restore debug state
- */
-#define local_dbg_save(flags) \
- do { \
- typecheck(unsigned long, flags); \
- asm volatile( \
- "mrs %0, daif // local_dbg_save\n" \
- "msr daifset, #8" \
- : "=r" (flags) : : "memory"); \
- } while (0)
-
-#define local_dbg_restore(flags) \
- do { \
- typecheck(unsigned long, flags); \
- asm volatile( \
- "msr daif, %0 // local_dbg_restore\n" \
- : : "r" (flags) : "memory"); \
- } while (0)
-
-/*
* Mask/unmask/restore all exceptions, including interrupts. If the I bit
* is modified the caller should call trace_hardirqs_{on,off}().
*/
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index d618e25c3de1..56cb27bfa650 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -46,9 +46,9 @@ u8 debug_monitors_arch(void)
static void mdscr_write(u32 mdscr)
{
unsigned long flags;
- local_dbg_save(flags);
+ flags = local_mask_daif();
write_sysreg(mdscr, mdscr_el1);
- local_dbg_restore(flags);
+ local_restore_daif(flags);
}
NOKPROBE_SYMBOL(mdscr_write);
--
2.11.0
next prev parent reply other threads:[~2017-05-24 16:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 16:57 [PATCH 0/9] SError rework to support RAS notifications via SEI James Morse
2017-05-24 16:57 ` [PATCH 1/9] arm64: explicitly mask all exceptions James Morse
2017-05-24 16:57 ` James Morse [this message]
2017-05-24 16:58 ` [PATCH 3/9] arm64: unmask all exceptions on CPU startup James Morse
2017-05-24 16:58 ` [PATCH 4/9] arm64: entry.S: mask all exceptions during kernel_exit James Morse
2017-05-24 16:58 ` [PATCH 5/9] arm64: entry.S: move enable_step_tsk into kernel_exit James Morse
2017-05-24 16:58 ` [PATCH 6/9] arm64: entry.S: convert el1_sync James Morse
2017-05-24 16:58 ` [PATCH 7/9] arm64: entry.S convert el0_sync James Morse
2017-05-24 16:58 ` [PATCH 8/9] arm64: entry.S: convert elX_irq James Morse
2017-05-24 16:58 ` [PATCH 9/9] arm64: entry.S: move SError handling into a C function for future expansion James Morse
2017-06-14 17:13 ` [PATCH 10/9] arm64: cpufeature: Detect CPU RAS Extensions James Morse
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=20170524165806.29866-3-james.morse@arm.com \
--to=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).