All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: Generic page fault (Was: libsigsegv ....)
Date: Sun, 01 Mar 2015 14:57:07 +1100	[thread overview]
Message-ID: <1425182227.4645.173.camel@kernel.crashing.org> (raw)
In-Reply-To: <CA+55aFw+K6aev6JPTiYxWjtJS0O8+MUwC-5=O4Gb+0mCd+tOfQ@mail.gmail.com>

On Sat, 2015-02-28 at 16:41 -0800, Linus Torvalds wrote:
> On Sat, Feb 28, 2015 at 3:02 PM, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
> >
> > Anyway, here's the current patch:
> 
> Ok, I think I like this approach better.
> 
> Your FAULT_FLAG_EXEC handling is wrong, though. It shouldn't check
> VM_WRITE, it should check VM_EXEC. A bit too much copy-paste ;)

Ah yes indeed :) I would have caught that pretty quickly once I tried
powerpc.

> Btw, it's quite possible that we could just do all the PF_PROT
> handling at the x86 level, before even calling the generic fault
> handler. It's not like we even need the vma or the mm semaphore: if
> it's a non-write protection fault, we always SIGSEGV. So why even
> bother getting the locks and looking up the page tables etc?

For non-write possibly, though that means we always end up going
through handle_mm_fault for a non-present PTE before we decide
that it wasn't actually accessible.

Not a huge deal I suppose unless something (ab)uses mprotect + emulation
for things like spying on MMIO accesses (been there) or god knows what
other userspace based paging or GC might be out there. It's asking for
trouble but the check in access_error() doesn't hurt much either.

On the other hand, we are all about simplifying code here, aren't
we ? :-) It's not like the early bail-out on x86 will buy us much and
it's going to be more arch specific code since they'll all have a
different variant of PF_PROT.

One thing that worries me a bit, however, with the PF_PROT handling in
the generic case is the case of archs who support
present-but-not-accessible PTEs in "HW" (for us that basically means no
_PAGE_USER), as these might use such fault for NUMA balancing, or
software maintained "young" bit, and in those case, bailing out on
PF_PROT is wrong. I'll have to figure out if that ever happens when I
dig through more archs.

> Now, that PF_PROT handling isn't exactly performance-critical, but it
> might help to remove the odd x86 special case from the generic code.

I don't think it's that odd on x86. If you look at what other archs do,
there's a bit of everything out there. Just powerpc may or may not
support exec permission for example depending on the CPU generation and
when it doesn't it's basically similar to x86. I yet have to fully
understand what ARM does (looks simple, just need to make sure it's what
I think it is and check various ARM generations), sparc has its
oddities, etc...

None of that is terribly urgent and I'm pretty busy so give me a bit
more time now that we have some kind of direction, to go through a few
more archs and see where it takes us. I'll start gathering cross
compilers and qemu debian images in the next few days.

Cheers,
Ben.



WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: Generic page fault (Was: libsigsegv ....)
Date: Sun, 01 Mar 2015 14:57:07 +1100	[thread overview]
Message-ID: <1425182227.4645.173.camel@kernel.crashing.org> (raw)
In-Reply-To: <CA+55aFw+K6aev6JPTiYxWjtJS0O8+MUwC-5=O4Gb+0mCd+tOfQ@mail.gmail.com>

On Sat, 2015-02-28 at 16:41 -0800, Linus Torvalds wrote:
> On Sat, Feb 28, 2015 at 3:02 PM, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
> >
> > Anyway, here's the current patch:
> 
> Ok, I think I like this approach better.
> 
> Your FAULT_FLAG_EXEC handling is wrong, though. It shouldn't check
> VM_WRITE, it should check VM_EXEC. A bit too much copy-paste ;)

Ah yes indeed :) I would have caught that pretty quickly once I tried
powerpc.

> Btw, it's quite possible that we could just do all the PF_PROT
> handling at the x86 level, before even calling the generic fault
> handler. It's not like we even need the vma or the mm semaphore: if
> it's a non-write protection fault, we always SIGSEGV. So why even
> bother getting the locks and looking up the page tables etc?

For non-write possibly, though that means we always end up going
through handle_mm_fault for a non-present PTE before we decide
that it wasn't actually accessible.

Not a huge deal I suppose unless something (ab)uses mprotect + emulation
for things like spying on MMIO accesses (been there) or god knows what
other userspace based paging or GC might be out there. It's asking for
trouble but the check in access_error() doesn't hurt much either.

On the other hand, we are all about simplifying code here, aren't
we ? :-) It's not like the early bail-out on x86 will buy us much and
it's going to be more arch specific code since they'll all have a
different variant of PF_PROT.

One thing that worries me a bit, however, with the PF_PROT handling in
the generic case is the case of archs who support
present-but-not-accessible PTEs in "HW" (for us that basically means no
_PAGE_USER), as these might use such fault for NUMA balancing, or
software maintained "young" bit, and in those case, bailing out on
PF_PROT is wrong. I'll have to figure out if that ever happens when I
dig through more archs.

