From: Clara Kowalsky <clara.kowalsky@siemens.com>
To: xenomai@lists.linux.dev, rpm@xenomai.org
Cc: florian.bezdeka@siemens.com, Clara Kowalsky <clara.kowalsky@siemens.com>
Subject: [PATCH][Dovetail 6.1] arm64: dovetail: Fix undefinstr/break trap handling
Date: Fri, 3 Nov 2023 09:11:07 +0100 [thread overview]
Message-ID: <20231103081107.3400986-1-clara.kowalsky@siemens.com> (raw)
[ This is a backport of ca33f993e7b677f20a29150b14fd120416bf548e ]
When running an compat RT application on arm64 the break trap is
handled via the undefined instruction trap.
A possible call stack looks like this:
Call trace:
handle_inband_event+0x2d0/0x320
inband_event_notify+0x28/0x50
signal_wake_up_state+0x7c/0xa4
complete_signal+0x104/0x2d0
__send_signal_locked+0x1d0/0x3e4
send_signal_locked+0xf0/0x140
force_sig_info_to_task+0xa0/0x164
force_sig_fault+0x64/0x94
arm64_force_sig_fault+0x48/0x80
send_user_sigtrap+0x50/0x8c
aarch32_break_handler+0xac/0x1d0
do_undefinstr+0x6c/0x360
el0_undef+0x4c/0xd0
el0t_32_sync_handler+0xd0/0x140
el0t_32_sync+0x190/0x194
The trap is never reported to the companion core at that stage so
running_oob() in do_undefinstr() will always return true. As the
following bailout happens before calling the compat breakpoint
detection (aarch32_break_handler()) debugging the compat
application does not work.
Therefore do_undefinstr() reports the trap entry to the
companion core. If the companion core handles the undefined instruction,
running_oob returns true and the bailout occurs. Otherwise, switching to
the in-band stage takes place and the undefined instruction handler
continues with the compat breakpoint detection.
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
arch/arm64/kernel/traps.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index cc68be400244..5ea4cf543113 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -489,25 +489,28 @@ void arm64_notify_segfault(unsigned long addr)
void do_undefinstr(struct pt_regs *regs, unsigned long esr)
{
+ 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())
- return;
+ goto out_exit;
/* check for AArch32 breakpoint instructions */
if (!aarch32_break_handler(regs))
- return;
+ goto out_exit;
if (call_undef_hook(regs) == 0)
- return;
+ goto out_exit;
if (!user_mode(regs))
die("Oops - Undefined instruction", regs, esr);
- mark_trap_entry(ARM64_TRAP_UNDI, regs);
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
+
+out_exit:
mark_trap_exit(ARM64_TRAP_UNDI, regs);
}
NOKPROBE_SYMBOL(do_undefinstr);
--
2.39.2
next reply other threads:[~2023-11-03 8:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 8:11 Clara Kowalsky [this message]
2023-11-05 15:52 ` [PATCH][Dovetail 6.1] arm64: dovetail: Fix undefinstr/break trap handling Philippe Gerum
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=20231103081107.3400986-1-clara.kowalsky@siemens.com \
--to=clara.kowalsky@siemens.com \
--cc=florian.bezdeka@siemens.com \
--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).