xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard.weinberger@gmail.com>
To: Xenomai <xenomai@lists.linux.dev>
Cc: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Subject: ARM64 prefault weirdness
Date: Tue, 27 Feb 2024 10:24:22 +0100	[thread overview]
Message-ID: <CAFLxGvzXWdySKjXmWv=onYk0urPzkn8bxWuvoFEmLzLyuQTj1Q@mail.gmail.com> (raw)

Hi!

The more code I read, the more I get confused by Xenomai's prefault code. ;-)

On Kernel 6.1, David and I have the following situation:
1. A kernel module does vmalloc_user() followed by rtdm_mmap_to_user()
with PROT_READ | PROT_EXEC
2. Arm64's prefault code triggers VM_BUG_ON_VMA(prev != vma, vma); in
find_mergeable_anon_vma()
3. It triggers only when PROT_WRITE in rtdm_mmap_to_user() is *not* set.

While playing with David's reproducer I discovered that even without
calling cobalt_machine.prefault() I don't
get page faults in the RT application while accessing the area.
rtdm_mmap_to_user() calls for vmalloc'ed areas vm_insert_page(), so I
guess(!) we get there already
page table entries.

Can it be that cobalt_machine.prefault() is not really needed on arm64
for vmalloc'ed memory?
Maybe older kernels are just more forgiving and tolerate unneeded
calls of handle_mm_fault()?
The VM_BUG_ON_VMA() assertion is also rather new and you need to have
CONFIG_DEBUG_VM=y,
maybe nobody noticed ever.

What do you think?

-- 
Thanks,
//richard

             reply	other threads:[~2024-02-27  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  9:24 Richard Weinberger [this message]
2024-02-28 13:44 ` ARM64 prefault weirdness Richard Weinberger
2024-03-05 15:00   ` Jan Kiszka
2024-03-05 15:39     ` Richard Weinberger
2024-03-05 16:58       ` 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='CAFLxGvzXWdySKjXmWv=onYk0urPzkn8bxWuvoFEmLzLyuQTj1Q@mail.gmail.com' \
    --to=richard.weinberger@gmail.com \
    --cc=david.oberhollenzer@sigma-star.at \
    --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).