From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Xenomai <xenomai@lists.linux.dev>,
Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: Re: [dovetail][PATCH] arm64: dovetail: Notify the core about compat alignment fixups
Date: Tue, 10 Nov 2026 17:52:49 +0100 [thread overview]
Message-ID: <87wlqk6332.fsf@xenomai.org> (raw)
In-Reply-To: <4d7b7926-4a09-40c0-b4e8-d5512f8107ef@siemens.com> (Jan Kiszka's message of "Tue, 10 Nov 2026 16:46:00 +0100")
Jan Kiszka <jan.kiszka@siemens.com> writes:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> With CONFIG_COMPAT_ALIGNMENT_FIXUPS, misaligned multi-word loads and
> stores of 32-bit tasks are emulated by do_compat_alignment_fixup(),
> called from do_alignment_fault() via do_mem_abort(). The companion
> core is only told about the trap when the fixup fails and
> do_mem_abort() falls back to signal injection. If the fixup succeeds,
> an oob thread runs the whole emulation from the oob stage: it fetches
> the faulting instruction, emulates it by accessing user memory, which
> may fault in pages, and accounts a perf event, none of which is
> oob-safe. On arm, the equivalent path in do_alignment() is annotated.
>
> Notify the core before attempting the fixup, reporting the trap as
> ARM64_TRAP_ACCESS like do_bad_area() does for the same fault when the
> fixups are disabled. If the fixup fails, the notification is unwound
> before do_mem_abort() goes on, so its own annotation pairs as usual.
>
> Assisted-by: opencode:Opus-5.5
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> This was a found by pure code analysis as most setups have
> CONFIG_COMPAT_ALIGNMENT_FIXUPS off. It was not tested yet, working on a
> setup.
>
> arch/arm64/mm/fault.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index 2726eb3fa2d46..c3532ff0440ad 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -867,9 +867,15 @@ static int __kprobes do_translation_fault(unsigned long far,
> static int do_alignment_fault(unsigned long far, unsigned long esr,
> struct pt_regs *regs)
> {
> + int ret;
> +
> if (IS_ENABLED(CONFIG_COMPAT_ALIGNMENT_FIXUPS) &&
> - compat_user_mode(regs))
> - return do_compat_alignment_fixup(far, regs);
> + compat_user_mode(regs)) {
> + mark_trap_entry(ARM64_TRAP_ACCESS, regs);
> + ret = do_compat_alignment_fixup(far, regs);
> + mark_trap_exit(ARM64_TRAP_ACCESS, regs);
> + return ret;
> + }
> do_bad_area(far, esr, regs);
> return 0;
> }
If oob, we can expect MMF_DOVETAIL to be set for the current address
space, so .text pages of the caller should have been committed. In the
(unexpected) event some are not, get_user() and friends would still
recursively bump us to do_page_fault()/do_translation_fault() on a
subsequent synchronous exception path, which would mark the trap entry
eventually, causing the core to downgrade the task before damage is
done. This should work now that pipelined faults can pile up
safely. Anyway, I'll wait for some testing, things might be more
complicated.
--
Philippe.
next prev parent reply other threads:[~2026-11-10 16:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 15:46 [dovetail][PATCH] arm64: dovetail: Notify the core about compat alignment fixups Jan Kiszka
2026-11-10 16:52 ` Philippe Gerum [this message]
2026-11-10 17:47 ` Jan Kiszka
2026-11-10 18:01 ` 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=87wlqk6332.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=florian.bezdeka@siemens.com \
--cc=jan.kiszka@siemens.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.