* [PATCH 1/5] arm: dovetail: Fix user mode UND exception handling
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
@ 2025-04-08 12:34 ` Nikolaus Funk
2025-04-08 12:34 ` [PATCH 2/5] x86: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Nikolaus Funk @ 2025-04-08 12:34 UTC (permalink / raw)
To: xenomai; +Cc: richard, Richard Weinberger
From: Richard Weinberger <richard@nod.at>
When a real-time thread triggers an UND (undefined instruction) exception,
it will not be relaxed. As a result, the Linux signal mechanism cannot
deliver a signal to terminate the thread,
often leaving the system unresponsive.
To address this, trigger the ARM_TRAP_UNDEFINSTR trap if no undefined
instruction hook has handled the exception.
Make sure to do this only when the task is running in user mode.
In kernel mode, the UND exception should trigger ARM_TRAP_UNDEFINSTR
via entry-armv.S.
In preparation for real-time aware signals, allow fast exit from
user mode UND exceptions.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/arm/kernel/traps.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 9838b1f3e797..0de8123662b3 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -488,6 +488,9 @@ asmlinkage void do_undefinstr(struct pt_regs *regs)
if (call_undef_hook(regs, instr) == 0)
return;
+ if (user_mode(regs) && !mark_cond_trap_entry(ARM_TRAP_UNDEFINSTR, regs))
+ return;
+
die_sig:
#ifdef CONFIG_DEBUG_USER
if (user_debug & UDBG_UNDEFINED) {
@@ -499,6 +502,9 @@ asmlinkage void do_undefinstr(struct pt_regs *regs)
#endif
arm_notify_die("Oops - undefined instruction", regs,
SIGILL, ILL_ILLOPC, pc, 0, 6);
+
+ if (user_mode(regs))
+ mark_trap_exit(ARM_TRAP_UNDEFINSTR, regs);
}
NOKPROBE_SYMBOL(do_undefinstr)
--
2.48.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 2/5] x86: dovetail: Helper functions for signal frame setup and restore
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
2025-04-08 12:34 ` [PATCH 1/5] arm: dovetail: Fix user mode UND exception handling Nikolaus Funk
@ 2025-04-08 12:34 ` Nikolaus Funk
2025-04-08 12:34 ` [PATCH 3/5] arm64: dovetail: Allow early return from traps Nikolaus Funk
` (3 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Nikolaus Funk @ 2025-04-08 12:34 UTC (permalink / raw)
To: xenomai; +Cc: richard, Lorenz Kofler, Johannes Kirchmair
From: Lorenz Kofler <lorenz@sigma-star.at>
This introduces an interface for handling signal frame setup and restoration,
enabling realtime aware signal support within Xenomai. The implementation uses
existing Linux signal setup functions to avoid code duplication.
Co-developed-by: Johannes Kirchmair <johannes.kirchmair@sigmatek.at>
Co-developed-by: Richard Weinberger <richard@sigma-star.at>
Signed-off-by: Lorenz Kofler <lorenz@sigma-star.at>
---
arch/x86/include/asm/sighandling.h | 3 ++
arch/x86/kernel/signal.c | 80 ++++++++++++++++++++++++++++++
arch/x86/kernel/signal_32.c | 2 +-
arch/x86/kernel/signal_64.c | 2 +-
include/linux/dovetail.h | 4 ++
5 files changed, 89 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 5f441039b572..65fd0f940f4f 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -437,3 +437,83 @@ 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 = 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;
+ int sig;
+
+ 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;
+
+ if (copy_from_user(&sig, &frame->info.si_signo, sizeof(sig)))
+ return -EFAULT;
+
+ return sig;
+}
+
+static int dovetail_restore_32_rt_signal_frame(struct pt_regs *regs)
+{
+ struct rt_sigframe_ia32 __user *frame;
+ int sig;
+
+ 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;
+
+ if (copy_from_user(&sig, &frame->info.si_signo, sizeof(sig)))
+ return -EFAULT;
+
+ return sig;
+}
+
+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 ef654530bf5a..eecc9b2ee4d1 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 ee9453891901..d59e5924a89e 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 31e9d5eaed55..6bde62227c4b 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.48.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 3/5] arm64: dovetail: Allow early return from traps
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
2025-04-08 12:34 ` [PATCH 1/5] arm: dovetail: Fix user mode UND exception handling Nikolaus Funk
2025-04-08 12:34 ` [PATCH 2/5] x86: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
@ 2025-04-08 12:34 ` Nikolaus Funk
2025-04-08 12:58 ` Florian Bezdeka
2025-04-08 17:06 ` Jan Kiszka
2025-04-08 12:34 ` [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
` (2 subsequent siblings)
5 siblings, 2 replies; 17+ messages in thread
From: Nikolaus Funk @ 2025-04-08 12:34 UTC (permalink / raw)
To: xenomai
Cc: richard, Richard Weinberger, Johannes Kirchmair, Jan Kiszka,
Lorenz Kofler
From: Richard Weinberger <richard@nod.at>
Like on the x86 side, allow early return such that
handling the exception on the Linux can get avoided.
Co-developed-by: Johannes Kirchmair <johannes.kirchmair@sigmatek.at>
Co-developed-by: Jan Kiszka <jan.kiszka@siemens.com>
Co-developed-by: Lorenz Kofler <lorenz@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/arm64/kernel/traps.c | 18 ++++++++++--------
arch/arm64/mm/fault.c | 15 ++++++++++-----
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 0f3dcd34be87..fb135f886486 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -462,14 +462,12 @@ 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))
@@ -507,7 +505,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);
}
@@ -613,7 +612,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 {
@@ -672,7 +672,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);
}
@@ -916,7 +917,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 00159c38911e..514382742118 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -486,7 +486,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);
@@ -567,7 +568,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
@@ -818,7 +820,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);
@@ -935,7 +938,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);
@@ -953,7 +957,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_ACCESS, regs))
+ return;
arm64_notify_die("SP/PC alignment exception", regs, SIGBUS, BUS_ADRALN,
addr, esr);
--
2.48.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 3/5] arm64: dovetail: Allow early return from traps
2025-04-08 12:34 ` [PATCH 3/5] arm64: dovetail: Allow early return from traps Nikolaus Funk
@ 2025-04-08 12:58 ` Florian Bezdeka
2025-04-08 13:24 ` Richard Weinberger
2025-04-08 17:06 ` Jan Kiszka
1 sibling, 1 reply; 17+ messages in thread
From: Florian Bezdeka @ 2025-04-08 12:58 UTC (permalink / raw)
To: Nikolaus Funk, xenomai
Cc: richard, Richard Weinberger, Johannes Kirchmair, Jan Kiszka,
Lorenz Kofler
On Tue, 2025-04-08 at 14:34 +0200, Nikolaus Funk wrote:
> 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_ACCESS, regs))
> + return;
>
> arm64_notify_die("SP/PC alignment exception", regs, SIGBUS, BUS_ADRALN,
> addr, esr);
This hunk looks odd: ARM64_TRAP_ALIGN vs. ARM64_TRAP_ACCESS?
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 3/5] arm64: dovetail: Allow early return from traps
2025-04-08 12:58 ` Florian Bezdeka
@ 2025-04-08 13:24 ` Richard Weinberger
0 siblings, 0 replies; 17+ messages in thread
From: Richard Weinberger @ 2025-04-08 13:24 UTC (permalink / raw)
To: Nikolaus Funk, xenomai, Florian Bezdeka
Cc: Richard Weinberger, Johannes Kirchmair, Jan Kiszka, Lorenz Kofler
On Dienstag, 8. April 2025 14:58 Florian Bezdeka wrote:
> On Tue, 2025-04-08 at 14:34 +0200, Nikolaus Funk wrote:
> > 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_ACCESS, regs))
> > + return;
> >
> > arm64_notify_die("SP/PC alignment exception", regs, SIGBUS, BUS_ADRALN,
> > addr, esr);
>
> This hunk looks odd: ARM64_TRAP_ALIGN vs. ARM64_TRAP_ACCESS?
Hmm, yes. Looks like a copy&paste error.
Should be ARM64_TRAP_ALIGN to pair with mark_trap_exit().
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/5] arm64: dovetail: Allow early return from traps
2025-04-08 12:34 ` [PATCH 3/5] arm64: dovetail: Allow early return from traps Nikolaus Funk
2025-04-08 12:58 ` Florian Bezdeka
@ 2025-04-08 17:06 ` Jan Kiszka
2025-04-09 9:47 ` Richard Weinberger
1 sibling, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2025-04-08 17:06 UTC (permalink / raw)
To: Nikolaus Funk, xenomai
Cc: richard, Richard Weinberger, Johannes Kirchmair, Lorenz Kofler
On 08.04.25 14:34, Nikolaus Funk wrote:
> From: Richard Weinberger <richard@nod.at>
>
> Like on the x86 side, allow early return such that
> handling the exception on the Linux can get avoided.
>
Which traps can be caught and fully handled in oob this way? From my
past experiments, that list was not very long - and when I look at your
Xenomai 3 changes, it still isn't. What was particularly hard: DABT and
memory access faults.
Point is that we need to have some kind of consistency, between the
archs and between the reporting information (Linux vs. OOB signals). Or
we extensively need to document where all we are deviating (and ideally
why).
Jan
> Co-developed-by: Johannes Kirchmair <johannes.kirchmair@sigmatek.at>
> Co-developed-by: Jan Kiszka <jan.kiszka@siemens.com>
> Co-developed-by: Lorenz Kofler <lorenz@sigma-star.at>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> arch/arm64/kernel/traps.c | 18 ++++++++++--------
> arch/arm64/mm/fault.c | 15 ++++++++++-----
> 2 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index 0f3dcd34be87..fb135f886486 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
> @@ -462,14 +462,12 @@ 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))
> @@ -507,7 +505,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);
> }
> @@ -613,7 +612,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 {
> @@ -672,7 +672,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);
> }
> @@ -916,7 +917,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 00159c38911e..514382742118 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -486,7 +486,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);
> @@ -567,7 +568,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
> @@ -818,7 +820,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);
>
> @@ -935,7 +938,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);
> @@ -953,7 +957,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_ACCESS, regs))
> + return;
>
> arm64_notify_die("SP/PC alignment exception", regs, SIGBUS, BUS_ADRALN,
> addr, esr);
--
Siemens AG, Foundational Technologies
Linux Expert Center
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 3/5] arm64: dovetail: Allow early return from traps
2025-04-08 17:06 ` Jan Kiszka
@ 2025-04-09 9:47 ` Richard Weinberger
2025-04-09 14:25 ` Jan Kiszka
0 siblings, 1 reply; 17+ messages in thread
From: Richard Weinberger @ 2025-04-09 9:47 UTC (permalink / raw)
To: Nikolaus Funk, xenomai, Jan Kiszka
Cc: Richard Weinberger, Johannes Kirchmair, Lorenz Kofler
On Dienstag, 8. April 2025 19:06 Jan Kiszka wrote:
> On 08.04.25 14:34, Nikolaus Funk wrote:
> > From: Richard Weinberger <richard@nod.at>
> >
> > Like on the x86 side, allow early return such that
> > handling the exception on the Linux can get avoided.
> >
>
> Which traps can be caught and fully handled in oob this way? From my
> past experiments, that list was not very long - and when I look at your
> Xenomai 3 changes, it still isn't. What was particularly hard: DABT and
> memory access faults.
The list is indeed short.
So far ARM64_TRAP_UNDI/BTI and ALIGN look good.
> Point is that we need to have some kind of consistency, between the
> archs and between the reporting information (Linux vs. OOB signals). Or
> we extensively need to document where all we are deviating (and ideally
> why).
I'd vote for the latter.
Plus improving the rt_signal_hist test such that others can
test whether some exception handling is good enough or nor.
So, I suggest exposing more exception but mark/document the known good
ones explicitly.
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/5] arm64: dovetail: Allow early return from traps
2025-04-09 9:47 ` Richard Weinberger
@ 2025-04-09 14:25 ` Jan Kiszka
0 siblings, 0 replies; 17+ messages in thread
From: Jan Kiszka @ 2025-04-09 14:25 UTC (permalink / raw)
To: Richard Weinberger, Nikolaus Funk, xenomai
Cc: Richard Weinberger, Johannes Kirchmair, Lorenz Kofler
On 09.04.25 11:47, Richard Weinberger wrote:
> On Dienstag, 8. April 2025 19:06 Jan Kiszka wrote:
>> On 08.04.25 14:34, Nikolaus Funk wrote:
>>> From: Richard Weinberger <richard@nod.at>
>>>
>>> Like on the x86 side, allow early return such that
>>> handling the exception on the Linux can get avoided.
>>>
>>
>> Which traps can be caught and fully handled in oob this way? From my
>> past experiments, that list was not very long - and when I look at your
>> Xenomai 3 changes, it still isn't. What was particularly hard: DABT and
>> memory access faults.
>
> The list is indeed short.
> So far ARM64_TRAP_UNDI/BTI and ALIGN look good.
>
>> Point is that we need to have some kind of consistency, between the
>> archs and between the reporting information (Linux vs. OOB signals). Or
>> we extensively need to document where all we are deviating (and ideally
>> why).
>
> I'd vote for the latter.
> Plus improving the rt_signal_hist test such that others can
> test whether some exception handling is good enough or nor.
>
> So, I suggest exposing more exception but mark/document the known good
> ones explicitly.
Could you assemble such a list next, ideally also listing the not
supported exceptions? That would be a good foundation to discuss the
general feature in the context of evl as well.
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
` (2 preceding siblings ...)
2025-04-08 12:34 ` [PATCH 3/5] arm64: dovetail: Allow early return from traps Nikolaus Funk
@ 2025-04-08 12:34 ` Nikolaus Funk
2025-04-08 13:05 ` Florian Bezdeka
2025-04-08 12:34 ` [PATCH 5/5] arm: " Nikolaus Funk
2025-04-08 16:58 ` [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Jan Kiszka
5 siblings, 1 reply; 17+ messages in thread
From: Nikolaus Funk @ 2025-04-08 12:34 UTC (permalink / raw)
To: xenomai
Cc: richard, Richard Weinberger, Johannes Kirchmair, Jan Kiszka,
Lorenz Kofler
From: Richard Weinberger <richard@nod.at>
This introduces an interface for handling signal frame setup and restoration,
enabling realtime aware signal support within Xenomai. The implementation uses
existing Linux signal setup functions to avoid code duplication.
Co-developed-by: Johannes Kirchmair <johannes.kirchmair@sigmatek.at>
Co-developed-by: Jan Kiszka <jan.kiszka@siemens.com>
Co-developed-by: Lorenz Kofler <lorenz@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/arm64/include/asm/signal32.h | 3 ++
arch/arm64/kernel/signal.c | 85 +++++++++++++++++++++++++++++++
arch/arm64/kernel/signal32.c | 2 +-
3 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h
index 7e9f163d02ec..cfdd691aeecc 100644
--- a/arch/arm64/include/asm/signal32.h
+++ b/arch/arm64/include/asm/signal32.h
@@ -60,6 +60,9 @@ int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs);
void compat_setup_restart_syscall(struct pt_regs *regs);
+
+int compat_restore_sigframe(struct pt_regs *regs,
+ struct compat_sigframe __user *sf);
#else
static inline int compat_setup_frame(int usid, struct ksignal *ksig,
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index ad388cb248b2..1c3682abc897 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -1688,6 +1688,91 @@ 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 usig = ksig->sig;
+ int ret;
+
+ pagefault_disable();
+
+ if (!is_compat_task())
+ ret = setup_rt_frame(usig, ksig, oldset, regs);
+ else
+ ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
+
+ ret |= !valid_user_regs(®s->user_regs, current);
+
+ pagefault_enable();
+
+ return ret;
+}
+
+static int dovetail_restore_64_rt_signal_frame(struct pt_regs *regs)
+{
+ struct user_access_state ua_state;
+ struct rt_sigframe __user *frame;
+ int ret = -EFAULT;
+
+ if (regs->sp & 15)
+ goto out;
+
+ frame = (struct rt_sigframe __user *)regs->sp;
+
+ pagefault_disable();
+
+ if (!access_ok(frame, sizeof (*frame)))
+ goto out_pfe;
+
+ if (restore_sigframe(regs, frame, &ua_state))
+ goto out_pfe;
+
+ restore_user_access_state(&ua_state);
+
+ ret = 0;
+
+out_pfe:
+ pagefault_enable();
+out:
+ return ret;
+}
+
+static int dovetail_restore_32_rt_signal_frame(struct pt_regs *regs)
+{
+ struct compat_rt_sigframe __user *frame;
+ int ret = 0;
+
+ if (regs->sp & 7)
+ goto out;
+
+ frame = (struct compat_rt_sigframe __user *)regs->compat_sp;
+
+ pagefault_disable();
+
+ if (!access_ok(frame, sizeof (*frame)))
+ goto out_pfe;
+
+ if (compat_restore_sigframe(regs, &frame->sig))
+ goto out_pfe;
+
+ ret = 0;
+
+out_pfe:
+ pagefault_enable();
+out:
+ return ret;
+}
+
+int dovetail_restore_rt_signal_frame(struct pt_regs *regs)
+{
+ if (is_compat_task())
+ return dovetail_restore_32_rt_signal_frame(regs);
+ else
+ return dovetail_restore_64_rt_signal_frame(regs);
+}
+#endif
+
unsigned long __ro_after_init signal_minsigstksz;
/*
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index 81e798b6dada..4b4088eb49d1 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -179,7 +179,7 @@ static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame)
return err ? -EFAULT : 0;
}
-static int compat_restore_sigframe(struct pt_regs *regs,
+int compat_restore_sigframe(struct pt_regs *regs,
struct compat_sigframe __user *sf)
{
int err;
--
2.48.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore
2025-04-08 12:34 ` [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
@ 2025-04-08 13:05 ` Florian Bezdeka
2025-04-08 13:16 ` Richard Weinberger
0 siblings, 1 reply; 17+ messages in thread
From: Florian Bezdeka @ 2025-04-08 13:05 UTC (permalink / raw)
To: Nikolaus Funk, xenomai
Cc: richard, Richard Weinberger, Johannes Kirchmair, Jan Kiszka,
Lorenz Kofler
On Tue, 2025-04-08 at 14:34 +0200, Nikolaus Funk wrote:
> From: Richard Weinberger <richard@nod.at>
>
> This introduces an interface for handling signal frame setup and restoration,
> enabling realtime aware signal support within Xenomai. The implementation uses
> existing Linux signal setup functions to avoid code duplication.
>
> Co-developed-by: Johannes Kirchmair <johannes.kirchmair@sigmatek.at>
> Co-developed-by: Jan Kiszka <jan.kiszka@siemens.com>
> Co-developed-by: Lorenz Kofler <lorenz@sigma-star.at>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> arch/arm64/include/asm/signal32.h | 3 ++
> arch/arm64/kernel/signal.c | 85 +++++++++++++++++++++++++++++++
> arch/arm64/kernel/signal32.c | 2 +-
> 3 files changed, 89 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h
> index 7e9f163d02ec..cfdd691aeecc 100644
> --- a/arch/arm64/include/asm/signal32.h
> +++ b/arch/arm64/include/asm/signal32.h
> @@ -60,6 +60,9 @@ int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
> struct pt_regs *regs);
>
> void compat_setup_restart_syscall(struct pt_regs *regs);
> +
> +int compat_restore_sigframe(struct pt_regs *regs,
> + struct compat_sigframe __user *sf);
> #else
>
> static inline int compat_setup_frame(int usid, struct ksignal *ksig,
> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index ad388cb248b2..1c3682abc897 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
> @@ -1688,6 +1688,91 @@ 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 usig = ksig->sig;
> + int ret;
> +
> + pagefault_disable();
> +
> + if (!is_compat_task())
> + ret = setup_rt_frame(usig, ksig, oldset, regs);
> + else
> + ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
I would vote for changing the condition to is_compat_task() and
switching if/else branches.
> +
> + ret |= !valid_user_regs(®s->user_regs, current);
> +
> + pagefault_enable();
> +
> + return ret;
> +}
> +
> +static int dovetail_restore_64_rt_signal_frame(struct pt_regs *regs)
> +{
> + struct user_access_state ua_state;
> + struct rt_sigframe __user *frame;
> + int ret = -EFAULT;
> +
> + if (regs->sp & 15)
> + goto out;
- Where is this magic 15 coming from?
- return -EFAULT; would also work and save us one label.
> +
> + frame = (struct rt_sigframe __user *)regs->sp;
> +
> + pagefault_disable();
> +
> + if (!access_ok(frame, sizeof (*frame)))
> + goto out_pfe;
> +
> + if (restore_sigframe(regs, frame, &ua_state))
> + goto out_pfe;
> +
> + restore_user_access_state(&ua_state);
> +
> + ret = 0;
> +
> +out_pfe:
> + pagefault_enable();
> +out:
> + return ret;
> +}
> +
> +static int dovetail_restore_32_rt_signal_frame(struct pt_regs *regs)
> +{
> + struct compat_rt_sigframe __user *frame;
> + int ret = 0;
> +
> + if (regs->sp & 7)
> + goto out;
Same as above.
- Magic 7
- Is the error reporting really correct here? We would return 0.
> +
> + frame = (struct compat_rt_sigframe __user *)regs->compat_sp;
> +
> + pagefault_disable();
> +
> + if (!access_ok(frame, sizeof (*frame)))
> + goto out_pfe;
> +
> + if (compat_restore_sigframe(regs, &frame->sig))
> + goto out_pfe;
> +
> + ret = 0;
> +
> +out_pfe:
> + pagefault_enable();
> +out:
> + return ret;
> +}
> +
> +int dovetail_restore_rt_signal_frame(struct pt_regs *regs)
> +{
> + if (is_compat_task())
> + return dovetail_restore_32_rt_signal_frame(regs);
> + else
> + return dovetail_restore_64_rt_signal_frame(regs);
> +}
> +#endif
> +
> unsigned long __ro_after_init signal_minsigstksz;
>
> /*
> diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
> index 81e798b6dada..4b4088eb49d1 100644
> --- a/arch/arm64/kernel/signal32.c
> +++ b/arch/arm64/kernel/signal32.c
> @@ -179,7 +179,7 @@ static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame)
> return err ? -EFAULT : 0;
> }
>
> -static int compat_restore_sigframe(struct pt_regs *regs,
> +int compat_restore_sigframe(struct pt_regs *regs,
> struct compat_sigframe __user *sf)
> {
> int err;
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore
2025-04-08 13:05 ` Florian Bezdeka
@ 2025-04-08 13:16 ` Richard Weinberger
0 siblings, 0 replies; 17+ messages in thread
From: Richard Weinberger @ 2025-04-08 13:16 UTC (permalink / raw)
To: Nikolaus Funk, xenomai, Florian Bezdeka
Cc: Richard Weinberger, Johannes Kirchmair, Jan Kiszka, Lorenz Kofler
On Dienstag, 8. April 2025 15:05 Florian Bezdeka wrote:
> > + if (regs->sp & 15)
> > + goto out;
>
> - Where is this magic 15 coming from?
The stack needs to be word aligned.
This was taken from the Linux side.
> - return -EFAULT; would also work and save us one label.
Ok.
>
> > +
> > + frame = (struct rt_sigframe __user *)regs->sp;
> > +
> > + pagefault_disable();
> > +
> > + if (!access_ok(frame, sizeof (*frame)))
> > + goto out_pfe;
> > +
> > + if (restore_sigframe(regs, frame, &ua_state))
> > + goto out_pfe;
> > +
> > + restore_user_access_state(&ua_state);
> > +
> > + ret = 0;
> > +
> > +out_pfe:
> > + pagefault_enable();
> > +out:
> > + return ret;
> > +}
> > +
> > +static int dovetail_restore_32_rt_signal_frame(struct pt_regs *regs)
> > +{
> > + struct compat_rt_sigframe __user *frame;
> > + int ret = 0;
That should be pre-initialized to -EFAULT. :-S
> > + if (regs->sp & 7)
Given this a second thought, the check should inspect ->compat_sp, no ->sp.
> > + goto out;
>
> Same as above.
> - Magic 7
The stack needs to be word aligned.
> - Is the error reporting really correct here? We would return 0.
Yes.
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 5/5] arm: dovetail: Helper functions for signal frame setup and restore
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
` (3 preceding siblings ...)
2025-04-08 12:34 ` [PATCH 4/5] arm64: dovetail: Helper functions for signal frame setup and restore Nikolaus Funk
@ 2025-04-08 12:34 ` Nikolaus Funk
2025-04-08 13:12 ` Florian Bezdeka
2025-04-08 16:58 ` [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Jan Kiszka
5 siblings, 1 reply; 17+ messages in thread
From: Nikolaus Funk @ 2025-04-08 12:34 UTC (permalink / raw)
To: xenomai; +Cc: richard, Richard Weinberger
From: Richard Weinberger <richard@nod.at>
This introduces an interface for handling signal frame setup and restoration,
enabling realtime aware signal support within Xenomai. The implementation uses
existing Linux signal setup functions to avoid code duplication.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/arm/kernel/signal.c | 50 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 2631632090c0..27fcbf22336c 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -497,6 +497,56 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
return err;
}
+#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 = -EFAULT;
+ int sig;
+
+ if (regs->ARM_sp & 7) {
+ goto out;
+ }
+
+ frame = (struct rt_sigframe __user *)regs->ARM_sp;
+
+ pagefault_disable();
+
+ if (!access_ok(frame, sizeof (*frame))) {
+ goto out_pfe;
+ }
+
+ if (restore_sigframe(regs, &frame->sig)) {
+ goto out_pfe;
+ }
+
+ if (copy_from_user(&sig, &frame->info.si_signo, sizeof(sig)))
+ goto out_pfe;
+
+ ret = sig;
+
+out_pfe:
+ pagefault_enable();
+out:
+ return ret;
+}
+#endif
+
/*
* OK, we're invoking a handler
*/
--
2.48.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 5/5] arm: dovetail: Helper functions for signal frame setup and restore
2025-04-08 12:34 ` [PATCH 5/5] arm: " Nikolaus Funk
@ 2025-04-08 13:12 ` Florian Bezdeka
2025-04-08 13:18 ` Richard Weinberger
0 siblings, 1 reply; 17+ messages in thread
From: Florian Bezdeka @ 2025-04-08 13:12 UTC (permalink / raw)
To: Nikolaus Funk, xenomai; +Cc: richard, Richard Weinberger
On Tue, 2025-04-08 at 14:34 +0200, Nikolaus Funk wrote:
> From: Richard Weinberger <richard@nod.at>
>
> This introduces an interface for handling signal frame setup and restoration,
> enabling realtime aware signal support within Xenomai. The implementation uses
> existing Linux signal setup functions to avoid code duplication.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> arch/arm/kernel/signal.c | 50 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
> index 2631632090c0..27fcbf22336c 100644
> --- a/arch/arm/kernel/signal.c
> +++ b/arch/arm/kernel/signal.c
> @@ -497,6 +497,56 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
> return err;
> }
>
> +#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 = -EFAULT;
> + int sig;
> +
> + if (regs->ARM_sp & 7) {
> + goto out;
> + }
The different code style here (and below) is by intention?
> +
> + frame = (struct rt_sigframe __user *)regs->ARM_sp;
> +
> + pagefault_disable();
> +
> + if (!access_ok(frame, sizeof (*frame))) {
> + goto out_pfe;
> + }
> +
> + if (restore_sigframe(regs, &frame->sig)) {
> + goto out_pfe;
> + }
> +
> + if (copy_from_user(&sig, &frame->info.si_signo, sizeof(sig)))
> + goto out_pfe;
Hm... Switched the style again... I assume checkpatch would have
complained... No?
> +
> + ret = sig;
> +
> +out_pfe:
> + pagefault_enable();
> +out:
> + return ret;
> +}
> +#endif
> +
> /*
> * OK, we're invoking a handler
> */
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 5/5] arm: dovetail: Helper functions for signal frame setup and restore
2025-04-08 13:12 ` Florian Bezdeka
@ 2025-04-08 13:18 ` Richard Weinberger
0 siblings, 0 replies; 17+ messages in thread
From: Richard Weinberger @ 2025-04-08 13:18 UTC (permalink / raw)
To: Nikolaus Funk, xenomai, Florian Bezdeka; +Cc: Richard Weinberger
On Dienstag, 8. April 2025 15:12 Florian Bezdeka wrote:
> The different code style here (and below) is by intention?
Too many different persons have worked on this and things got
copy&pasted.
> >
> > +
> > + frame = (struct rt_sigframe __user *)regs->ARM_sp;
> > +
> > + pagefault_disable();
> > +
> > + if (!access_ok(frame, sizeof (*frame))) {
> > + goto out_pfe;
> > + }
> > +
> > + if (restore_sigframe(regs, &frame->sig)) {
> > + goto out_pfe;
> > + }
> > +
> > + if (copy_from_user(&sig, &frame->info.si_signo, sizeof(sig)))
> > + goto out_pfe;
>
> Hm... Switched the style again... I assume checkpatch would have
> complained... No?
checkpatch issues a warning, so it is a matter of taste.
But I agree, we should be consistent. :-S
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC PATCH 0/5] Dovetail: Real-time Exception Handling
2025-04-08 12:34 [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Nikolaus Funk
` (4 preceding siblings ...)
2025-04-08 12:34 ` [PATCH 5/5] arm: " Nikolaus Funk
@ 2025-04-08 16:58 ` Jan Kiszka
2025-04-08 17:55 ` Richard Weinberger
5 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2025-04-08 16:58 UTC (permalink / raw)
To: Nikolaus Funk, xenomai; +Cc: richard, Richard Weinberger
On 08.04.25 14:34, Nikolaus Funk wrote:
> From: Richard Weinberger <richard@nod.at>
>
> This is the Dovetail side of the real-time exception handling
> (aka real-time signal) feature.
>
> In its current form, it's a bit larger than expected because it also
> includes the signal frame helper functions. It's debatable whether
> these should be part of Dovetail or Xenomai.
>
> The smaller, but much more important changes are for ARM32 and
> ARM64. These allow fast return from exception handling so that
> Xenomai can decide whether an exception should be propagated
> to Linux or not.
Is this targeting latest dovetail (6.14.y-dovetail-rebase) or something
older? Did you already look into how well backporting works? Just to
collect already information upfront.
Jan
>
> Lorenz Kofler (1):
> x86: dovetail: Helper functions for signal frame setup and restore
>
> Richard Weinberger (4):
> arm: dovetail: Fix user mode UND exception handling
> arm64: dovetail: Allow early return from traps
> arm64: dovetail: Helper functions for signal frame setup and restore
> arm: dovetail: Helper functions for signal frame setup and restore
>
> arch/arm/kernel/signal.c | 50 ++++++++++++++++++
> arch/arm/kernel/traps.c | 6 +++
> arch/arm64/include/asm/signal32.h | 3 ++
> arch/arm64/kernel/signal.c | 85 ++++++++++++++++++++++++++++++
> arch/arm64/kernel/signal32.c | 2 +-
> arch/arm64/kernel/traps.c | 18 ++++---
> arch/arm64/mm/fault.c | 15 ++++--
> arch/x86/include/asm/sighandling.h | 3 ++
> arch/x86/kernel/signal.c | 80 ++++++++++++++++++++++++++++
> arch/x86/kernel/signal_32.c | 2 +-
> arch/x86/kernel/signal_64.c | 2 +-
> include/linux/dovetail.h | 4 ++
> 12 files changed, 254 insertions(+), 16 deletions(-)
>
--
Siemens AG, Foundational Technologies
Linux Expert Center
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [RFC PATCH 0/5] Dovetail: Real-time Exception Handling
2025-04-08 16:58 ` [RFC PATCH 0/5] Dovetail: Real-time Exception Handling Jan Kiszka
@ 2025-04-08 17:55 ` Richard Weinberger
0 siblings, 0 replies; 17+ messages in thread
From: Richard Weinberger @ 2025-04-08 17:55 UTC (permalink / raw)
To: Nikolaus Funk, xenomai, Jan Kiszka; +Cc: Richard Weinberger
On Dienstag, 8. April 2025 18:58 Jan Kiszka wrote:
> On 08.04.25 14:34, Nikolaus Funk wrote:
> > From: Richard Weinberger <richard@nod.at>
> >
> > This is the Dovetail side of the real-time exception handling
> > (aka real-time signal) feature.
> >
> > In its current form, it's a bit larger than expected because it also
> > includes the signal frame helper functions. It's debatable whether
> > these should be part of Dovetail or Xenomai.
> >
> > The smaller, but much more important changes are for ARM32 and
> > ARM64. These allow fast return from exception handling so that
> > Xenomai can decide whether an exception should be propagated
> > to Linux or not.
>
> Is this targeting latest dovetail (6.14.y-dovetail-rebase) or something
> older? Did you already look into how well backporting works? Just to
> collect already information upfront.
It is based on v6.14-dovetail1-rebase.
So gar porting to other releases worked okay'isch.
In ARM64 this changed caused a little friction:
2e8a1acea859 ("arm64: signal: Improve POR_EL0 handling to avoid uaccess failures")
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 17+ messages in thread