> Now, that PF_PROT handling isn't exactly performance-critical, but it
> might help to remove the odd x86 special case from the generic code.

I don't think it's that odd on x86. If you look at what other archs do,
there's a bit of everything out there. Just powerpc may or may not
support exec permission for example depending on the CPU generation and
when it doesn't it's basically similar to x86. I yet have to fully
understand what ARM does (looks simple, just need to make sure it's what
I think it is and check various ARM generations), sparc has its
oddities, etc...

None of that is terribly urgent and I'm pretty busy so give me a bit
more time now that we have some kind of direction, to go through a few
more archs and see where it takes us. I'll start gathering cross
compilers and qemu debian images in the next few days.

Cheers,
Ben.


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-03-01  3:57 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1422361485.6648.71.camel@opensuse.org>
     [not found] ` <54C78756.9090605@suse.cz>
     [not found]   ` <alpine.LSU.2.11.1501271347440.30227@nerf60.vanv.qr>
     [not found]     ` <1422364084.6648.82.camel@opensuse.org>
     [not found]       ` <s5h7fw8hvdp.wl-tiwai@suse.de>
     [not found]         ` <CA+55aFyzy_wYHHnr2gDcYr7qcgOKM2557bRdg6RBa=cxrynd+Q@mail.gmail.com>
2015-01-27 20:57           ` [opensuse-factory] Re: [opensuse-kernel] libsigsegv build fail with kernel 3.18.3 Linus Torvalds
     [not found]             ` <CA+55aFxRnj97rpSQvvzLJhpo7C8TQ-F=eB1Ry2n53AV1rN8mwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-28  7:38               ` [opensuse-factory] " Heiko Carstens
2015-01-28  7:38                 ` [opensuse-factory] Re: [opensuse-kernel] " Heiko Carstens
2015-01-29  6:59             ` Max Filippov
2015-01-29 18:16               ` Linus Torvalds
2015-02-02  0:23                 ` Benjamin Herrenschmidt
2015-02-02  1:09                   ` Linus Torvalds
2015-02-22 23:50                     ` Benjamin Herrenschmidt
2015-02-22 23:50                       ` [opensuse-factory] " Benjamin Herrenschmidt
2015-02-28  7:12                     ` Generic page fault (Was: libsigsegv ....) Benjamin Herrenschmidt
2015-02-28  7:14                       ` Benjamin Herrenschmidt
2015-02-28  7:14                         ` Benjamin Herrenschmidt
2015-02-28 10:36                         ` Benjamin Herrenschmidt
2015-02-28 10:36                           ` Benjamin Herrenschmidt
2015-02-28 19:56                       ` Linus Torvalds
2015-02-28 19:56                         ` Linus Torvalds
2015-02-28 19:58                         ` Linus Torvalds
2015-02-28 19:58                           ` Linus Torvalds
2015-02-28 21:14                         ` Benjamin Herrenschmidt
2015-02-28 21:14                           ` Benjamin Herrenschmidt
2015-02-28 21:49                           ` Linus Torvalds
2015-02-28 21:49                             ` Linus Torvalds
2015-02-28 22:49                             ` Benjamin Herrenschmidt
2015-02-28 22:49                               ` Benjamin Herrenschmidt
2015-02-28 22:16                           ` Benjamin Herrenschmidt
2015-02-28 22:16                             ` Benjamin Herrenschmidt
2015-02-28 22:50                             ` Benjamin Herrenschmidt
2015-02-28 22:50                               ` Benjamin Herrenschmidt
2015-02-28 23:02                             ` Benjamin Herrenschmidt
2015-02-28 23:02                               ` Benjamin Herrenschmidt
2015-03-01  0:41                               ` Linus Torvalds
2015-03-01  0:41                                 ` Linus Torvalds
2015-03-01  3:57                                 ` Benjamin Herrenschmidt [this message]
2015-03-01  3:57                                   ` Benjamin Herrenschmidt
     [not found]           ` <CA+55aFyzy_wYHHnr2gDcYr7qcgOKM2557bRdg6RBa=cxrynd+Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-27 21:12             ` [opensuse-factory] Re: libsigsegv build fail with kernel 3.18.3 Jan Engelhardt
2015-01-27 21:12               ` [opensuse-factory] Re: [opensuse-kernel] " Jan Engelhardt
2015-01-27 21:32               ` Linus Torvalds
2015-01-27 22:14                 ` Jan Engelhardt
2015-01-27 22:32                   ` Linus Torvalds
2015-01-27 23:13                     ` Jan Engelhardt
2015-01-27 23:53                     ` David Miller
     [not found]                     ` <CA+55aFzguEFfG2REN1soMC+0UJ7GtANfEvMoCNPt0QqmP9LKoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-28  8:48                       ` [opensuse-factory] " Andreas Schwab
2015-01-28  8:48                         ` [opensuse-factory] Re: [opensuse-kernel] " Andreas Schwab

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=1425182227.4645.173.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=torvalds@linux-foundation.org \
    /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.