From: Al Viro <viro@ZenIV.linux.org.uk>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Vineet Gupta <Vineet.Gupta1@synopsys.com>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault
Date: Sun, 21 Aug 2016 07:42:34 +0100 [thread overview]
Message-ID: <20160821064229.GX2356@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20160821045402.GC14857@tucnak.redhat.com>
On Sun, Aug 21, 2016 at 06:54:02AM +0200, Jakub Jelinek wrote:
> On Sat, Aug 20, 2016 at 05:45:00PM -0700, Linus Torvalds wrote:
> If you plan to use setjmp/longjmp a lot, then it is certainly a major
> performance and compile time/memory problem.
> Older versions don't model it properly, and newer gccs emit abnormal edges
> from every longjmp or call that might longjmp to an artificial basic block
> and from there to every setjmp.
> Also note that gcc has/supports two setjmp kind of APIs, normal setjmp and
> slightly more lightweight __builtin_setjmp which saves fewer registers, and
> on some targets is/used to be used for EH instead of DWARF based ones.
It's not exactly setjmp/longjmp; what I had in mind was along the lines of
static inline bool start(void)
{
asm(
save enough state into current_thread_info()->something, with
1f for saved %rip
stac
res = true
2:
.section .text.fixup
1: res = false
clac
jmp 2b
.previous
)
if (unlikely(!res))
asm clobber everything
return res;
}
and in unsafe_get_user() exception fixup (again, in .text.fixup section,
and invisible to gcc) jumping to common code that would pick saved state
from current_thread_info() and jump to saved location.
The uses would be along the lines of
if (!start())
goto fail;
unsafe_get_user(foo, &p1->foo);
unsafe_get_user(bar, &p1->bar);
...
asm clac
IOW, a bunch of branches hidden from gcc, with destination (in the same
function) dominating the source of each (via visible branches as well).
Originally I hoped to get away with saving just the %rip; Linus has pointed
out that stack pointer is also needed. It's obviously much less generic
than setjmp/longjmp is. Single per-thread jmp_buf rudiment, all "longjmp"
calls in the same function as "setjmp" one, pretty much not giving a damn
about any local variables we might've changed if the "longjmp" is taken,
etc.
The point of the exercise is to have the normal execution path containing
no error checks - just the data copying, with all exception handling happening
out-of-line...
next prev parent reply other threads:[~2016-08-21 6:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 19:10 [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault Vineet Gupta
2016-08-19 19:10 ` Vineet Gupta
2016-08-19 21:24 ` Al Viro
2016-08-19 22:00 ` Linus Torvalds
2016-08-19 22:11 ` Linus Torvalds
2016-08-20 23:32 ` Linus Torvalds
2016-08-21 0:11 ` Al Viro
2016-08-21 0:45 ` Linus Torvalds
2016-08-21 1:00 ` Linus Torvalds
2016-08-21 1:09 ` H. Peter Anvin
2016-08-21 1:40 ` Al Viro
2016-08-21 4:54 ` Jakub Jelinek
2016-08-21 6:42 ` Al Viro [this message]
2016-08-21 17:52 ` Linus Torvalds
2016-08-22 22:23 ` Linus Torvalds
2016-08-22 23:12 ` H. Peter Anvin
2016-08-22 23:48 ` Linus Torvalds
2016-08-22 23:51 ` H. Peter Anvin
2016-08-22 23:57 ` David Miller
2016-08-23 0:09 ` H. Peter Anvin
2016-08-23 0:17 ` Al Viro
2016-08-22 23:19 ` H. Peter Anvin
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=20160821064229.GX2356@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=Vineet.Gupta1@synopsys.com \
--cc=hpa@zytor.com \
--cc=jakub@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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.