xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Richard Weinberger <richard.weinberger@gmail.com>
Cc: Richard Weinberger <richard@sigma-star.at>,
	Philippe Gerum <rpm@xenomai.org>,
	Xenomai <xenomai@lists.linux.dev>
Subject: Re: [RFC][PATCH] x86: dovetail: Permit to declare a trap handled
Date: Mon, 12 Feb 2024 17:12:31 +0100	[thread overview]
Message-ID: <41296dbe-5e83-4f7d-8963-5c985e83ab30@siemens.com> (raw)
In-Reply-To: <CAFLxGvytJP_ibg0ex4zgyahaxNJH2b_M=Nu3ZBWtrm9neRoW9w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

On 12.02.24 16:14, Richard Weinberger wrote:
> On Mon, Feb 12, 2024 at 4:12 PM Jan Kiszka <jan.kiszka@siemens.com> wrote:
>>>> Ok, so since the idea is generally agreed, I'll push the x86 and arm
>>>> support for this in a couple of days.
>>>
>>> Currently, I'm looking into implementing Johannes's RT-Signals for ARM64,
>>> but from what I see on the dovetail side, only x86 has gained support to declare traps handled.
>>>
>>> At least on x86, I see that a trap is considered handled if no switch to in-band has occurred.
>>> Did I miss something?
>>
>> Yes, I do have some first hacks here as well. ARM and ARM64 is not yet
>> ready for this, unfortunately.
> 
> Can you please share your hacks?
> What is missing? I'll happily continue your work.
> 

Just refreshed [1], and the kernel side hacks are attached (mixture of
Johannes and my WIP changes). Blocker is really the level of kernel
enabling we need/want for non-x86. Those changes can be many. Also a
problem is the information forwarding from the exception handler to the
oob callback - missing in many cases, see also the dances needed in
xnarch_setup_trap_info().

Jan

[1]
https://source.denx.de/Xenomai/xenomai/-/commits/wip/fault-signals/?ref_type=heads

-- 
Siemens AG, Technology
Linux Expert Center

[-- Attachment #2: 0001-add-dovtail-signal-setup-function.patch --]
[-- Type: text/x-patch, Size: 5120 bytes --]

From 4873c7f02d5364646ed4fca272b6336aeb3a5cde Mon Sep 17 00:00:00 2001
From: Johannes Kirchmair <johannes.kirchmair@sigmatek.at>
Date: Tue, 9 May 2023 15:11:51 +0200
Subject: [PATCH 1/3] add dovtail signal setup function

add an interface to dovetail for signal frame setup and restoring.

This is useful for implementing rt signals within Xenomai.

The interface makes it possible to use the setup use functions provided
by Linux.

This is just a proof of concept using a very naive approach using most
of the code provided by Linux to setup signals.
The patch should be discussed, especially considering if using the
Linux functions is viable in a rt context.

Also to discuss would be the interface itself,
for convenience I used the kernels struct ksignal for testing. But maybe
we should maintain our own struct, that is not that feature rich.
---
 arch/x86/include/asm/sighandling.h |  3 ++
 arch/x86/kernel/signal.c           | 71 ++++++++++++++++++++++++++++++
 arch/x86/kernel/signal_32.c        |  2 +-
 arch/x86/kernel/signal_64.c        |  2 +-
 include/linux/dovetail.h           |  4 ++
 5 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/sighandling.h b/arch/x86/include/asm/sighandling.h
index e770c4fc47f4..ed6b7fcd7250 100644
--- a/arch/x86/include/asm/sighandling.h
+++ b/arch/x86/include/asm/sighandling.h
@@ -24,4 +24,7 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);
 int x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);
 int x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);
 
+bool ia32_restore_sigcontext(struct pt_regs *regs, struct sigcontext_32 __user *usc);
+bool restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *usc, unsigned long uc_flags);
+
 #endif /* _ASM_X86_SIGHANDLING_H */
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 65fe2094da59..22db1df10a9d 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -409,3 +409,74 @@ bool sigaltstack_size_valid(size_t ss_size)
 	return true;
 }
 #endif /* CONFIG_DYNAMIC_SIGFRAME */
