All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Gerst <brgerst@gmail.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Borislav Petkov <bp@alien8.de>, X86 ML <x86@kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Robert <elliott@hpe.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tony Luck <tony.luck@intel.com>, Ingo Molnar <mingo@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-nvdimm <linux-nvdimm@ml01.01.org>
Subject: Re: [PATCH v8 1/3] x86: Expand exception table to allow new handling options
Date: Mon, 11 Jan 2016 18:09:46 -0500	[thread overview]
Message-ID: <CAMzpN2gamZbY+k=oADhAxEiNPEzeezaRDDOvF2ZU1rWG2CDNSA@mail.gmail.com> (raw)
In-Reply-To: <CALCETrVR=_CYHt4R4yurKpnfi76P8GTwHycPLmqPshK2bCv+Fg@mail.gmail.com>

On Sat, Jan 9, 2016 at 1:36 AM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Jan 8, 2016 8:31 PM, "Brian Gerst" <brgerst@gmail.com> wrote:
>>
>> On Fri, Jan 8, 2016 at 10:39 PM, Brian Gerst <brgerst@gmail.com> wrote:
>> > On Fri, Jan 8, 2016 at 8:52 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> >> On Fri, Jan 8, 2016 at 12:49 PM, Tony Luck <tony.luck@intel.com> wrote:
>> >>> Huge amounts of help from  Andy Lutomirski and Borislav Petkov to
>> >>> produce this. Andy provided the inspiration to add classes to the
>> >>> exception table with a clever bit-squeezing trick, Boris pointed
>> >>> out how much cleaner it would all be if we just had a new field.
>> >>>
>> >>> Linus Torvalds blessed the expansion with:
>> >>>   I'd rather not be clever in order to save just a tiny amount of space
>> >>>   in the exception table, which isn't really criticial for anybody.
>> >>>
>> >>> The third field is a simple integer indexing into an array of handler
>> >>> functions (I thought it couldn't be a relative pointer like the other
>> >>> fields because a module may have its ex_table loaded more than 2GB away
>> >>> from the handler function - but that may not be actually true. But the
>> >>> integer is pretty flexible, we are only really using low two bits now).
>> >>>
>> >>> We start out with three handlers:
>> >>>
>> >>> 0: Legacy - just jumps the to fixup IP
>> >>> 1: Fault - provide the trap number in %ax to the fixup code
>> >>> 2: Cleaned up legacy for the uaccess error hack
>> >>
>> >> I think I preferred the relative function pointer approach.
>> >>
>> >> Also, I think it would be nicer if the machine check code would invoke
>> >> the handler regardless of which handler (or class) is selected.  Then
>> >> the handlers that don't want to handle #MC can just reject them.
>> >>
>> >> Also, can you make the handlers return bool instead of int?
>> >
>> > I'm hashing up an idea that could eliminate alot of text in the .fixup
>> > section, but it needs the integer handler method to work.  We have
>> > alot of fixup code that does "mov $-EFAULT, reg; jmp xxxx".  If we
>> > encode the register in the third word, the handler can be generic and
>> > no fixup code for each user access would be needed.  That would
>> > recover alot of the memory used by expanding the exception table.
>>
>> On second thought, this could still be implemented with a relative
>> function pointer.  We'd just need a separate function for each
>> register.
>>
>
> If we could get gcc to play along (which, IIRC, it already can for
> __put_user), we can do much better with jump labels -- the fixup
> target would be a jump label.
>
> Even without that, how about using @cc?  Do:
>
> clc
> mov whatever, wherever
>
> The fixup sets the carry flag and skips the faulting instruction
> (either by knowing the length or by decoding it), and the inline asm
> causes gcc to emit jc to the error logic.
>
> --Andy

I agree that for at least put_user() using asm goto would be an even
better option.  get_user() on the other hand, will be much messier to
deal with, since asm goto statements can't have outputs, plus it
zeroes the output register on fault.

--
Brian Gerst

