linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Benjamin Herrenschmidt <benh@au1.ibm.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>, Takashi Iwai <tiwai@suse.de>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	opensuse-factory@opensuse.org,
	OpenSUSE Kernel Team <opensuse-kernel@opensuse.org>
Subject: Re: [opensuse-factory] Re: [opensuse-kernel] libsigsegv build fail with kernel 3.18.3
Date: Sun, 1 Feb 2015 17:09:15 -0800	[thread overview]
Message-ID: <CA+55aFw9sg7pu9-2RbMGyPv5yUtcH54QowoH+5RhWqpPYg4YGQ@mail.gmail.com> (raw)
In-Reply-To: <1422836637.17302.9.camel@au1.ibm.com>

On Sun, Feb 1, 2015 at 4:23 PM, Benjamin Herrenschmidt <benh@au1.ibm.com> wrote:
>
> I prefer having the test inside mm_fault_error(), even if that makes the
> patch a bit bigger, it keeps the logic in a single place. Untested
> patch:

I'm certainly ok with that, but I wanted to make the code that I
wasn't going to compile (much less test) for various architectures be
as simple and straightforward as possible.

So feel free to send a patch that fixes it up to do it in a single
place after testing it.

Of course, what I *really* want would be to make a new
"generic_mm_fault()" helper that would do all the normal stuff:

 - find_vma()
 - check permissions and ranges
 - call 'handle_mm_fault()'
 - do the proper error, retry and minor/major fault handling

and then most architectures could just call that.

Everybody has their own thing that they do *before* they get the mmap
semaphore (x86 has at least kprobe, mmio tracing, vmalloc-fault,
spurious prefetch faults due to AMD CPU bugs, in-atomic debugging irq
re-enablement, etc etc). Those aren't even worth it trying to make
into generic things. But just looking at the original patch, a _lot_
of the stuff around the actual handle_mm_fault() call is very very
generic indeed, and I think it could be made into a generic helper
function.

For example, I not that long ago fixed the x86 handling of
VM_FAULT_RETRY when there was a fatal signal pending and we were
returning to kernel mode. The code would just return, "knowing" that
the fatal signal would mean that rather than faulting again, the
process would be killed. Except if the fault happened from kernel
space, that wouldn't happen, and it really would just fault forever.

I would not be surprised if somebody copied the old incorrect x86 case
for VM_FAULT_RETRY and fatal signals, and it just never got fixed
anywhere else.

Doing all that in a generic helper routine (that then just returns a
value saying "SIGBUS", "SIGSEGV" - we'd probably have to split it up
into "SIGSEGV due to access error" vs "SIGSEGV due to map error" to
make everybody happy, "out of memory" or "success" would have made it
trivial to add the whole VM_FAULT_SIGSEGV, but it would also mean that
everybody got fixes to the retry handling etc. Because right now
there's a *lot* of basically duplicated code (although powerpc and
s390 in particular have made some changes of their own).

Anybody willing to see if they could encapsulate that part of the x86
code, and make it more widely useful? I say "x86 code", because that's
the most tested one, and I think it gets the odd retry and error cases
right (and minor/major fault counting etc), unlike some.

                           Linus

  reply	other threads:[~2015-02-02  1:09 UTC|newest]

Thread overview: 35+ 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 [this message]
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 10:36                         ` Benjamin Herrenschmidt
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:49                           ` Linus Torvalds
2015-02-28 21:49                             ` Linus Torvalds
2015-02-28 22:49                             ` Benjamin Herrenschmidt
2015-02-28 22:16                           ` 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
     [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=CA+55aFw9sg7pu9-2RbMGyPv5yUtcH54QowoH+5RhWqpPYg4YGQ@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=benh@au1.ibm.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=opensuse-factory@opensuse.org \
    --cc=opensuse-kernel@opensuse.org \
    --cc=tiwai@suse.de \
    /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 NNTP newsgroup(s).