Skip to contentSkip to conversation

arm64: ipipe: route traps to co-kernel

PATCH New Philippe Gerum 1 participant 1 message Sep 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/7 arm64: ipipe: route traps to co-kernel

This commit introduces the changes redirecting traps and exceptions to the interrupt pipeline, so that the co-kernel can be made aware early on. The co-kernel may then decide whether the fault should be propagated to the regular kernel for actual handling.

This is typically useful for allowing the co-kernel to downgrade the current context from the head domain to the root domain, when leaving the burden of handling major faults to the regular kernel makes more sense than expecting the co-kernel to reinvent such a wheel (e.g. memory violations, illegal instructions, divide by zero etc). As a matter of fact, optimizing latency upon such events would not make much sense anyway.

---
 arch/arm64/include/asm/ipipe_base.h |  10 +++
 arch/arm64/kernel/ptrace.c          |   6 +-
 arch/arm64/kernel/traps.c           |   9 ++-
 arch/arm64/mm/fault.c               | 118 +++++++++++++++++++++++++++++++++---
 4 files changed, 131 insertions(+), 12 deletions(-)
arch/arm64/include/asm/ipipe_base.h +10 -0
index e3f8d4f45201..a7c07a1c4271 100644
@@ -80,6 +80,16 @@ unsigned __ipipe_processor_id(void);
 
 /* ARM64 traps */
 #define IPIPE_TRAP_MAYDAY        0	/* Internal recovery trap */
+#define IPIPE_TRAP_ACCESS	 1	/* Data or instruction access exception */
+#define IPIPE_TRAP_SECTION	 2	/* Section fault */
+#define IPIPE_TRAP_DABT		 3	/* Generic data abort */
+#define IPIPE_TRAP_UNKNOWN	 4	/* Unknown exception */
+#define IPIPE_TRAP_BREAK	 5	/* Instruction breakpoint */
+#define IPIPE_TRAP_FPU_ACC	 6	/* Floating point access */
+#define IPIPE_TRAP_FPU_EXC	 7	/* Floating point exception */
+#define IPIPE_TRAP_UNDEFINSTR	 8	/* Undefined instruction */
+#define IPIPE_TRAP_ALIGNMENT	 9	/* Unaligned access exception */
+#define IPIPE_NR_FAULTS         10
 
 #endif /* CONFIG_IPIPE */
 
arch/arm64/kernel/ptrace.c +4 -2
index edaf346d13d5..176860103491 100644
@@ -185,10 +185,12 @@ static void ptrace_hbptriggered(struct perf_event *bp,
 		.si_code	= TRAP_HWBKPT,
 		.si_addr	= (void __user *)(bkpt->trigger),
 	};
+	int i __maybe_unused;
 
-#ifdef CONFIG_COMPAT
-	int i;
+	if (__ipipe_report_trap(IPIPE_TRAP_BREAK, regs))
+		return;
 
+#ifdef CONFIG_COMPAT
 	if (!is_compat_task())
 		goto send_sig;
 
arch/arm64/kernel/traps.c +8 -1
index 4fc0e958770b..c109209d1611 100644
@@ -294,7 +294,7 @@ void arm64_notify_die(const char *str, struct pt_regs *regs,
 }
 
 static LIST_HEAD(undef_hook);
-static DEFINE_RAW_SPINLOCK(undef_lock);
+static IPIPE_DEFINE_RAW_SPINLOCK(undef_lock);
 
 void register_undef_hook(struct undef_hook *hook)
 {
@@ -418,6 +418,9 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
 	if (call_undef_hook(regs) == 0)
 		return;
 
+	if (__ipipe_report_trap(IPIPE_TRAP_UNDEFINSTR, regs))
+		return;
+ 
 	force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
 }
 
@@ -646,6 +649,10 @@ asmlinkage void bad_el0_sync(struct pt_regs *regs, int reason, unsigned int esr)
 {
 	siginfo_t info;
 	void __user *pc = (void __user *)instruction_pointer(regs);
+
+	if (__ipipe_report_trap(IPIPE_TRAP_UNKNOWN, regs))
+		return;
+
 	console_verbose();
 
 	pr_crit("Bad EL0 synchronous exception detected on CPU%d, code 0x%08x -- %s\n",
arch/arm64/mm/fault.c +109 -9

258 lines not on this page · raw message

Signature · 1 line
2.14.4