+
+#ifdef CONFIG_DOVETAIL
+int dovetail_setup_rt_signal_frame(struct ksignal *ksig, struct pt_regs *regs)
+{
+	int ret;
+
+	pagefault_disable();
+
+	if (regs->cs == __USER_CS) {
+	        ret = x64_setup_rt_frame(ksig, regs);
+	} else if (regs->cs == __USER32_CS) {
+	        ksig->ka.sa.sa_flags |= SA_IA32_ABI;
+	        ret = ia32_setup_rt_frame(ksig, regs);
+	} else {
+		ret = -EINVAL;
+	}
+
+	pagefault_enable();
+
+	return ret;
+}
+
+static int dovetail_restore_64_rt_signal_frame(struct pt_regs *regs)
+{
+	struct rt_sigframe __user *frame;
+	unsigned long uc_flags;
+
+	frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
+	if (!access_ok(frame, sizeof(*frame)))
+		return -EFAULT;
+	if (__get_user(uc_flags, &frame->uc.uc_flags))
+		return -EFAULT;
+
+	if (!restore_sigcontext(regs, &frame->uc.uc_mcontext, uc_flags))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int dovetail_restore_32_rt_signal_frame(struct pt_regs *regs)
+{
+	struct rt_sigframe_ia32 __user *frame;
+
+	frame = (struct rt_sigframe_ia32 __user *)(regs->sp - 4);
+	if (!access_ok(frame, sizeof(*frame)))
+	        return -EFAULT;
+
+	if (!ia32_restore_sigcontext(regs, &frame->uc.uc_mcontext))
+	        return -EFAULT;
+
+	return 0;
+}
+
+int dovetail_restore_rt_signal_frame(struct pt_regs *regs)
+{
+	int ret;
+
+	pagefault_disable();
+
+	if (regs->cs == __USER_CS)
+		ret = dovetail_restore_64_rt_signal_frame(regs);
+	else if (regs->cs == __USER32_CS)
+		ret = dovetail_restore_32_rt_signal_frame(regs);
+	else
+		ret = -EINVAL;
+
+	pagefault_enable();
+
+	return ret;
+}
+#endif
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index c12624bc82a3..a494e51e2ec7 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -74,7 +74,7 @@ static inline void reload_segments(struct sigcontext_32 *sc)
 /*
  * Do a signal return; undo the signal stack.
  */
-static bool ia32_restore_sigcontext(struct pt_regs *regs,
+bool ia32_restore_sigcontext(struct pt_regs *regs,
 				    struct sigcontext_32 __user *usc)
 {
 	struct sigcontext_32 sc;
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index 23d8aaf8d9fd..09ae2437b5f3 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -47,7 +47,7 @@ static void force_valid_ss(struct pt_regs *regs)
 		regs->ss = __USER_DS;
 }
 
-static bool restore_sigcontext(struct pt_regs *regs,
+bool restore_sigcontext(struct pt_regs *regs,
 			       struct sigcontext __user *usc,
 			       unsigned long uc_flags)
 {
diff --git a/include/linux/dovetail.h b/include/linux/dovetail.h
index 366260e3291c..c87665728038 100644
--- a/include/linux/dovetail.h
+++ b/include/linux/dovetail.h
@@ -151,6 +151,10 @@ void oob_trampoline(void);
 
 void arch_inband_task_init(struct task_struct *p);
 
+int dovetail_setup_rt_signal_frame(struct ksignal *ksig, struct pt_regs *regs);
+
+int dovetail_restore_rt_signal_frame(struct pt_regs *regs);
+
 int dovetail_start(void);
 
 void dovetail_stop(void);
-- 
2.35.3


[-- Attachment #3: 0002-arm-signal-frames.patch --]
[-- Type: text/x-patch, Size: 5598 bytes --]

From 7bfdc9830fb38adadb849b16383cb1da4b344178 Mon Sep 17 00:00:00 2001
From: Jan Kiszka <jan.kiszka@siemens.com>
Date: Tue, 17 Oct 2023 14:36:57 +0200
Subject: [PATCH 2/3] arm: signal frames

---
 arch/arm/kernel/signal.c | 39 +++++++++++++++++++++++++++++++++++++
 arch/arm/mm/alignment.c  |  3 ++-
 arch/arm/mm/fault.c      | 42 ++++++++++++++++++++++++----------------
 3 files changed, 66 insertions(+), 18 deletions(-)

diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 2631632090c0..6ee172b5e3e3 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -599,6 +599,45 @@ static int do_signal(struct pt_regs *regs, int syscall)
 	return 0;
 }
 
+#ifdef CONFIG_DOVETAIL
+int dovetail_setup_rt_signal_frame(struct ksignal *ksig, struct pt_regs *regs)
+{
+	sigset_t *oldset = sigmask_to_save();
+	int ret;
+
+	pagefault_disable();
+
+	ret = setup_rt_frame(ksig, oldset, regs);
+	ret |= !valid_user_regs(regs);
+
+	pagefault_enable();
+
+	return ret;
+}
+
+int dovetail_restore_rt_signal_frame(struct pt_regs *regs)
+{
+	struct rt_sigframe __user *frame;
+	int ret = 0;
+
+	if (regs->ARM_sp & 7)
+		return -EFAULT;
+
+	frame = (struct rt_sigframe __user *)regs->ARM_sp;
+
+	pagefault_disable();
+
+	if (!access_ok(frame, sizeof (*frame)) ||
+	    restore_sigframe(regs, &frame->sig) ||
+	    restore_altstack(&frame->sig.uc.uc_stack))
+		ret = -EFAULT;
+
+	pagefault_enable();
+
+	return ret;
+}
+#endif
+
 static inline void do_retuser(void)
 {
 	unsigned int thread_flags;
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index b03ce1ded8f5..a5bba966d916 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -813,7 +813,8 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	if (interrupts_enabled(regs))
 		hard_local_irq_enable();
 
-	mark_trap_entry(ARM_TRAP_ALIGNMENT, regs);
+	if (!mark_cond_trap_entry(ARM_TRAP_ALIGNMENT, regs))
+		return 0;
 
 	instrptr = instruction_pointer(regs);
 
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index fd628acecd14..c4ef796c2e92 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -39,7 +39,7 @@
  * preempted by an out-of-band activity.
  */
 static inline
-unsigned long fault_entry(int exception, struct pt_regs *regs)
+bool __fault_entry(int exception, struct pt_regs *regs, unsigned long *pflags)
 {
 	unsigned long flags;
 
@@ -47,11 +47,10 @@ unsigned long fault_entry(int exception, struct pt_regs *regs)
 
 	flags = hard_local_save_flags();
 
-	/*
-	 * The companion core must demote the current context to
-	 * in-band stage if running oob on entry.
-	 */
-	mark_trap_entry(exception, regs);
+	if (!mark_cond_trap_entry(exception, regs)) {
+		hard_local_irq_restore(flags);
+		return false;
+	}
 
 	if (raw_irqs_disabled_flags(flags)) {
 		stall_inband();
@@ -60,9 +59,13 @@ unsigned long fault_entry(int exception, struct pt_regs *regs)
 
 	hard_local_irq_enable();
 
-	return flags;
+	*pflags = flags;
+	return true;
 }
 
+#define fault_entry(__exception, __regs, __flags) \
+	__fault_entry(__exception, __regs, &__flags)
+
 static inline
 void fault_exit(int exception, struct pt_regs *regs,
 		unsigned long flags)
@@ -80,7 +83,7 @@ void fault_exit(int exception, struct pt_regs *regs,
 
 #else	/* !CONFIG_IRQ_PIPELINE */
 
-#define fault_entry(__exception, __regs)  ({ 0; })
+#define fault_entry(__exception, __regs, __flags)  (true)
 #define fault_exit(__exception, __regs, __flags)  \
 	do { (void)(__flags); } while (0)
 
@@ -283,9 +286,10 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	 * have no context to handle this fault with.
 	 */
 	  if (user_mode(regs)) {
-		irqflags = fault_entry(ARM_TRAP_ACCESS, regs);
-		__do_user_fault(addr, fsr, SIGSEGV, SEGV_MAPERR, regs);
-		fault_exit(ARM_TRAP_ACCESS, regs, irqflags);
+		if (fault_entry(ARM_TRAP_ACCESS, regs, irqflags)) {
+			__do_user_fault(addr, fsr, SIGSEGV, SEGV_MAPERR, regs);
+			fault_exit(ARM_TRAP_ACCESS, regs, irqflags);
+		}
 	  } else
 		/*
 		 * irq_pipeline: kernel faults are either quickly
@@ -323,7 +327,8 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	unsigned long vm_flags = VM_ACCESS_FLAGS;
 	unsigned long irqflags;
 
-	irqflags = fault_entry(ARM_TRAP_ACCESS, regs);
+	if (!fault_entry(ARM_TRAP_ACCESS, regs, irqflags))
+		return 0;
 
 	if (kprobe_page_fault(regs, fsr))
 		goto out;
@@ -561,9 +566,10 @@ do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 {
 	unsigned long irqflags;
 
-	irqflags = fault_entry(ARM_TRAP_SECTION, regs);
-	do_bad_area(addr, fsr, regs);
-	fault_exit(ARM_TRAP_SECTION, regs, irqflags);
+	if (fault_entry(ARM_TRAP_SECTION, regs, irqflags)) {
+		do_bad_area(addr, fsr, regs);
+		fault_exit(ARM_TRAP_SECTION, regs, irqflags);
+	}
 	return 0;
 }
 #endif /* CONFIG_ARM_LPAE */
@@ -616,7 +622,8 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
 		return;
 
-	irqflags = fault_entry(ARM_TRAP_DABT, regs);
+	if (!fault_entry(ARM_TRAP_DABT, regs, irqflags))
+		return;
 	pr_alert("8<--- cut here ---\n");
 	pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n",
 		inf->name, fsr, addr);
@@ -649,7 +656,8 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
 	if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
 		return;
 
-	irqflags = fault_entry(ARM_TRAP_PABT, regs);
+	if (!fault_entry(ARM_TRAP_PABT, regs, irqflags))
+		return;
 	pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
 		inf->name, ifsr, addr);
 
-- 
2.35.3


[-- Attachment #4: 0003-arm64-rt-signals.patch --]
[-- Type: text/x-patch, Size: 6040 bytes --]

From 9cb4078aac4e42e6d54d77c9c97140dc7055474e Mon Sep 17 00:00:00 2001
From: Jan Kiszka <jan.kiszka@siemens.com>
Date: Thu, 11 Jan 2024 11:02:34 +0100
Subject: [PATCH 3/3] arm64 rt signals

---
 arch/arm64/kernel/signal.c | 39 ++++++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/traps.c  | 22 ++++++++++-----------
 arch/arm64/mm/fault.c      | 20 +++++++++++++------
 3 files changed, 63 insertions(+), 18 deletions(-)

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index d2ae16680752..1dd55aa1833f 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -1279,6 +1279,45 @@ static void do_signal(struct pt_regs *regs)
 	restore_saved_sigmask();
 }
 
+#ifdef CONFIG_DOVETAIL
+int dovetail_setup_rt_signal_frame(struct ksignal *ksig, struct pt_regs *regs)
+{
+	sigset_t *oldset = sigmask_to_save();
+	int ret;
+
+	pagefault_disable();
+
+	ret = setup_rt_frame(ksig->sig, ksig, oldset, regs);
+	ret |= !valid_user_regs(&regs->user_regs, current);
+
+	pagefault_enable();
+
+	return ret;
+}
+
+int dovetail_restore_rt_signal_frame(struct pt_regs *regs)
+{
+	struct rt_sigframe __user *frame;
+	int ret = 0;
+
+	if (regs->sp & 15)
+		return -EFAULT;
+
+	frame = (struct rt_sigframe __user *)regs->sp;
+
+	pagefault_disable();
+
+	if (!access_ok(frame, sizeof (*frame)) ||
+	    restore_sigframe(regs, frame) ||
+	    restore_altstack(&frame->uc.uc_stack))
+		ret = -EFAULT;
+
+	pagefault_enable();
+
+	return ret;
+}
+#endif
+
 static inline void do_retuser(void)
 {
 	unsigned long thread_flags;
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 6492162e931c..4c14ee5396d1 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -456,14 +456,8 @@ void do_el0_undef(struct pt_regs *regs, unsigned long esr)
 {
 	u32 insn;
 
-	mark_trap_entry(ARM64_TRAP_UNDI, regs);
-
-	/*
-	 * If the companion core did not switched us to in-band
-	 * context, we may assume that it has handled the trap.
-	 */
-	if (running_oob())
-		goto out_exit;
+	if (!mark_cond_trap_entry(ARM64_TRAP_UNDI, regs))
+		return;
 
 	/* check for AArch32 breakpoint instructions */
 	if (!aarch32_break_handler(regs))
@@ -501,7 +495,8 @@ void do_el1_undef(struct pt_regs *regs, unsigned long esr)
 
 void do_el0_bti(struct pt_regs *regs)
 {
-	mark_trap_entry(ARM64_TRAP_BTI, regs);
+	if (!mark_cond_trap_entry(ARM64_TRAP_BTI, regs))
+		return;
 	force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
 	mark_trap_exit(ARM64_TRAP_BTI, regs);
 }
@@ -590,7 +585,8 @@ static void user_cache_maint_handler(unsigned long esr, struct pt_regs *regs)
 	}
 
 	if (ret) {
-		mark_trap_entry(ARM64_TRAP_ACCESS, regs);
+		if (!mark_cond_trap_entry(ARM64_TRAP_ACCESS, regs))
+			return;
 		arm64_notify_segfault(tagged_address);
 		mark_trap_exit(ARM64_TRAP_ACCESS, regs);
 	} else {
@@ -641,7 +637,8 @@ static void mrs_handler(unsigned long esr, struct pt_regs *regs)
 	sysreg = esr_sys64_to_sysreg(esr);
 
 	if (do_emulate_mrs(regs, sysreg, rt) != 0) {
-		mark_trap_entry(ARM64_TRAP_ACCESS, regs);
+		if (!mark_cond_trap_entry(ARM64_TRAP_ACCESS, regs))
+			return;
 		force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
 		mark_trap_exit(ARM64_TRAP_ACCESS, regs);
 	}
@@ -884,7 +881,8 @@ void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr)
 {
 	unsigned long pc = instruction_pointer(regs);
 
-	mark_trap_entry(ARM64_TRAP_ACCESS, regs);
+	if (!mark_cond_trap_entry(ARM64_TRAP_ACCESS, regs))
+		return;
 	current->thread.fault_address = 0;
 	current->thread.fault_code = esr;
 
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 543600b9cf0b..5870a1d0ff8e 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -493,7 +493,8 @@ static void do_bad_area(unsigned long far, unsigned long esr,
 	if (user_mode(regs)) {
 		const struct fault_info *inf = esr_to_fault_info(esr);
 
-		mark_trap_entry(ARM64_TRAP_ACCESS, regs);
+		if (!mark_cond_trap_entry(ARM64_TRAP_ACCESS, regs))
+			return;
 		set_thread_esr(addr, esr);
 		arm64_force_sig_fault(inf->sig, inf->code, far, inf->name);
 		mark_trap_exit(ARM64_TRAP_ACCESS, regs);
@@ -549,7 +550,8 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
 	if (kprobe_page_fault(regs, esr))
 		return 0;
 
-	mark_trap_entry(ARM64_TRAP_ACCESS, regs);
+	if (!mark_cond_trap_entry(ARM64_TRAP_ACCESS, regs))
+		return 0;
 
 	/*
 	 * If we're in an interrupt or have no user context, we must not take
@@ -624,6 +626,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
 	if (fault_signal_pending(fault, regs)) {
 		if (!user_mode(regs))
 			goto no_context;
+		mark_trap_exit(ARM64_TRAP_ACCESS, regs);
 		return 0;
 	}
 lock_mmap:
@@ -645,8 +648,10 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
 	}
 
 	/* The fault is fully completed (including releasing mmap lock) */
-	if (fault & VM_FAULT_COMPLETED)
+	if (fault & VM_FAULT_COMPLETED) {
+		mark_trap_exit(ARM64_TRAP_ACCESS, regs);
 		return 0;
+	}
 
 	if (fault & VM_FAULT_RETRY) {
 		mm_flags |= FAULT_FLAG_TRIED;
@@ -747,7 +752,8 @@ static int do_sea(unsigned long far, unsigned long esr, struct pt_regs *regs)
 	const struct fault_info *inf;
 	unsigned long siaddr;
 
-	mark_trap_entry(ARM64_TRAP_SEA, regs);
+	if (!mark_cond_trap_entry(ARM64_TRAP_SEA, regs))
+		return 0;
 
 	inf = esr_to_fault_info(esr);
 
@@ -864,7 +870,8 @@ void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs)
 	if (!inf->fn(far, esr, regs))
 		return;
 
-	mark_trap_entry(ARM64_TRAP_ACCESS, regs);
+	if (!mark_cond_trap_entry(ARM64_TRAP_ACCESS, regs))
+		return;
 
 	if (!user_mode(regs))
 		die_kernel_fault(inf->name, addr, esr, regs);
@@ -882,7 +889,8 @@ NOKPROBE_SYMBOL(do_mem_abort);
 
 void do_sp_pc_abort(unsigned long addr, unsigned long esr, struct pt_regs *regs)
 {
-	mark_trap_entry(ARM64_TRAP_ALIGN, regs);
+	if (!mark_cond_trap_entry(ARM64_TRAP_ALIGN, regs))
+		return;
 
 	arm64_notify_die("SP/PC alignment exception", regs, SIGBUS, BUS_ADRALN,
 			 addr, esr);
-- 
2.35.3


  reply	other threads:[~2024-02-12 16:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08  7:11 [RFC][PATCH] x86: dovetail: Permit to declare a trap handled Jan Kiszka
2022-07-08  7:12 ` Jan Kiszka
2022-11-09  7:31   ` Johannes Kirchmair
2022-11-09  9:28     ` Jan Kiszka
2022-11-09 10:06       ` Philippe Gerum
2022-11-09 10:38         ` Jan Kiszka
2022-11-09 11:42           ` Johannes Kirchmair
2022-11-10  9:00             ` Philippe Gerum
2024-02-12 15:04               ` Richard Weinberger
2024-02-12 15:12                 ` Jan Kiszka
2024-02-12 15:14                   ` Richard Weinberger
2024-02-12 16:12                     ` Jan Kiszka [this message]
2024-03-28  7:28                       ` Richard Weinberger
2024-04-08 11:59                         ` Jan Kiszka
2022-11-09  7:36 ` Johannes Kirchmair
2022-11-09  9:29   ` Jan Kiszka

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=41296dbe-5e83-4f7d-8963-5c985e83ab30@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=richard.weinberger@gmail.com \
    --cc=richard@sigma-star.at \
    --cc=rpm@xenomai.org \
    --cc=xenomai@lists.linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).