WARNING: multiple messages have this Message-ID (diff)
From: Brian Gerst <brgerst@gmail.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Borislav Petkov <bp@alien8.de>, X86 ML <x86@kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Robert <elliott@hpe.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tony Luck <tony.luck@intel.com>, Ingo Molnar <mingo@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-nvdimm <linux-nvdimm@ml01.01.org>
Subject: Re: [PATCH v8 1/3] x86: Expand exception table to allow new handling options
Date: Mon, 11 Jan 2016 18:09:46 -0500	[thread overview]
Message-ID: <CAMzpN2gamZbY+k=oADhAxEiNPEzeezaRDDOvF2ZU1rWG2CDNSA@mail.gmail.com> (raw)
In-Reply-To: <CALCETrVR=_CYHt4R4yurKpnfi76P8GTwHycPLmqPshK2bCv+Fg@mail.gmail.com>

On Sat, Jan 9, 2016 at 1:36 AM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Jan 8, 2016 8:31 PM, "Brian Gerst" <brgerst@gmail.com> wrote:
>>
>> On Fri, Jan 8, 2016 at 10:39 PM, Brian Gerst <brgerst@gmail.com> wrote:
>> > On Fri, Jan 8, 2016 at 8:52 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> >> On Fri, Jan 8, 2016 at 12:49 PM, Tony Luck <tony.luck@intel.com> wrote:
>> >>> Huge amounts of help from  Andy Lutomirski and Borislav Petkov to
>> >>> produce this. Andy provided the inspiration to add classes to the
>> >>> exception table with a clever bit-squeezing trick, Boris pointed
>> >>> out how much cleaner it would all be if we just had a new field.
>> >>>
>> >>> Linus Torvalds blessed the expansion with:
>> >>>   I'd rather not be clever in order to save just a tiny amount of space
>> >>>   in the exception table, which isn't really criticial for anybody.
>> >>>
>> >>> The third field is a simple integer indexing into an array of handler
>> >>> functions (I thought it couldn't be a relative pointer like the other
>> >>> fields because a module may have its ex_table loaded more than 2GB away
>> >>> from the handler function - but that may not be actually true. But the
>> >>> integer is pretty flexible, we are only really using low two bits now).
>> >>>
>> >>> We start out with three handlers:
>> >>>
>> >>> 0: Legacy - just jumps the to fixup IP
>> >>> 1: Fault - provide the trap number in %ax to the fixup code
>> >>> 2: Cleaned up legacy for the uaccess error hack
>> >>
>> >> I think I preferred the relative function pointer approach.
>> >>
>> >> Also, I think it would be nicer if the machine check code would invoke
>> >> the handler regardless of which handler (or class) is selected.  Then
>> >> the handlers that don't want to handle #MC can just reject them.
>> >>
>> >> Also, can you make the handlers return bool instead of int?
>> >
>> > I'm hashing up an idea that could eliminate alot of text in the .fixup
>> > section, but it needs the integer handler method to work.  We have
>> > alot of fixup code that does "mov $-EFAULT, reg; jmp xxxx".  If we
>> > encode the register in the third word, the handler can be generic and
>> > no fixup code for each user access would be needed.  That would
>> > recover alot of the memory used by expanding the exception table.
>>
>> On second thought, this could still be implemented with a relative
>> function pointer.  We'd just need a separate function for each
>> register.
>>
>
> If we could get gcc to play along (which, IIRC, it already can for
> __put_user), we can do much better with jump labels -- the fixup
> target would be a jump label.
>
> Even without that, how about using @cc?  Do:
>
> clc
> mov whatever, wherever
>
> The fixup sets the carry flag and skips the faulting instruction
> (either by knowing the length or by decoding it), and the inline asm
> causes gcc to emit jc to the error logic.
>
> --Andy

I agree that for at least put_user() using asm goto would be an even
better option.  get_user() on the other hand, will be much messier to
deal with, since asm goto statements can't have outputs, plus it
zeroes the output register on fault.

--
Brian Gerst

--
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:[~2016-01-11 23:09 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-09  0:04 [PATCH v8 0/3] Machine check recovery when kernel accesses poison Tony Luck
2016-01-09  0:04 ` Tony Luck
2015-12-31 19:40 ` [PATCH v8 2/3] x86, mce: Check for faults tagged in EXTABLE_CLASS_FAULT exception table entries Tony Luck
2015-12-31 19:40   ` Tony Luck
2016-01-08 20:49 ` [PATCH v8 1/3] x86: Expand exception table to allow new handling options Tony Luck
2016-01-08 20:49   ` Tony Luck
2016-01-09  1:52   ` Andy Lutomirski
2016-01-09  1:52     ` Andy Lutomirski
2016-01-09  3:39     ` Brian Gerst
2016-01-09  3:39       ` Brian Gerst
2016-01-09  4:31       ` Brian Gerst
2016-01-09  4:31         ` Brian Gerst
2016-01-09  6:36         ` Andy Lutomirski
2016-01-09  6:36           ` Andy Lutomirski
2016-01-11 23:09           ` Brian Gerst [this message]
2016-01-11 23:09             ` Brian Gerst
2016-01-11 23:22             ` Andy Lutomirski
2016-01-11 23:22               ` Andy Lutomirski
2016-01-11 23:48             ` Luck, Tony
2016-01-11 23:48               ` Luck, Tony
2016-01-09 17:45     ` Tony Luck
2016-01-09 17:45       ` Tony Luck
2016-01-09 18:00       ` Andy Lutomirski
2016-01-09 18:00         ` Andy Lutomirski
2016-01-09 19:51         ` Tony Luck
2016-01-09 19:51           ` Tony Luck
2016-01-09 22:32           ` Andy Lutomirski
2016-01-09 22:32             ` Andy Lutomirski
2016-01-10  1:15             ` Tony Luck
2016-01-10  1:15               ` Tony Luck
2016-01-11  0:25     ` Luck, Tony
2016-01-11  0:25       ` Luck, Tony
2016-01-08 21:18 ` [PATCH v8 3/3] x86, mce: Add __mcsafe_copy() Tony Luck
2016-01-08 21:18   ` Tony Luck
2016-01-09  1:49   ` Andy Lutomirski
2016-01-09  1:49     ` Andy Lutomirski
2016-01-09 17:48     ` Tony Luck
2016-01-09 17:48       ` Tony Luck
2016-01-09 17:57       ` Andy Lutomirski
2016-01-09 17:57         ` Andy Lutomirski
2016-01-09 19:39         ` Tony Luck
2016-01-09 19:39           ` Tony Luck
2016-01-09 22:15           ` Dan Williams
2016-01-09 22:15             ` Dan Williams
2016-01-09 22:33             ` Andy Lutomirski
2016-01-09 22:33               ` Andy Lutomirski
2016-01-10  0:23               ` Dan Williams
2016-01-10  0:23                 ` Dan Williams
2016-01-10  1:40                 ` Tony Luck
2016-01-10  1:40                   ` Tony Luck
2016-01-10 11:26                   ` Borislav Petkov
2016-01-10 11:26                     ` Borislav Petkov
2016-01-11 10:44                     ` Ingo Molnar
2016-01-11 10:44                       ` Ingo Molnar
2016-01-13 23:22                       ` Tony Luck
2016-01-13 23:22                         ` Tony Luck
2016-01-14  4:39                         ` Borislav Petkov
2016-01-14  4:39                           ` Borislav Petkov
2016-01-30  0:35                           ` Tony Luck
2016-01-30  0:35                             ` Tony Luck
2016-01-30 10:28                             ` Borislav Petkov
2016-01-30 10:28                               ` Borislav Petkov
2016-02-01 23:10                               ` Tony Luck
2016-02-01 23:10                                 ` Tony Luck
2016-02-01 23:16                                 ` Dan Williams
2016-02-01 23:16                                   ` Dan Williams
2016-01-12  0:26     ` Luck, Tony
2016-01-12  0:26       ` Luck, Tony
2016-01-12  0:30       ` Andy Lutomirski
2016-01-12  0:30         ` Andy Lutomirski
2016-01-12  0:37       ` Andy Lutomirski
2016-01-12  0:37         ` Andy Lutomirski

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='CAMzpN2gamZbY+k=oADhAxEiNPEzeezaRDDOvF2ZU1rWG2CDNSA@mail.gmail.com' \
    --to=brgerst@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=elliott@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@ml01.01.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.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.